Skip to content

Commit

Permalink
chore: set default dest_dir
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Dobroveanu <[email protected]>
  • Loading branch information
Crazyglue committed Feb 18, 2025
1 parent 010ccbb commit b8e68e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ jobs:
# See: https://oras.land/docs/installation/#runner-machine-of-azure-devops-and-github-actions
run: |
sudo apt-get -y install skopeo
poetry install olot
- name: Nox test
working-directory: clients/python
run: |
Expand Down
3 changes: 2 additions & 1 deletion clients/python/src/model_registry/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import os
import tempfile
from pathlib import Path
from typing import Callable, TypedDict

Expand Down Expand Up @@ -142,9 +143,9 @@ def _get_oras_backend() -> BackendDefinition:

def save_to_oci_registry(
base_image: str,
dest_dir: str | os.PathLike,
oci_ref: str,
model_files: list[os.PathLike],
dest_dir: str | os.PathLike = tempfile.mkdtemp(),
backend: str = "skopeo",
modelcard: os.PathLike | None = None,
backend_registry: BackendDict | None = DEFAULT_BACKENDS,
Expand Down
8 changes: 4 additions & 4 deletions clients/python/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_save_to_oci_registry_with_skopeo():
model_files = [readme_file_path]
backend = "skopeo"

save_to_oci_registry(base_image, dest_dir, oci_ref, model_files, backend)
save_to_oci_registry(base_image, oci_ref, model_files, dest_dir, backend)

def test_save_to_oci_registry_with_custom_backend():
is_available_mock = Mock()
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_save_to_oci_registry_with_custom_backend():

model_files = [readme_file_path]

save_to_oci_registry(base_image, dest_dir, oci_ref, model_files, backend, None, backend_registry)
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()
Expand All @@ -143,13 +143,13 @@ def test_save_to_oci_registry_with_custom_backend_unavailable():


with pytest.raises(ValueError) as e:
save_to_oci_registry("", "", "", "", backend, backend_registry=backend_registry)
save_to_oci_registry("", "", [], "", backend, backend_registry=backend_registry)

assert f"Backend '{backend}' is selected, but not available on the system. Ensure the dependencies for '{backend}' are installed in your environment." in str(e.value)

def test_save_to_oci_registry_backend_not_found():
backend = "non-existent"
with pytest.raises(ValueError) as e:
save_to_oci_registry("", "", "", [], backend)
save_to_oci_registry("", "", [], "", backend)

assert f"'{backend}' is not an available backend to use." in str(e.value)

0 comments on commit b8e68e6

Please sign in to comment.