Question: Trouble galaxy API set_as_current
1
gravatar for dgygax
4.4 years ago by
dgygax50
United States
dgygax50 wrote:

I am trying to change the current working history using the API. In order to do so I have imported the python module requests. The python code I am running is:

 

import requests

requests.put('http://localhost:8080/api/histories/e144222fed44799a/set_as_current?key=ee91bee815264e77d38e16dd5ed2e5c9')

 

e144222fed44799a is the history id I want to set as current

ee91bee815264e77d38e16dd5ed2e5c9 is my current API key

 

When I run the code the following error is returned in the terminal where I am running galaxy:

 

galaxy.web.framework ERROR 2014-07-21 19:08:30,597 Uncaught exception in exposed API method:

Traceback (most recent call last):

  File "/Users/derekgygax/Desktop/galaxy-dist/lib/galaxy/web/framework/__init__.py", line 331, in decorator

    rval = func( self, trans, *args, **kwargs)

  File "/Users/derekgygax/Desktop/galaxy-dist/lib/galaxy/webapps/galaxy/api/histories.py", line 139, in set_as_current

    trans.history = history

  File "/Users/derekgygax/Desktop/galaxy-dist/lib/galaxy/web/framework/__init__.py", line 1022, in set_history

    self.galaxy_session.current_history = history

AttributeError: 'NoneType' object has no attribute 'current_history'

127.0.0.1 - - [21/Jul/2014:19:08:30 -0400] "PUT /api/histories/e144222fed44799a/set_as_current?key=ee91bee815264e77d38e16dd5ed2e5c9 HTTP/1.1" 500 - "-" "python-requests/2.3.0 CPython/2.7.5 Darwin/13.3.0"

 

Any help resolving this issue would be much appreciated.

api history galaxy • 1.5k views
ADD COMMENTlink modified 4.4 years ago by Martin Čech ♦♦ 4.9k • written 4.4 years ago by dgygax50
1

Hi, dgygax.

Martin's right. This API call is used exclusively by the UI/client-side code. There's unfortunately no way to make it work purely with the API (with no browser session for the user) alone.

It's on my list to:

  • make a note of that in the docs for that method
  • decide whether it should be removed entirely from the API section and moved into the web controllers

Is there a reason you need to set the current history? Most functionality (running tools, uploading datasets, etc.) should work using a 'history_id' parameter to specify which history you want 'to work in' (similar to the browser UI's notion of a 'current history'). Please let us know if you see something that doesn't work that way or that requires a current history.

Thanks for the report and apologies for the confusion,

Carl

ADD REPLYlink modified 4.4 years ago • written 4.4 years ago by carlfeberhard390
1

We are using galaxy to automate a workflow for lab technicians. Each time they run the workflow for a given batch we want a separate history for that batch. Rather than relying on the technician to create a history we want galaxy to automatically create a history each time the workflow is run and switch to it. Do you have any suggestion for how we might accomplish this?

ADD REPLYlink written 4.4 years ago by dgygax50
1

Ok. That should be do-able by:

  1. Creating a new history: POST /api/histories (optionally including a name). This will return JSON describing the new history (including the id - important for the next step).
  2. Running the workflow over the API passing in the new history's id as 'hist_id=<new id>'. See this page in the docs for more info and options: http://galaxy-central.readthedocs.org/en/latest/lib/galaxy.webapps.galaxy.api.html#galaxy.webapps.galaxy.api.workflows.WorkflowsAPIController.create
ADD REPLYlink written 4.4 years ago by carlfeberhard390
2
gravatar for Martin Čech
4.4 years ago by
Martin Čech ♦♦ 4.9k
United States
Martin Čech ♦♦ 4.9k wrote:

It seems you have to have a session in order to set a history as current. :/

The method's code needs to be adjusted to accomodate the case that it is used purely via the API.

ADD COMMENTlink modified 4.4 years ago • written 4.4 years ago by Martin Čech ♦♦ 4.9k
1

There is a Trello card tracking the progress of this feature: https://trello.com/c/hsu9WWpS/1836-trouble-using-galaxy-api-method-set-as-current

You can vote on it to make it a priority.

ADD REPLYlink modified 4.4 years ago • written 4.4 years ago by Martin Čech ♦♦ 4.9k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 166 users visited in the last hour