bioblend icon indicating copy to clipboard operation
bioblend copied to clipboard

Error when trying to get ids of workflow outputs

Open stvlar opened this issue 2 years ago • 13 comments

Hello, I'm using bioblends to get results from workflows I've developed and my code worked well until recently. I'm trying to get the ids of the outputs to then download them as files through a web platform I'm developing with django.

This is the code I'm using:

  media_path = ".."
   result_path = ".."
   max_timeout = 1*24*60*60 #days*hours*mins*secs

   if request.method == 'POST':
       form = SnippetForm(request.POST, request.FILES)
       if form.is_valid():
           form = Snippet(file=request.FILES['file'])
           form.save()

           file_name_final = form.file.name[10:]
           file_path = media_path + file_name_final

          server = 'https://usegalaxy.eu/'
          api_key = ''
          gi = bioblend.galaxy.GalaxyInstance(url=server, key=api_key)

           test = gi.tools.upload_file(file_path, 'upload history id')

           hda = test['outputs'][0].get('id')
           datamap = dict()
           datamap = {0: {'id': hda['id'], 'src': 'hda'}}

           results_run = gi.workflows.invoke_workflow('workflow id', inputs=datamap, history_name='script results')
           results_id = results_run['outputs']
           id_str = ''.join(results_id)
           #download output to user's pc
           gi.datasets.download_dataset(id_str, file_path=result_path, maxwait=max_timeout)

stvlar avatar Jan 20 '22 08:01 stvlar