Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: typos revealed by JET.jl #9

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading