Hi everybody.
I’m developing a tool that allows to choose between different options for a query.
Now my code is inside a python file where for each type of query I have a different function.
Following this guide I created the XML file and everything is running correctly without errors when I start Galaxy.
The problem is that when I run the tool (with every option) I get this error:
Job submission failed.
The server could not complete this request. Please verify your parameter settings, retry submission and contact the Galaxy Team if this error persists. A transcript of the submitted data is shown below.
In the terminal I get this:
galaxy.tools ERROR 2022-02-28 11:43:36,932 [pN:main.web.1,p:13472,w:1,m:0,tN:uWSGIWorker1Core0] Exception caught while attempting to execute tool with id 'impc_test':
Traceback (most recent call last):
File "lib/galaxy/util/template.py", line 80, in fill_template
return unicodify(t, log_exception=False)
File "lib/galaxy/util/__init__.py", line 1060, in unicodify
value = str(value)
File "/Users/andrea/Desktop/galaxy/.venv/lib/python3.6/site-packages/Cheetah/Template.py", line 1053, in __unicode__
return getattr(self, mainMethName)()
File "cheetah_DynamicallyCompiledCheetahTemplate_1646045016_93172_79883.py", line 91, in respond
EOFError: EOF when reading a line
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "lib/galaxy/tools/__init__.py", line 1770, in handle_single_execution
flush_job=flush_job,
File "lib/galaxy/tools/__init__.py", line 1858, in execute
return self.tool_action.execute(self, trans, incoming=incoming, set_output_hid=set_output_hid, history=history, **kwargs)
File "lib/galaxy/tools/actions/__init__.py", line 529, in execute
handle_output(name, output)
File "lib/galaxy/tools/actions/__init__.py", line 455, in handle_output
data.name = self.get_output_name(output, data, tool, on_text, trans, incoming, history, wrapped_params.params, job_params)
File "lib/galaxy/tools/actions/__init__.py", line 784, in get_output_name
return fill_template(output.label, context=params, python_template_version=tool.python_template_version)
File "lib/galaxy/util/template.py", line 124, in fill_template
python_template_version=python_template_version,
File "lib/galaxy/util/template.py", line 126, in fill_template
raise first_exception or e
File "lib/galaxy/util/template.py", line 80, in fill_template
return unicodify(t, log_exception=False)
File "lib/galaxy/util/__init__.py", line 1060, in unicodify
value = str(value)
File "/Users/andrea/Desktop/galaxy/.venv/lib/python3.6/site-packages/Cheetah/Template.py", line 1053, in __unicode__
return getattr(self, mainMethName)()
File "DynamicallyCompiledCheetahTemplate.py", line 89, in respond
EOFError: EOF when reading a line
galaxy.tools.execute WARNING 2022-02-28 11:43:36,932 [pN:main.web.1,p:13472,w:1,m:0,tN:uWSGIWorker1Core0] There was a failure executing a job for tool [impc_test] - Error executing tool with id 'impc_test': EOF when reading a line
Here’s the .py code that I’m using as test and its XML file:
test.py (here I don’t have functions since I’m making tests on the input which is the part that, in my opinion, is raising the error)
import sys
import argparse
import requests
import pandas as pd
import numpy as np
def main():
# define options
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("-k", "--option", type=str, help="Option selected")
# parse
args = parser.parse_args()
option = str(args.option)
if option == 'q1':
print("Hello 1! Input: " + sys.argv[1])
textfile = open(sys.argv[2], "w+")
textfile.write( "Here's the input of first query: " + sys.argv[1] + "\n")
textfile.close()
elif option == 'q2':
print("Hello 2! Input: " + sys.argv[1])
textfile = open(sys.argv[2], "w+")
textfile.write( "Here's the input of second query: " + sys.argv[1] + "\n")
textfile.close()
else:
sys.exit("Error!")
if __name__ == "__main__":
main()
test.xml
<tool id="impc_test" name="Test " version="0.1.0">
<description>for impc query selection</description>
<requirements>
<requirement type="package">requests</requirement>
<requirement type="package">pandas</requirement>
<requirement type="package">numpy</requirement>
</requirements>
<command>
python3 "{$__tool_directory__/test.py}" '$query_type.input' '$output' #set $option = str($selector) --option $option
</command>
<inputs>
<conditional name="query_type">
<param name="selector" type="select" labels="Select a query:">
<option value="q1">First</option>
<option value="q2">Second</option>
</param>
<when value="q1">
<param name="input" type="text" label="Input 1:"/>
</when>
<when value="q2">
<param name="input" type="text" label="Input 2:"/>
</when>
</conditional>
</inputs>
<outputs>
<data format="tabular" name="output" label="${tool.name} on ${input}"/>
</outputs>
<help>
Just a test for IMPC queries.
</help>
</tool>
Essentially, I’m trying to set ‘option’ on different values so inside the code I can use it to call different functions.
Thank you all for the help.