Skip to content

Commit

Permalink
chore: ensure uri is returned from function
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Dobroveanu <[email protected]>
  • Loading branch information
Crazyglue committed Feb 20, 2025
1 parent c736e7e commit 0fcdde7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions clients/python/src/model_registry/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ def save_to_oci_registry(
backend: str = "skopeo",
modelcard: os.PathLike | None = None,
backend_registry: BackendDict | None = DEFAULT_BACKENDS,
) -> None:
) -> str:
"""Appends a list of files to an OCI-based image.
Args:
base_image: The image to append model files to. This image will be downloaded to the location at `dest_dir`
dest_dir: The location to save the downloaded and extracted base image to.
oci_ref: Destination of where to push the newly layered image to
oci_ref: Destination of where to push the newly layered image to. eg, "quay.io/my-org/my-registry:1.0.0"
model_files: List of files to add to the base_image as layers
backend: The CLI tool to use to perform the oci image pull/push. One of: "skopeo", "oras"
modelcard: Optional, path to the modelcard to additionally include as a layer
Expand Down Expand Up @@ -202,3 +202,7 @@ def save_to_oci_registry(
backend_def["pull"](base_image, local_image_path)
oci_layers_on_top(local_image_path, model_files, modelcard)
backend_def["push"](local_image_path, oci_ref)

# Return the OCI URI

return f"oci://{oci_ref}"
3 changes: 2 additions & 1 deletion clients/python/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ def pull_mock_imple(base_image, dest_dir):

model_files = [readme_file_path]

save_to_oci_registry(base_image, oci_ref, model_files, dest_dir, backend, None, backend_registry)
uri = save_to_oci_registry(base_image, oci_ref, model_files, dest_dir, backend, None, backend_registry)
# Ensure our mocked backend was called
is_available_mock.assert_called_once()
pull_mock.assert_called_once()
push_mock.assert_called_once()
assert uri == f"oci://{oci_ref}"

def test_save_to_oci_registry_with_custom_backend_unavailable():
is_available_mock = Mock()
Expand Down

0 comments on commit 0fcdde7

Please sign in to comment.