|
3 | 3 | # We don't use `using Foo` here.
|
4 | 4 | # We either use `using Foo: hello, world`, or we use `import Foo`.
|
5 | 5 | # https://github.com/JuliaLang/julia/pull/42080
|
6 |
| -using Distributed: addprocs, workers, nworkers, remotecall_fetch |
| 6 | +using Distributed: addprocs, workers, nworkers, remotecall_fetch, @everywhere |
7 | 7 | using SlurmClusterManager: SlurmManager
|
8 | 8 |
|
9 | 9 | addprocs(SlurmManager())
|
10 | 10 |
|
| 11 | +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 12 | +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 13 | +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 14 | + |
| 15 | +# To run tests outside of CI, set e.g. |
| 16 | +# `export JULIA_SLURMCLUSTERMANAGER_IS_CI=false` |
| 17 | +# in your Bash session before you launch the Slurm job. |
| 18 | +function is_ci() |
| 19 | + name = "JULIA_SLURMCLUSTERMANAGER_IS_CI" |
| 20 | + |
| 21 | + # We intentionally default to true. |
| 22 | + # This allows things to work in our CI (which is inside of Docker). |
| 23 | + default_value = "true" |
| 24 | + |
| 25 | + value_str = strip(get(ENV, name, default_value)) |
| 26 | + value_b = parse(Bool, value_str) |
| 27 | + return value_b |
| 28 | +end |
| 29 | + |
| 30 | +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 31 | +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 32 | +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 33 | + |
11 | 34 | # We intentionally do not use `@assert` here.
|
12 | 35 | # In a future minor release of Julia, `@assert`s may be disabled by default.
|
13 | 36 | const SLURM_NTASKS = parse(Int, ENV["SLURM_NTASKS"])
|
|
22 | 45 | sort!(hosts)
|
23 | 46 | println("List of hosts: ", hosts)
|
24 | 47 |
|
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) |
| 48 | +if is_ci() |
| 49 | + @info "This is CI, so we will perform the hostname test" |
| 50 | + |
| 51 | + # We don't use `@assert` here, for reason described above. |
| 52 | + if hosts != ["c1", "c1", "c2", "c2"] |
| 53 | + msg = "Test failed: observed_hosts=$(hosts) does not match expected_hosts=[c1, c1, c2, c2]" |
| 54 | + error(msg) |
| 55 | + end |
| 56 | +else |
| 57 | + @warn "This is not CI, so we will skip the hostname test" |
29 | 58 | end
|
| 59 | + |
| 60 | +@everywhere import Distributed |
| 61 | + |
| 62 | +# Workers report in: |
| 63 | +@everywhere println("Host $(Distributed.myid()): $(gethostname())") |
0 commit comments