Skip to content

Commit c2093e5

Browse files
Add tests
1 parent fb19669 commit c2093e5

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

tests/unitary/with_extras/aqua/test_model.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*--
3-
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
44
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
55

66
import os
@@ -653,12 +653,12 @@ def test_get_model_fine_tuned(
653653
}
654654

655655
@pytest.mark.parametrize(
656-
("artifact_location_set", "download_from_hf"),
656+
("artifact_location_set", "download_from_hf", "delete_from_local"),
657657
[
658-
(True, True),
659-
(True, False),
660-
(False, True),
661-
(False, False),
658+
(True, True, True),
659+
(True, False, True),
660+
(False, True, False),
661+
(False, False, True),
662662
],
663663
)
664664
@patch("ads.model.service.oci_datascience_model.OCIDataScienceModel.create")
@@ -683,6 +683,7 @@ def test_import_verified_model(
683683
mock_ocidsc_create,
684684
artifact_location_set,
685685
download_from_hf,
686+
delete_from_local,
686687
mock_get_hf_model_info,
687688
mock_init_client,
688689
):
@@ -747,6 +748,7 @@ def test_import_verified_model(
747748
os_path=os_path,
748749
local_dir=str(tmpdir),
749750
download_from_hf=True,
751+
delete_from_local=delete_from_local,
750752
allow_patterns=["*.json"],
751753
ignore_patterns=["test.json"],
752754
)
@@ -761,6 +763,20 @@ def test_import_verified_model(
761763
f"oci os object bulk-upload --src-dir {str(tmpdir)}/{model_name} --prefix prefix/path/{model_name}/ -bn aqua-bkt -ns aqua-ns --auth api_key --profile DEFAULT --no-overwrite --exclude {HF_METADATA_FOLDER}*"
762764
)
763765
)
766+
if delete_from_local:
767+
cache_dir = os.path.join(
768+
os.path.expanduser("~"),
769+
".cache",
770+
"huggingface",
771+
"hub",
772+
"models--oracle--aqua-1t-mega-model",
773+
)
774+
assert (
775+
os.path.exists(f"{str(tmpdir)}/{os.path.dirname(model_name)}")
776+
is False
777+
)
778+
assert os.path.exists(cache_dir) is False
779+
764780
else:
765781
model: AquaModel = app.register(
766782
model="ocid1.datasciencemodel.xxx.xxxx.",
@@ -1183,22 +1199,22 @@ def test_import_model_with_input_tags(
11831199
"model": "oracle/oracle-1it",
11841200
"inference_container": "odsc-vllm-serving",
11851201
},
1186-
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --inference_container odsc-vllm-serving",
1202+
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --delete_from_local True --inference_container odsc-vllm-serving",
11871203
),
11881204
(
11891205
{
11901206
"os_path": "oci://aqua-bkt@aqua-ns/path",
11911207
"model": "ocid1.datasciencemodel.oc1.iad.<OCID>",
11921208
},
1193-
"ads aqua model register --model ocid1.datasciencemodel.oc1.iad.<OCID> --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True",
1209+
"ads aqua model register --model ocid1.datasciencemodel.oc1.iad.<OCID> --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --delete_from_local True",
11941210
),
11951211
(
11961212
{
11971213
"os_path": "oci://aqua-bkt@aqua-ns/path",
11981214
"model": "oracle/oracle-1it",
11991215
"download_from_hf": False,
12001216
},
1201-
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf False",
1217+
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf False --delete_from_local True",
12021218
),
12031219
(
12041220
{
@@ -1207,7 +1223,7 @@ def test_import_model_with_input_tags(
12071223
"download_from_hf": True,
12081224
"model_file": "test_model_file",
12091225
},
1210-
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --model_file test_model_file",
1226+
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --delete_from_local True --model_file test_model_file",
12111227
),
12121228
(
12131229
{
@@ -1216,7 +1232,7 @@ def test_import_model_with_input_tags(
12161232
"inference_container": "odsc-tei-serving",
12171233
"inference_container_uri": "<region>.ocir.io/<your_tenancy>/<your_image>",
12181234
},
1219-
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --inference_container odsc-tei-serving --inference_container_uri <region>.ocir.io/<your_tenancy>/<your_image>",
1235+
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path --download_from_hf True --delete_from_local True --inference_container odsc-tei-serving --inference_container_uri <region>.ocir.io/<your_tenancy>/<your_image>",
12201236
),
12211237
(
12221238
{
@@ -1227,7 +1243,7 @@ def test_import_model_with_input_tags(
12271243
"defined_tags": {"dtag1": "dvalue1", "dtag2": "dvalue2"},
12281244
},
12291245
"ads aqua model register --model oracle/oracle-1it --os_path oci://aqua-bkt@aqua-ns/path "
1230-
"--download_from_hf True --inference_container odsc-vllm-serving --freeform_tags "
1246+
"--download_from_hf True --delete_from_local True --inference_container odsc-vllm-serving --freeform_tags "
12311247
'{"ftag1": "fvalue1", "ftag2": "fvalue2"} --defined_tags {"dtag1": "dvalue1", "dtag2": "dvalue2"}',
12321248
),
12331249
],

0 commit comments

Comments
 (0)