Hi Neil, can you retry after applying this commit from my new pull request? https://bitbucket.org/nsoranzo/galaxy-central/commits/11597a078e650508706431... -- Nicola Soranzo Bioinformatics Program, CRS4 Loc. Piscina Manna, 09010 Pula (CA), Italy http://www.bioinformatica.crs4.it/ Neil.Burdett@csiro.au ha scritto:
Hi Nicola, I've merged your changes into my version of the galaxy code (slightly older than galaxy-central) I believe, however, I get the following error when I try and execute your script:
Traceback (most recent call last): File "get_wfs.py", line 13, in <module> common.post(api_key, 'http://barium-rbh:9100/extras/api/workflows/import', data) File "/home/galaxy/milxcloud/scripts/api/common.py", line 48, in post return simplejson.loads( urllib2.urlopen( req ).read() ) File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 406, in open response = meth(req, response) File "/usr/lib/python2.7/urllib2.py", line 519, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python2.7/urllib2.py", line 444, in error return self._call_chain(*args) File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 527, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 500: Internal Server Error
so I printed out the some lines in common.py
def post( api_key, url, data ): # Do the actual POST. url = make_url( api_key, url ) print "URL is %s" % url
URL is http://barium-rbh:9100/extras/api/workflows/import?key=34ee80757f0d03de36e33...
the script is: import sys #sys.path.insert(1, 'milxcloud/scripts/api') import common api_key = '34ee80757f0d03de36e33a1676d245e4' workflows = common.get(api_key, 'http://barium-rbh:9100/api/workflows?show_published=True') print workflows published_workflow_ids = [str(workflow[u'id']) for workflow in workflows if bool(workflow[u'published'])] print published_workflow_ids
for pw_id in published_workflow_ids: data = {} data['workflow_id'] = pw_id common.post(api_key, 'http://barium-rbh:9100/extras/api/workflows/import', data)
and I run it from ~/scripts/api
The output from the script is : python get_wfs.py [{'name': 'SUVR', 'tags': [], 'url': '/extras/api/workflows/f2db41e1fa331b3e', 'published': True, 'model_class': 'StoredWorkflow', 'id': 'f2db41e1fa331b3e'}, {'name': 'processSUVRData', 'tags': [], 'url': '/extras/api/workflows/f597429621d6eb2b', 'published': True, 'model_class': 'StoredWorkflow', 'id': 'f597429621d6eb2b'}] ['f2db41e1fa331b3e', 'f597429621d6eb2b'] URL is http://barium-rbh:9100/extras/api/workflows/import?key=34ee80757f0d03de36e33...
Any ideas why the import maybe failing?
Thanks Neil
________________________________________ From: Nicola Soranzo [soranzo@crs4.it] Sent: Monday, January 20, 2014 9:03 PM To: Burdett, Neil (CCI, Herston - RBWH) Cc: galaxy-dev@lists.bx.psu.edu Subject: Re: Import workflows via API
Hi Neil, to import all published workflows you can use a script like this:
import sys sys.path.insert(1, 'galaxy-central/scripts/api') import common api_key = 'YOUR_USER_API_KEY' workflows = common.get(api_key, 'http://YOUR_SERVER/api/workflows?show_published=True') published_workflow_ids = [str(workflow[u'id']) for workflow in workflows if bool(workflow[u'published'])] for pw_id in published_workflow_ids: data['workflow_id'] = pw_id common.post(api_key, 'http://YOUR_SERVER/api/workflows/import', data)
Nicola
Il 2014-01-19 03:12 Neil.Burdett@csiro.au ha scritto:
Hi Nicola, that is exactly what I'm looking for, however, how do I execute the script/tool? I would like to import all published workflows. What is the name of the script to run and the arguments ? Can you give an example please?
Thanks again Neil
Date: Fri, 17 Jan 2014 11:36:03 +0100 From: Nicola Soranzo <soranzo@crs4.it> To: <galaxy-dev@lists.bx.psu.edu> Subject: Re: [galaxy-dev] Import workflows via API Message-ID: <d834d247437269704a26e8bbf8f678c2@crs4.it> Content-Type: text/plain; charset=UTF-8; format=flowed
Il 2014-01-17 06:45 Neil.Burdett@csiro.au ha scritto:
Hi,
I execute workflows via the API. However, if I want another user to use my workflows, I can publish my workflows, but the new user then has to go on to the web browser and import this workflow.
Is there a method/script which I can call via the API which can import all available (published) workflows so the user doesn't have to click a button on the web browser "import workflow" ?
Thanks for any help
Hi Neil, you are very lucky, just yesterday my pull request implementing exactly this has been merged in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/pull-request/298/api-display-and...
and is also available in BioBlend thanks to my colleague Simone Leo:
https://github.com/afgane/bioblend/pull/51
Best, Nicola
-- Nicola Soranzo, Ph.D. Bioinformatics Program, CRS4 Loc. Piscina Manna, 09010 Pula (CA), Italy http://www.bioinformatica.crs4.it/