Command line arguments not being passed in sbatch
<p>I am trying to submit a job using the SLURM job scheduler and am finding that when I use the <code>--export=VAR=VALUE</code> syntax then some of my variables are not being passed (often the variable in the first instance of <code>export</code>). My understanding is that I need to specify <code>--export=...</code> for each variable, e.g.</p>

<pre><code>sbatch --export=build=true --export=param=p100_256 run.py
</code></pre>

<p>My script "run.py" looks like this:</p>

<pre><code>#! /usr/bin/env python                                                                                                                                                                                                      
import os,fnmatch

print(os.environ["SLURM_JOB_NAME"])
print(os.environ["SLURM_JOB_ID"])

print(fnmatch.filter(os.environ.keys(),"b*"))
print(fnmatch.filter(os.environ.keys(),"p*"))
</code></pre>

<p>I'd prefer to submit a python script as all of my existing scripts (used previously with PBS) are already in python and I don't want to have to rewrite them in shell scripts. My problem is best demonstrated through a short example. </p>

<p>Firstly,</p>

<pre><code>&gt; sbatch --export=build=true --export=param=p100_256 run.py
&gt; Submitted batch job 2249581
</code></pre>

<p>produces a log file with the following:</p>

<pre><code>run.py
2249581
[]
['param']
</code></pre>

<p>If I reverse the order of the <code>export</code> flags for 'build' and 'param',</p>

<pre><code>&gt; sbatch --export=param=true --export=build=p100_256 run.py
&gt; Submitted batch job 2249613
</code></pre>

<p>then the log file now looks like,</p>

<pre><code>run.py
2249613
['build']
[]
</code></pre>

<p>which would suggest that only the final instance of the <code>export</code> flag is being passed. If I add in a third instance of <code>export</code>,</p>

<pre><code> &gt; sbatch --export=param=1 --export=build=p100_256 --export=build_again=hello  run.py
 &gt; Submitted batch job 2249674
</code></pre>

<p>then the log file returns,</p>

<pre><code>run.py
2249674
['build_again']
[]
</code></pre>

<p>So does anybody know why only the final instance of <code>export</code> is being passed? Have I got the syntax incorrect? Do I need to specify an additional flag?</p>

<p>Thanks!</p>

<p>Yes, looks like I had the syntax incorrect. I missed in the documentation that additional variables should be comma separated and specified with a  single <code>export</code> flag, e.g.</p>

<pre><code>&gt; sbatch --export=build=true,param=p100_256 run.py
</code></pre>

<p>So previous instances of <code>export</code> must be being replaced each time <code>export</code> is specified.</p>

python command-line-arguments slurm