44
44
45
45
@static if Base. VERSION >= v " 1.9.0"
46
46
# 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.
48
48
# 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`
49
52
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
51
61
elseif v " 1.6.0" <= Base. VERSION < v " 1.9.0"
52
62
# In Julia 1.6 through 1.8, the no-argument method `Distributed.default_addprocs_params()`
53
63
# does not include :env. However, Julia does allow us to add a specialized method
54
64
# `Distributed.default_addprocs_params(::SlurmManager)`, so we do so here.
55
65
#
56
66
# 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.
58
70
#
59
71
# See also: https://github.com/JuliaLang/julia/blob/v1.8.0/stdlib/Distributed/src/cluster.jl#L526-L540
60
72
function Distributed. default_addprocs_params (:: SlurmManager )
61
73
our_stuff = Dict {Symbol,Any} (
62
74
:env => [],
75
+ custom_worker_flag = ` --worker` ,
63
76
)
64
77
upstreams_stuff = Distributed. default_addprocs_params ()
65
78
total_stuff = merge (our_stuff, upstreams_stuff)
@@ -69,6 +82,10 @@ elseif Base.VERSION < v"1.6.0"
69
82
# In Julia 1.5 and earlier, Julia does not have the `addenv()` function.
70
83
# I don't want to add a dependency on Compat.jl just for this one feature,
71
84
# 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.
72
89
end
73
90
74
91
function _new_environment_additions (params_env:: Dict{String, String} )
@@ -178,8 +195,9 @@ function Distributed.launch(manager::SlurmManager, params::Dict, instances_arr::
178
195
exehome = params[:dir ]
179
196
exename = params[:exename ]
180
197
exeflags = params[:exeflags ]
198
+ custom_worker_flag = params[:custom_worker_flag ]
181
199
182
- _srun_cmd_without_env = ` srun -D $exehome $exename $exeflags --worker `
200
+ _srun_cmd_without_env = ` srun -D $exehome $exename $exeflags $custom_worker_flag `
183
201
184
202
@static if Base. VERSION >= v " 1.6.0"
185
203
# Pass the key-value pairs from `params[:env]` to the `srun` command:
0 commit comments