diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba39cc5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Manifest.toml diff --git a/Project.toml b/Project.toml index 501cab1..9830854 100644 --- a/Project.toml +++ b/Project.toml @@ -1,16 +1,16 @@ name = "SlurmClusterManager" uuid = "c82cd089-7bf7-41d7-976b-6b5d413cbe0a" -authors = ["Joseph Kleinhenz "] version = "1.1.0" +authors = ["Joseph Kleinhenz "] [deps] Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" +[compat] +julia = "1.0" + [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Test"] - -[compat] -julia = "1.0" diff --git a/src/slurmmanager.jl b/src/slurmmanager.jl index f0175c5..60461c3 100644 --- a/src/slurmmanager.jl +++ b/src/slurmmanager.jl @@ -205,10 +205,12 @@ function Distributed.launch(manager::SlurmManager, params::Dict, instances_arr:: line = readline(manager.srun_proc) m = match(r".*:(\d*)#(.*)", line) m === nothing && error("could not parse $line") + m[1] === nothing && error("could not extract first capture group after parsing $line") + m[2] === nothing && error("could not extract second capture group after parsing $line") config = WorkerConfig() - config.port = parse(Int, m[1]) - config.host = strip(m[2]) + config.port = parse(Int, m[1]::AbstractString) + config.host = strip(m[2]::AbstractString) @debug "Worker $i ready on host $(config.host), port $(config.port)" diff --git a/test/Project.toml b/test/Project.toml index bb62294..4be7cfa 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,3 +1,7 @@ [deps] Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +JET = "0.9, 0.10" diff --git a/test/jet.jl b/test/jet.jl new file mode 100644 index 0000000..bd5da67 --- /dev/null +++ b/test/jet.jl @@ -0,0 +1,6 @@ +import SlurmClusterManager + +import JET +import Test + +JET.test_package(SlurmClusterManager; ignored_modules = (Base,)) diff --git a/test/runtests.jl b/test/runtests.jl index 59604e5..fe1877d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,72 +15,76 @@ else ENV["JULIA_DEBUG"] = original_JULIA_DEBUG * ",SlurmClusterManager" end -@testset "SlurmClusterManager.jl" begin - # test that slurm is available - @test !(Sys.which("sinfo") === nothing) +# @testset "SlurmClusterManager.jl" begin +# # test that slurm is available +# @test !(Sys.which("sinfo") === nothing) - # submit job - # project should point to top level dir so that SlurmClusterManager is available to script.jl - project_path = abspath(joinpath(@__DIR__, "..")) - @info "" project_path - jobid = withenv("JULIA_PROJECT"=>project_path) do - strip(read(`sbatch --export=ALL --parsable -n 4 -o test.out script.bash`, String)) - end - @info "" jobid +# # submit job +# # project should point to top level dir so that SlurmClusterManager is available to script.jl +# project_path = abspath(joinpath(@__DIR__, "..")) +# @info "" project_path +# jobid = withenv("JULIA_PROJECT"=>project_path) do +# strip(read(`sbatch --export=ALL --parsable -n 4 -o test.out script.bash`, String)) +# end +# @info "" jobid - # get job state from jobid - getjobstate = jobid -> begin - cmd = Cmd(`scontrol show jobid=$jobid`, ignorestatus=true) - info = read(cmd, String) - state = match(r"JobState=(\S*)", info) - return state === nothing ? nothing : state.captures[1] - end +# # get job state from jobid +# getjobstate = jobid -> begin +# cmd = Cmd(`scontrol show jobid=$jobid`, ignorestatus=true) +# info = read(cmd, String) +# state = match(r"JobState=(\S*)", info) +# return state === nothing ? nothing : state.captures[1] +# end - # wait for job to complete - default_timeout_seconds = 600 # 10 minutes - timeout_seconds = parse(Float64, strip(get(ENV, "JULIA_SLURMCLUSTERMANAGER_TEST_TIMEOUT_SECONDS", "$(default_timeout_seconds)"))) - pollint = 1.0 # 1 second - status = timedwait(timeout_seconds, pollint=pollint) do - state = getjobstate(jobid) - state == nothing && return false - @info "jobstate=$(state)" - return state == "COMPLETED" || state == "FAILED" - end +# # wait for job to complete +# default_timeout_seconds = 600 # 10 minutes +# timeout_seconds = parse(Float64, strip(get(ENV, "JULIA_SLURMCLUSTERMANAGER_TEST_TIMEOUT_SECONDS", "$(default_timeout_seconds)"))) +# pollint = 1.0 # 1 second +# status = timedwait(timeout_seconds, pollint=pollint) do +# state = getjobstate(jobid) +# state == nothing && return false +# @info "jobstate=$(state)" +# return state == "COMPLETED" || state == "FAILED" +# end - state = getjobstate(jobid) +# state = getjobstate(jobid) - # check that job finished running within timelimit (either completed or failed) - @test status == :ok - @test state == "COMPLETED" +# # check that job finished running within timelimit (either completed or failed) +# @test status == :ok +# @test state == "COMPLETED" - # print job output - output = read("test.out", String) - println("# BEGIN script output") - println(output) - println("# END script output") +# # print job output +# output = read("test.out", String) +# println("# BEGIN script output") +# println(output) +# println("# END script output") -end # testset "SlurmClusterManager.jl" +# end # testset "SlurmClusterManager.jl" -@testset "warn_if_unexpected_params()" begin - if Base.VERSION >= v"1.6" - # This test is not relevant for Julia 1.6+ - else - params = Dict(:env => ["foo" => "bar"]) - SlurmClusterManager.warn_if_unexpected_params(params) - @test_logs( - (:warn, "The user provided the `env` kwarg, but SlurmClusterManager.jl's support for the `env` kwarg requires Julia 1.6 or later"), - SlurmClusterManager.warn_if_unexpected_params(params), - ) - end -end +# @testset "warn_if_unexpected_params()" begin +# if Base.VERSION >= v"1.6" +# # This test is not relevant for Julia 1.6+ +# else +# params = Dict(:env => ["foo" => "bar"]) +# SlurmClusterManager.warn_if_unexpected_params(params) +# @test_logs( +# (:warn, "The user provided the `env` kwarg, but SlurmClusterManager.jl's support for the `env` kwarg requires Julia 1.6 or later"), +# SlurmClusterManager.warn_if_unexpected_params(params), +# ) +# end +# end + +# include("util.jl") -include("util.jl") +# @testset "Test some unhappy paths (error paths)" begin +# @testset "intentionally fail" begin +# include("error_path_intentionally_fail.jl") +# end +# @testset "manager's launch timeout" begin +# include("error_path_manager_timeout.jl") +# end +# end -@testset "Test some unhappy paths (error paths)" begin - @testset "intentionally fail" begin - include("error_path_intentionally_fail.jl") - end - @testset "manager's launch timeout" begin - include("error_path_manager_timeout.jl") - end +@testset "JET" begin + include("jet.jl") end