1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*--
3
- # Copyright (c) 2024 Oracle and/or its affiliates.
3
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
4
4
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
5
6
6
import os
@@ -653,12 +653,12 @@ def test_get_model_fine_tuned(
653
653
}
654
654
655
655
@pytest .mark .parametrize (
656
- ("artifact_location_set" , "download_from_hf" ),
656
+ ("artifact_location_set" , "download_from_hf" , "delete_from_local" ),
657
657
[
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 ),
662
662
],
663
663
)
664
664
@patch ("ads.model.service.oci_datascience_model.OCIDataScienceModel.create" )
@@ -683,6 +683,7 @@ def test_import_verified_model(
683
683
mock_ocidsc_create ,
684
684
artifact_location_set ,
685
685
download_from_hf ,
686
+ delete_from_local ,
686
687
mock_get_hf_model_info ,
687
688
mock_init_client ,
688
689
):
@@ -747,6 +748,7 @@ def test_import_verified_model(
747
748
os_path = os_path ,
748
749
local_dir = str (tmpdir ),
749
750
download_from_hf = True ,
751
+ delete_from_local = delete_from_local ,
750
752
allow_patterns = ["*.json" ],
751
753
ignore_patterns = ["test.json" ],
752
754
)
@@ -761,6 +763,20 @@ def test_import_verified_model(
761
763
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 } *"
762
764
)
763
765
)
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
+
764
780
else :
765
781
model : AquaModel = app .register (
766
782
model = "ocid1.datasciencemodel.xxx.xxxx." ,
@@ -1183,22 +1199,22 @@ def test_import_model_with_input_tags(
1183
1199
"model" : "oracle/oracle-1it" ,
1184
1200
"inference_container" : "odsc-vllm-serving" ,
1185
1201
},
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" ,
1187
1203
),
1188
1204
(
1189
1205
{
1190
1206
"os_path" : "oci://aqua-bkt@aqua-ns/path" ,
1191
1207
"model" : "ocid1.datasciencemodel.oc1.iad.<OCID>" ,
1192
1208
},
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 " ,
1194
1210
),
1195
1211
(
1196
1212
{
1197
1213
"os_path" : "oci://aqua-bkt@aqua-ns/path" ,
1198
1214
"model" : "oracle/oracle-1it" ,
1199
1215
"download_from_hf" : False ,
1200
1216
},
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 " ,
1202
1218
),
1203
1219
(
1204
1220
{
@@ -1207,7 +1223,7 @@ def test_import_model_with_input_tags(
1207
1223
"download_from_hf" : True ,
1208
1224
"model_file" : "test_model_file" ,
1209
1225
},
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" ,
1211
1227
),
1212
1228
(
1213
1229
{
@@ -1216,7 +1232,7 @@ def test_import_model_with_input_tags(
1216
1232
"inference_container" : "odsc-tei-serving" ,
1217
1233
"inference_container_uri" : "<region>.ocir.io/<your_tenancy>/<your_image>" ,
1218
1234
},
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>" ,
1220
1236
),
1221
1237
(
1222
1238
{
@@ -1227,7 +1243,7 @@ def test_import_model_with_input_tags(
1227
1243
"defined_tags" : {"dtag1" : "dvalue1" , "dtag2" : "dvalue2" },
1228
1244
},
1229
1245
"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 "
1231
1247
'{"ftag1": "fvalue1", "ftag2": "fvalue2"} --defined_tags {"dtag1": "dvalue1", "dtag2": "dvalue2"}' ,
1232
1248
),
1233
1249
],
0 commit comments