Skip to content

Commit

Permalink
chore: fix Julia formatting (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi authored May 27, 2024
1 parent ad5d0fb commit 1a1c5a6
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Mocking.apply(mocking_patch) do
authors="JuliaHub Inc.",
format=Documenter.HTML(;
canonical="https://help.juliahub.com/julia-api/stable",
edit_link="main"
edit_link="main",
),
pages=[
"Home" => "index.md",
Expand Down
4 changes: 2 additions & 2 deletions src/authentication.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function authenticate(
server_uri_string = if isnothing(server)
haskey(ENV, "JULIA_PKG_SERVER") || throw(
AuthenticationError(
"Either JULIA_PKG_SERVER must be set, or explicit `server` argument passed to JuliaHub.authenticate().",
"Either JULIA_PKG_SERVER must be set, or explicit `server` argument passed to JuliaHub.authenticate()."
),
)
Pkg.pkg_server()
Expand Down Expand Up @@ -442,7 +442,7 @@ function reauthenticate!(
if new_auth.username != auth.username
throw(
AuthenticationError(
"Username in new authentication ($(new_auth.username)) does not match original authentication ($(auth.username))",
"Username in new authentication ($(new_auth.username)) does not match original authentication ($(auth.username))"
),
)
end
Expand Down
16 changes: 8 additions & 8 deletions src/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function datasets(
e isa JuliaHubException && rethrow(e)
e isa JuliaHubError && rethrow(e)
throw(
JuliaHubError("Error while retrieving datasets from the server", e, catch_backtrace()),
JuliaHubError("Error while retrieving datasets from the server", e, catch_backtrace())
)
end
# It might happen that some of the elements of the `datasets` array can not be parsed for some reason,
Expand Down Expand Up @@ -406,7 +406,7 @@ function dataset end
@_authuser function dataset(
dsref::_DatasetRefTuple;
throw::Bool=true,
auth::Authentication=__auth__()
auth::Authentication=__auth__(),
)
username, dataset_name = dsref
for dataset in datasets(; shared=true, auth)
Expand Down Expand Up @@ -447,7 +447,7 @@ function delete_dataset end
@_authuser function delete_dataset(
dsref::_DatasetRefTuple;
force::Bool=false,
auth::Authentication=__auth__()
auth::Authentication=__auth__(),
)
username, dataset_name = dsref
_assert_current_user(username, auth; op="delete_dataset")
Expand Down Expand Up @@ -548,7 +548,7 @@ function upload_dataset end
# we must throw an invalid request error.
throw(
InvalidRequestError(
"Dataset '$dataset_name' for user '$username' already exists, but update=false and replace=false.",
"Dataset '$dataset_name' for user '$username' already exists, but update=false and replace=false."
),
)
elseif replace
Expand Down Expand Up @@ -600,7 +600,7 @@ function upload_dataset end
# dtype).
throw(
InvalidRequestError(
"Local data type ($dtype) does not match existing dataset dtype $(upload_config["dataset_type"])",
"Local data type ($dtype) does not match existing dataset dtype $(upload_config["dataset_type"])"
),
)
end
Expand All @@ -622,7 +622,7 @@ function upload_dataset end
if !all(ismissing.((description, tags, visibility, license, groups)))
update_dataset(
(username, dataset_name); auth,
description, tags, visibility, license, groups
description, tags, visibility, license, groups,
)
end
# If everything was successful, we'll return an updated DataSet object.
Expand Down Expand Up @@ -843,7 +843,7 @@ function download_dataset(
dsref::_DatasetRefTuple,
local_path::AbstractString;
auth::Authentication=__auth__(),
kwargs...
kwargs...,
)
ds = dataset(dsref; auth)
download_dataset(ds, local_path; auth, kwargs...)
Expand All @@ -858,7 +858,7 @@ function download_dataset(
)
dataset.dtype ["Blob", "BlobTree"] || throw(
InvalidRequestError(
"Download only supported for Blobs and BlobTrees, but '$(dataset.name)' is $(dataset.type)",
"Download only supported for Blobs and BlobTrees, but '$(dataset.name)' is $(dataset.type)"
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/jobs/jobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ function _download_job_file(auth::Authentication, file::JobFile, io::IO)
job_file_url,
_authheaders(auth);
status_exception=false,
response_stream=io
response_stream=io,
)
r.status == 200 || _throw_invalidresponse(r)
return nothing
Expand Down
10 changes: 5 additions & 5 deletions src/jobs/logging-kafka.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mutable struct KafkaLogsBuffer <: AbstractJobLogsBuffer
f,
nothing,
0,
ReentrantLock()
ReentrantLock(),
)
# If the user requested streaming too, then we start the background task.
stream && _job_logs_kafka_start_streaming!(auth, b)
Expand Down Expand Up @@ -142,7 +142,7 @@ function _job_logs_newer!(
consumer_id, logs, job_is_done = _get_logs_kafka_parsed(
auth, jobname;
offset=_kafka_next_offset(b),
timeout=_KAFKA_DEFAULT_GET_TIMEOUT
timeout=_KAFKA_DEFAULT_GET_TIMEOUT,
)
job_is_done && (b._found_last = true)
# If the returned list of logs is empty, we check if we can still update the cursor
Expand Down Expand Up @@ -176,7 +176,7 @@ function _job_logs_newer!(
next_offset = last(logs)._offset + 1
consumer_id, logs, job_is_done = _get_logs_kafka_parsed(
auth, jobname; offset=next_offset, consumer_id,
timeout=_KAFKA_DEFAULT_GET_TIMEOUT
timeout=_KAFKA_DEFAULT_GET_TIMEOUT,
)
job_is_done && (b._found_last = true)
end
Expand Down Expand Up @@ -257,7 +257,7 @@ function _job_logs_older!(
consumer_id, logs, _ = _get_logs_kafka_parsed(
auth, jobname;
offset=next_offset,
timeout=_KAFKA_DEFAULT_GET_TIMEOUT
timeout=_KAFKA_DEFAULT_GET_TIMEOUT,
)
# This should not normally happen because we should only be asking for logs that are actually present.
# But sometimes it does.. maybe when the timeout is not long enough? So we handle this by gracefully
Expand All @@ -278,7 +278,7 @@ function _job_logs_older!(
next_offset = last(logs)._offset + 1
consumer_id, logs, _ = _get_logs_kafka_parsed(
auth, jobname; offset=next_offset, consumer_id,
timeout=_KAFKA_DEFAULT_GET_TIMEOUT
timeout=_KAFKA_DEFAULT_GET_TIMEOUT,
)
@assert !isempty(logs)
end
Expand Down
6 changes: 3 additions & 3 deletions src/jobs/logging-legacy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function _get_job_logs_legacy(
query = Pair{String, Any}[
"log_output_type" => "content",
"jobname" => jobname,
"log_out_type" => "json"
"log_out_type" => "json",
]
if start_time !== nothing
if end_time !== nothing
Expand Down Expand Up @@ -224,7 +224,7 @@ function _get_job_logs_legacy(
if jb isa Dict && !get(jb, "success", true)
throw(
JuliaHubError(
"Downloading log content failed: `$(get(jb, "reason", get(jb, "message", "unknown error")))`",
"Downloading log content failed: `$(get(jb, "reason", get(jb, "message", "unknown error")))`"
),
)
end
Expand Down Expand Up @@ -461,7 +461,7 @@ function _job_logs_older!(
r = JuliaHub._get_job_logs_legacy(
auth, jobname;
end_time=timestamp,
event_id=reference_log._legacy_eventId
event_id=reference_log._legacy_eventId,
)
if isempty(r.logs)
# TODO: If the logs are empty, then something has probably gone wrong
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end
_print_log_list(logs::Vector{JobLogMessage}; kwargs...) = _print_log_list(stdout, logs; kwargs...)
function _print_log_list(
io::IO, logs::Vector{JobLogMessage}; all::Bool=false,
nlines::Integer=_default_display_lines(io)
nlines::Integer=_default_display_lines(io),
)
@assert Base.all(x -> isa(x, JobLogMessage), logs) # note: kwarg shadows function
@assert nlines >= 1
Expand Down
6 changes: 3 additions & 3 deletions src/jobsubmission.jl
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ function _upload_appbundle(appbundle_tar_path::AbstractString; auth::Authenticat
Mocking.@mock _restput_mockable(
upload_url,
["Content-Length" => filesize(appbundle_tar_path)],
input
input,
)
end
# The response body of a successful upload is empty
Expand Down Expand Up @@ -1136,7 +1136,7 @@ function submit_job(
end
submit_job(
WorkloadConfig(app, compute; alias, env, project, timelimit, _image_sha256);
kwargs...
kwargs...,
)
end

Expand Down Expand Up @@ -1290,7 +1290,7 @@ function _job_submit_args(
registry_name=packagejob.registry,
args=merge(
Dict("jobname" => packagejob.name, "jr_uuid" => packagejob.jr_uuid),
packagejob.args
packagejob.args,
),
# Just in case, we want to omit sysimage_build altogether when it is not requested.
sysimage_build=packagejob.sysimage ? true : nothing,
Expand Down
4 changes: 2 additions & 2 deletions src/node.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function _nodespec_exact(
if isempty(idxs)
return _throw_or_nothing(;
msg="Unable to find a nodespec: ncpu=$ncpu memory=$memory gpu=$gpu",
throw
throw,
)
end
if length(idxs) > 1
Expand All @@ -192,7 +192,7 @@ function _nodespec_smallest(
if isnothing(idx)
return _throw_or_nothing(;
msg="Unable to find a nodespec with at least: ncpu=$ncpu memory=$memory gpu=$gpu",
throw
throw,
)
else
return nodes[idx]
Expand Down
2 changes: 1 addition & 1 deletion src/userinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function _get_authenticated_user_legacy(server::AbstractString, token::Secret)::
json, _ = _parse_response_json(r, Dict)
users = _get_json(_get_json(json, "data", Dict; msg), "users", Vector)
length(users) == 1 || throw(
JuliaHubError("$msg\nInvalid JSON returned by the server: length(users)=$(length(users))"),
JuliaHubError("$msg\nInvalid JSON returned by the server: length(users)=$(length(users))")
)
user = only(users)
userid = _get_json(user, "id", Int; msg)
Expand Down
4 changes: 2 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function _parse_response_json(s::AbstractString, ::Type{T})::Tuple{T, String} wh
if !isa(object, T)
throw(
JuliaHubError(
"Invalid JSON returned by the server (expected `$T`, got `$(typeof(object))`):\n$(s)",
"Invalid JSON returned by the server (expected `$T`, got `$(typeof(object))`):\n$(s)"
),
)
end
Expand Down Expand Up @@ -368,7 +368,7 @@ _nothing_or(f::Base.Callable, x) = isnothing(x) ? nothing : f(x)
function _throw_or_nothing(
nothrow_extra_logic_f::Union{Base.Callable, Nothing}=nothing;
msg::AbstractString,
throw::Bool
throw::Bool,
)
throw && Base.throw(InvalidRequestError(msg))
isnothing(nothrow_extra_logic_f) || nothrow_extra_logic_f(msg)
Expand Down
8 changes: 4 additions & 4 deletions test/authentication.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ end
token,
username="authfile_username",
expires=1234,
email="authfile@example.org"
email="authfile@example.org",
)
# Testing the fallback to legacy GQL endpoint
MOCK_JULIAHUB_STATE[:auth_v1_status] = 404
let a = JuliaHub._authentication(
server;
token,
username="authfile_username",
email="authfile@example.org"
email="authfile@example.org",
)
@test a isa JuliaHub.Authentication
@test a.server == server
Expand All @@ -105,7 +105,7 @@ end
token,
username="authfile_username",
expires=1234,
email="authfile@example.org"
email="authfile@example.org",
)
# Missing username in /api/v1 -- succes, but with a warning
delete!(MOCK_JULIAHUB_STATE, :auth_v1_status)
Expand All @@ -114,7 +114,7 @@ end
server;
token,
username="authfile_username",
email="authfile@example.org"
email="authfile@example.org",
)
@test a isa JuliaHub.Authentication
@test a.server == server
Expand Down
4 changes: 2 additions & 2 deletions test/batchimages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ end
[
Dict(
"display_name" => "Stable", "type" => "base-cpu",
"image_key_name" => "stable-cpu"
"image_key_name" => "stable-cpu",
),
Dict(
"display_name" => "Stable", "type" => "base-gpu",
"image_key_name" => "stable-gpu"
"image_key_name" => "stable-gpu",
),
Dict(
"display_name" => "Dev", "type" => "option-cpu", "image_key_name" => "dev-cpu"
Expand Down
4 changes: 2 additions & 2 deletions test/datasets-live.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ try
JuliaHub.upload_dataset(
blobname, joinpath(TESTDATA, "hi.txt");
description="some blob", tags=["x", "y", "z"],
auth
auth,
)
datasets = list_datasets_prefix(PREFIX; auth)
@test length(datasets) == 1
Expand All @@ -89,7 +89,7 @@ try

JuliaHub.upload_dataset(
(auth.username, treename), TESTDATA;
description="some tree", tags=["a", "b", "c"]
description="some tree", tags=["a", "b", "c"],
)
datasets = list_datasets_prefix(PREFIX; auth)
tree_dataset = only(filter(d -> d.name == treename, datasets))
Expand Down
2 changes: 1 addition & 1 deletion test/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ end
@test isdir(joinpath(pwd(), "local"))
@test_logs (:warn,) JuliaHub.download_dataset(
("username", "blobtree/example"),
"local"; replace=true
"local"; replace=true,
)
@test isdir(joinpath(pwd(), "local"))
end
Expand Down
8 changes: 4 additions & 4 deletions test/jobs-live.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ end
job, _ = submit_test_job(
JuliaHub.script"@info 1+1; sleep(200)"noenv;
ncpu=2, memory=8,
auth, alias="script-simple"
auth, alias="script-simple",
)
@test job isa JuliaHub.Job
@test job.status ("Submitted", "Running")
Expand Down Expand Up @@ -315,7 +315,7 @@ end
ENV["RESULTS_FILE"] = joinpath(@__DIR__, "output.txt")
n = write(ENV["RESULTS_FILE"], "output-txt-content")
@info "Wrote $(n) bytes"
"""noenv; alias="output-file",
"""noenv; alias="output-file"
)
job = JuliaHub.wait_job(job)
@test job.status == "Completed"
Expand Down Expand Up @@ -345,7 +345,7 @@ end
write(joinpath(odir, "bar.txt"), "output-txt-content-2")
@info "Wrote: odir"
ENV["RESULTS_FILE"] = odir
"""noenv; alias="output-file-tarball",
"""noenv; alias="output-file-tarball"
)
job = JuliaHub.wait_job(job)
@test job.status == "Completed"
Expand Down Expand Up @@ -386,7 +386,7 @@ end
joinpath(@__DIR__, "jobenvs", "sysimage"),
"script.jl";
sysimage=true,
); auth, alias="sysimage",
); auth, alias="sysimage"
)
job = JuliaHub.wait_job(job)
@test job.status == "Completed"
Expand Down
Loading

0 comments on commit 1a1c5a6

Please sign in to comment.