Skip to content

Commit 5a1e635

Browse files
authored
feat: receive and use tags in image options (#94)
1 parent 09fdfd7 commit 5a1e635

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## [Unreleased]
6+
7+
### Added
8+
9+
* Support for displaying and submitting batch image options with tags when working with JuliaHub instances v6.10 and above. ([#94])
10+
511
## Version [v0.1.13] - 2025-04-28
612

713
### Fixed

src/batchimages.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Base.@kwdef struct BatchImage
1717
image::String
1818
_cpu_image_key::Union{String, Nothing}
1919
_gpu_image_key::Union{String, Nothing}
20+
_image_tag::Union{String, Nothing}
21+
_image_sha::Union{String, Nothing}
2022
_is_product_default::Bool
2123
_interactive_product_name::Union{String, Nothing}
2224
end
@@ -34,6 +36,8 @@ function Base.show(io::IO, ::MIME"text/plain", image::BatchImage)
3436
print(io, '\n', " image: ", image.image)
3537
isnothing(image._cpu_image_key) || print(io, "\n CPU image: ", image._cpu_image_key)
3638
isnothing(image._gpu_image_key) || print(io, "\n GPU image: ", image._gpu_image_key)
39+
isnothing(image._image_tag) || print(io, ":$(image._image_tag)")
40+
isnothing(image._image_sha) || print(io, ":$(image._image_sha)")
3741
if !isnothing(image._interactive_product_name)
3842
print(io, "\n Features:")
3943
print(io, "\n - Expose Port: ✓")
@@ -186,7 +190,7 @@ function _batchimages_legacy(auth::Authentication)
186190
end
187191

188192
function _api_product_image_groups(auth::Authentication)
189-
r = _restcall(auth, :GET, "juliaruncloud", "product_image_groups")
193+
r = _restcall(auth, :GET, "juliaruncloud", "product_image_groups"; query=[("extended", "true")])
190194
r.status == 200 || _throw_invalidresponse(r)
191195
return _parse_response_json(r, Dict)
192196
end
@@ -214,6 +218,8 @@ Base.@kwdef mutable struct _ImageKeys
214218
isdefault::Bool = false
215219
cpu::Union{String, Nothing} = nothing
216220
gpu::Union{String, Nothing} = nothing
221+
tag::Union{String, Nothing} = nothing
222+
sha::Union{String, Nothing} = nothing
217223
end
218224

219225
function _group_images(images; image_group::AbstractString)
@@ -231,9 +237,13 @@ function _group_images(images; image_group::AbstractString)
231237
end
232238
image_key_name = _get_json(image, "image_key_name", String)
233239
display_name = _get_json(image, "display_name", String)
240+
tag = _get_json_or(image, "image_tag", Union{String, Nothing})
241+
sha = _get_json_or(image, "image_sha", Union{String, Nothing})
234242
image_type = _parse_image_group_entry_type(image)
235243
isnothing(image_type) && continue # invalid image type will return a nothing, which we will ignore
236-
imagekeys = get!(grouped_images, display_name, _ImageKeys(; isdefault=image_type.isdefault))
244+
imagekeys = get!(
245+
grouped_images, display_name, _ImageKeys(; isdefault=image_type.isdefault, tag, sha)
246+
)
237247
# If this image key set is already problematic, no point in checking further
238248
imagekeys.error && continue
239249
# We make sure that there are no conflicts with base- and option- image types
@@ -333,6 +343,8 @@ function _batchimages_62(auth::Authentication)
333343
_gpu_image_key = imagekey.gpu,
334344
_is_product_default = imagekey.isdefault,
335345
_interactive_product_name = interactive_product_name,
346+
_image_tag = imagekey.tag,
347+
_image_sha = imagekey.sha,
336348
)
337349
end
338350
end

src/jobsubmission.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct _JobSubmission1
2222
# Job image configuration
2323
product_name::Union{String, Nothing}
2424
image::Union{String, Nothing}
25+
image_tag::Union{String, Nothing}
2526
image_sha256::Union{String, Nothing}
2627
sysimage_build::Union{String, Nothing}
2728
sysimage_manifest_sha::Union{String, Nothing}
@@ -56,6 +57,7 @@ struct _JobSubmission1
5657
# Job image configuration
5758
product_name::Union{AbstractString, Nothing}=nothing,
5859
image::Union{AbstractString, Nothing}=nothing,
60+
image_tag::Union{AbstractString, Nothing}=nothing,
5961
image_sha256::Union{AbstractString, Nothing}=nothing,
6062
sysimage_build::Union{Bool, Nothing}=nothing,
6163
sysimage_manifest_sha::Union{AbstractString, Nothing}=nothing,
@@ -138,7 +140,8 @@ struct _JobSubmission1
138140
appbundle, appbundle_upload_info,
139141
registry_name, package_name, branch_name, git_revision,
140142
# Job image configuration
141-
product_name, image, image_sha256, string(sysimage_build), sysimage_manifest_sha,
143+
product_name, image, image_tag, image_sha256,
144+
string(sysimage_build), sysimage_manifest_sha,
142145
# Compute configuration
143146
node_class, string(cpu),
144147
string(nworkers), _string_or_nothing(elastic), _string_or_nothing(min_workers_required),
@@ -1311,7 +1314,12 @@ function _job_submit_args(
13111314
end
13121315
batch.image._cpu_image_key
13131316
end
1314-
(; product_name=batch.image.product, image)
1317+
(;
1318+
product_name=batch.image.product,
1319+
image,
1320+
image_tag=batch.image._image_tag,
1321+
image_sha256=batch.image._image_sha,
1322+
)
13151323
else
13161324
(;)
13171325
end

test/mocking.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ function _restcall_mocked(method, url, headers, payload; query)
468468
else
469469
serve_kafka(logengine, method, Dict(query))
470470
end
471-
elseif (method == :GET) && endswith(url, "/juliaruncloud/product_image_groups")
471+
elseif (method == :GET) && occursin("/juliaruncloud/product_image_groups", url)
472472
Dict(
473473
"image_groups" => Dict(
474474
"base_and_opt" => [

0 commit comments

Comments
 (0)