Skip to content

Commit

Permalink
Merge branch 'mp/jet-ci' of github.com:JuliaComputing/JuliaHub.jl int…
Browse files Browse the repository at this point in the history
…o mp/jet-ci
  • Loading branch information
mortenpi committed Jul 5, 2023
2 parents 4efe845 + 8800559 commit b74e182
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/batchimages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ function _group_images(images; image_group::AbstractString)
for image in images
if !isa(image, Dict)
msg = """
Invalid JSON returned by the server: value for '$(image_group)' not an object
$(r_json_str)
Invalid JSON returned by the server: image value is not an object
image_group = $(image_group)
image = $(image)
"""
throw(JuliaHubError(msg))
end
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/logging-legacy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ end

function _job_logs_legacy_start_streaming!(auth::Authentication, buffer::_LegacyLogsBuffer)
if !isnothing(buffer._stream)
@warn "Logs are already being streamed" b._jobname
@warn "Logs are already being streamed" buffer._jobname
return nothing
end
# If we're not already streaming, we construct a new _JobLogTask
Expand Down
8 changes: 4 additions & 4 deletions src/node.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ function nodespec(
# in the other method; but it's valid to pass here too
auth::Union{Authentication, Nothing}=nothing,
)
ncpu < 1 && throw(ArgumentError("ncpu must be >= 1"))
ngpu < 0 && throw(ArgumentError("ngpu must be >= 0"))
memory < 1 && throw(ArgumentError("memory must be >= 1"))
ncpu < 1 && Base.throw(ArgumentError("ncpu must be >= 1"))
ngpu < 0 && Base.throw(ArgumentError("ngpu must be >= 0"))
memory < 1 && Base.throw(ArgumentError("memory must be >= 1"))
if ngpu >= 2
return _throw_or_nothing(; msg="JuliaHub.jl does not support multi-GPU nodes", throw) do
return _throw_or_nothing(; msg="JuliaHub.jl does not support multi-GPU nodes", throw) do msg
@warn msg
end
end
Expand Down
4 changes: 3 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ end

_nothing_or(f::Base.Callable, x) = isnothing(x) ? nothing : f(x)

# Helper function to handle the
# Helper function to help manage the pattern where a function takes a 'throw::Bool` keyword
# argument and should either throw an InvalidRequestError, or return nothing.
#
# The nothrow_extra_logic_f(msg) callback can be used (via do syntax) do run additional code
# before returning if throw=false. 'msg' is passed as the first argument.
function _throw_or_nothing(
Expand Down
5 changes: 5 additions & 0 deletions test/jobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ end
@test n.vcores == 2
@test n.mem == 8
end

# Test the `throw` argument by requesting unsupported multi-GPU nodes
@test_throws JuliaHub.InvalidRequestError JuliaHub.nodespec(; ngpu=10)
@test_throws JuliaHub.InvalidRequestError JuliaHub.nodespec(; ngpu=10, throw=true)
@test @test_logs (:warn,) JuliaHub.nodespec(; ngpu=10, throw=false) === nothing
end
end

Expand Down

0 comments on commit b74e182

Please sign in to comment.