4444
4545@static if Base. VERSION >= v " 1.9.0"
4646 # In Julia 1.9 and later, the no-argument method `Distributed.default_addprocs_params()`
47- # includes :env, so we don't need to do anything .
47+ # includes :env.
4848 # See also: https://github.com/JuliaLang/julia/blob/v1.9.0/stdlib/Distributed/src/cluster.jl#L526-L541
49+ #
50+ # So we don't need to add `:env`
51+ # But we do still need to add `:custom_worker_flag`
4952
50- Distributed. default_addprocs_params (:: SlurmManager ) = Distributed. default_addprocs_params ()
53+ function Distributed. default_addprocs_params (:: SlurmManager )
54+ our_stuff = Dict {Symbol,Any} (
55+ :custom_worker_flag => ` --worker` ,
56+ )
57+ upstreams_stuff = Distributed. default_addprocs_params ()
58+ total_stuff = merge (our_stuff, upstreams_stuff)
59+ return total_stuff
60+ end
5161elseif v " 1.6.0" <= Base. VERSION < v " 1.9.0"
5262 # In Julia 1.6 through 1.8, the no-argument method `Distributed.default_addprocs_params()`
5363 # does not include :env. However, Julia does allow us to add a specialized method
5464 # `Distributed.default_addprocs_params(::SlurmManager)`, so we do so here.
5565 #
5666 # The ability to add the specialized `Distributed.default_addprocs_params(::SlurmManager)`
57- # method was added to Julia in https://github.com/JuliaLang/julia/pull/38570
67+ # method was added to Julia in https://github.com/JuliaLang/julia/pull/38570,
68+ # which corresponds to https://github.com/JuliaLang/julia/commit/687378ebfd1188ee7af302ec089cf3d31689647c,
69+ # which is in Julia 1.6 and later.
5870 #
5971 # See also: https://github.com/JuliaLang/julia/blob/v1.8.0/stdlib/Distributed/src/cluster.jl#L526-L540
6072 function Distributed. default_addprocs_params (:: SlurmManager )
6173 our_stuff = Dict {Symbol,Any} (
6274 :env => [],
75+ :custom_worker_flag => ` --worker` ,
6376 )
6477 upstreams_stuff = Distributed. default_addprocs_params ()
6578 total_stuff = merge (our_stuff, upstreams_stuff)
@@ -69,6 +82,10 @@ elseif Base.VERSION < v"1.6.0"
6982 # In Julia 1.5 and earlier, Julia does not have the `addenv()` function.
7083 # I don't want to add a dependency on Compat.jl just for this one feature,
7184 # so we will just choose to not support `params[:env]` on Julia 1.5 and earlier.
85+ #
86+ # Also, in Julia 1.5 and earlier, Julia does not have the
87+ # ability to add the specialized `Distributed.default_addprocs_params(::SlurmManager)`
88+ # method.
7289end
7390
7491function _new_environment_additions (params_env:: Dict{String, String} )
@@ -178,8 +195,9 @@ function Distributed.launch(manager::SlurmManager, params::Dict, instances_arr::
178195 exehome = params[:dir ]
179196 exename = params[:exename ]
180197 exeflags = params[:exeflags ]
198+ custom_worker_flag = params[:custom_worker_flag ]
181199
182- _srun_cmd_without_env = ` srun -D $exehome $exename $exeflags --worker `
200+ _srun_cmd_without_env = ` srun -D $exehome $exename $exeflags $custom_worker_flag `
183201
184202 @static if Base. VERSION >= v " 1.6.0"
185203 # Pass the key-value pairs from `params[:env]` to the `srun` command:
0 commit comments