Skip to content

Commit 25fa212

Browse files
committed
Fixed handling of env vars in Slurm. The existing template made some
assumptions about how the process worked that were incorrect. Specifically, you cannot issue multiple `#SBATCH --export` directives and expect them to add up. Only one should be used.
1 parent 391eb6b commit 25fa212

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/psij/executors/batch/slurm/slurm.mustache

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
#SBATCH --chdir="{{.}}"
99
{{/job.spec.directory}}
1010

11-
{{#job.spec.inherit_environment}}
12-
#SBATCH --export=ALL
13-
{{/job.spec.inherit_environment}}
14-
{{^job.spec.inherit_environment}}
15-
#SBATCH --export=NONE
16-
{{/job.spec.inherit_environment}}
17-
1811
{{#job.spec.resources}}
1912
{{#exclusive_node_use}}
2013
#SBATCH --exclusive
@@ -80,9 +73,17 @@ export PSIJ_NODEFILE
8073

8174

8275
{{#env}}
83-
#SBATCH --export={{name}}={{value}}
76+
export {{name}}={{value}}
8477
{{/env}}
8578

79+
{{#job.spec.inherit_environment}}
80+
#SBATCH --export=ALL{{#env}},{{name}}{{/env}}
81+
{{/job.spec.inherit_environment}}
82+
{{^job.spec.inherit_environment}}
83+
#SBATCH --export={{#env}}{{name}},{{/env}}
84+
{{/job.spec.inherit_environment}}
85+
86+
8687
{{!redirect output here instead of through #SBATCH directive since SLURM_JOB_ID is not available
8788
when the directives are evaluated; the reason for using the job id in the first place being the
8889
same as for the exit code file.}}

0 commit comments

Comments
 (0)