@@ -171,31 +171,42 @@ function warn_if_unexpected_params(params::Dict)
171
171
return nothing
172
172
end
173
173
174
+ @static if Base. VERSION >= v " 1.6.0"
175
+ # Pass the key-value pairs from `params[:env]` to the `srun` command:
176
+ function construct_srun_cmd (; params:: Dict )
177
+ exehome = params[:dir ]
178
+ exename = params[:exename ]
179
+ exeflags = params[:exeflags ]
180
+
181
+ _srun_cmd_without_env = ` srun -D $exehome $exename $exeflags --worker`
182
+
183
+ env2 = _new_environment_additions (Dict {String,String} (params[:env ]))
184
+ srun_cmd_with_env = addenv (_srun_cmd_without_env, env2)
185
+
186
+ return srun_cmd_with_env
187
+ end
188
+ else
189
+ # See discussion above for why we don't support this functionality on Julia 1.5 and earlier.
190
+ function construct_srun_cmd (; params:: Dict )
191
+ exehome = params[:dir ]
192
+ exename = params[:exename ]
193
+ exeflags = params[:exeflags ]
194
+
195
+ _srun_cmd_without_env = ` srun -D $exehome $exename $exeflags --worker`
196
+
197
+ return _srun_cmd_without_env
198
+ end
199
+ end
200
+
174
201
function Distributed. launch (manager:: SlurmManager , params:: Dict , instances_arr:: Array , c:: Condition )
175
202
try
176
203
warn_if_unexpected_params (params)
177
204
178
- exehome = params[:dir ]
179
- exename = params[:exename ]
180
- exeflags = params[:exeflags ]
181
-
182
- _srun_cmd_without_env = ` srun -D $exehome $exename $exeflags --worker`
183
-
184
- @static if Base. VERSION >= v " 1.6.0"
185
- # Pass the key-value pairs from `params[:env]` to the `srun` command:
186
- env2 = _new_environment_additions (Dict {String,String} (params[:env ]))
187
- srun_cmd_with_env = addenv (_srun_cmd_without_env, env2)
188
- else
189
- # See discussion above for why we don't support this functionality on Julia 1.5 and earlier.
190
- if haskey (params, :env )
191
- @warn " SlurmClusterManager.jl does not support params[:env] on Julia 1.5 and earlier" Base. VERSION
192
- end
193
- srun_cmd_with_env = _srun_cmd_without_env
194
- end
205
+ srun_cmd = construct_srun_cmd (; params= params)
195
206
196
207
# Pass cookie as stdin to srun; srun forwards stdin to process
197
208
# This way the cookie won't be visible in ps, top, etc on the compute node
198
- manager. srun_proc = open (srun_cmd_with_env , write= true , read= true )
209
+ manager. srun_proc = open (srun_cmd , write= true , read= true )
199
210
write (manager. srun_proc, cluster_cookie ())
200
211
write (manager. srun_proc, " \n " )
201
212
0 commit comments