How to pass arguments in pipeline to a python script

274 views
Skip to first unread message

Jani Issakainen

unread,
Jun 8, 2020, 8:55:36 AM6/8/20
to xnat_discussion
Hi,

I'm trying to pass arguments to a python script in my pipeline. Right now my pipeline launches successfully and triggers the python script "HelloW.py", which simply writes "Hello World" and some info about input arguments to a file called "hw.txt". Here is an example output.
"
Hello World! Number of arguments: 1 args
 Argument List: ['/data/xnat/pipeline/catalog/HW2/scripts/HelloW.py']
"

The problem is that  in my opinion I'm actually passing more arguments that never reach the script.  Right now I'm just passing test string arguments, but later I'd like to be able to pass a file path as an argument to the script so I can run sanity check and analysis on the session data. I have tested the HelloW.py manually on terminal and it takes arguments in just fine. Could someone help and tell me what I'm doing wrong please? Mistakes are probably somewhere here in these xml files.

Here is my step in pipeline xml:
"
...
<steps>
<step id="Greet the world" description="Greet the world with a proper hello!" workdirectory="^/Pipeline/parameters/parameter[name='workdir']/values/unique/text()^">
<resource name="HelloW" location="HW2/resources" >
<argument id="session">
<value>"Hello World2 test"</value>
</argument>
</resource>
</step>
</steps>
...
"
and here is the resource descriptor for the HelloW.py
"
<?xml version="1.0" encoding="UTF-8"?>
<pip:Resource xmlns:pip="http://nrg.wustl.edu/pipeline">
<pip:name>HelloW.py</pip:name>
<pip:commandPrefix>python</pip:commandPrefix>
<pip:location>HW2/scripts</pip:location>
<pip:type>Executable</pip:type>
<pip:input>
<pip:argument id="session">
<pip:description>Session ID</pip:description>
</pip:argument>
</pip:input>
</pip:Resource>
"

Just to reiterate and summarize. This pipeline successfully launches HelloW.py which runs fine - but it doesn't get the argument (id="session" and value "Hello World2 test")

Any help would be much appreciated. Thanks.
Reply all
Reply to author
Forward
0 new messages