|
1 | 1 | #!/usr/bin/env julia
|
2 | 2 |
|
3 |
| -using Distributed, SlurmClusterManager |
| 3 | +# We don't use `using Foo` here. |
| 4 | +# We either use `using Foo: hello, world`, or we use `import Foo`. |
| 5 | +# https://github.com/JuliaLang/julia/pull/42080 |
| 6 | +using Distributed: addprocs, workers, nworkers, remotecall_fetch |
| 7 | +using SlurmClusterManager: SlurmManager |
| 8 | + |
4 | 9 | addprocs(SlurmManager())
|
5 | 10 |
|
6 |
| -@assert nworkers() == parse(Int, ENV["SLURM_NTASKS"]) |
| 11 | +# We intentionally do not use `@assert` here. |
| 12 | +# In a future minor release of Julia, `@assert`s may be disabled by default. |
| 13 | +const SLURM_NTASKS = parse(Int, ENV["SLURM_NTASKS"]) |
| 14 | +if nworkers() != SLURM_NTASKS |
| 15 | + msg = "Test failed: nworkers=$(nworkers()) does not match SLURM_NTASKS=$(SLURM_NTASKS)" |
| 16 | + error(msg) |
| 17 | +end |
7 | 18 |
|
8 |
| -hosts = map(workers()) do id |
| 19 | +const hosts = map(workers()) do id |
9 | 20 | remotecall_fetch(() -> gethostname(), id)
|
10 | 21 | end
|
11 | 22 | sort!(hosts)
|
12 | 23 | println(hosts)
|
13 | 24 |
|
14 |
| -@assert hosts == ["c1", "c1", "c2", "c2"] |
| 25 | +# We don't use `@assert` here, for reason described above. |
| 26 | +if hosts != ["c1", "c1", "c2", "c2"] |
| 27 | + msg = "Test failed: observed_hosts=$(hosts) does not match expected_hosts=[c1, c1, c2, c2]" |
| 28 | + error(msg) |
| 29 | +end |
0 commit comments