@@ -1470,7 +1470,9 @@ def _download_file_description_artifact(self) -> Tuple[Union[str, List[str]], in
1470
1470
1471
1471
def add_artifact (
1472
1472
self ,
1473
- uri : str ,
1473
+ namespace : str ,
1474
+ bucket : str ,
1475
+ prefix : Optional [str ] = None ,
1474
1476
files : Optional [List [str ]] = None ,
1475
1477
):
1476
1478
"""
@@ -1496,11 +1498,11 @@ def add_artifact(
1496
1498
If `files` is provided, it only retrieves information about objects with matching file names.
1497
1499
- If no objects are found to add to the model description, a ValueError is raised.
1498
1500
"""
1499
- object_storage_details = ObjectStorageDetails .from_path (uri )
1500
- bucket = object_storage_details .bucket
1501
- namespace = object_storage_details .namespace
1502
- prefix = None if object_storage_details .filepath == "" else object_storage_details .filepath
1503
1501
1502
+ # Check if both prefix and files are provided
1503
+ if prefix is not None and files is not None :
1504
+ raise ValueError ("Both 'prefix' and 'files' cannot be provided. Please provide only one." )
1505
+
1504
1506
if self .model_file_description == None :
1505
1507
self .empty_json = {
1506
1508
"version" : "1.0" ,
@@ -1513,7 +1515,7 @@ def add_artifact(
1513
1515
self .object_storage_client = oc .OCIClientFactory (** (self .dsc_model .auth )).object_storage
1514
1516
1515
1517
# Remove if the model already exists
1516
- self .remove_artifact (uri = uri )
1518
+ self .remove_artifact (namespace = namespace , bucket = bucket , prefix = prefix )
1517
1519
1518
1520
def check_if_file_exists (fileName ):
1519
1521
isExists = False
@@ -1588,7 +1590,7 @@ def list_obj_versions_unpaginated():
1588
1590
)
1589
1591
self .set_spec (self .CONST_MODEL_FILE_DESCRIPTION , tmp_model_file_description )
1590
1592
1591
- def remove_artifact (self , uri : str ):
1593
+ def remove_artifact (self , namespace : str , bucket : str , prefix : Optional [ str ] = None ):
1592
1594
"""
1593
1595
Removes information about objects in a specified bucket from the model description JSON.
1594
1596
@@ -1604,10 +1606,6 @@ def remove_artifact(self, uri: str):
1604
1606
------
1605
1607
ValueError: If the model description JSON is None.
1606
1608
"""
1607
- object_storage_details = ObjectStorageDetails .from_path (uri )
1608
- bucket = object_storage_details .bucket
1609
- namespace = object_storage_details .namespace
1610
- prefix = None if object_storage_details .filepath == "" else object_storage_details .filepath
1611
1609
1612
1610
def findModelIdx ():
1613
1611
for idx , model in enumerate (self .model_file_description ["models" ]):
0 commit comments