@@ -1470,8 +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
- namespace : str ,
1474
- bucket : str ,
1473
+ uri : Optional [str ] = None ,
1474
+ namespace : Optional [str ] = None ,
1475
+ bucket : Optional [str ] = None ,
1475
1476
prefix : Optional [str ] = None ,
1476
1477
files : Optional [List [str ]] = None ,
1477
1478
):
@@ -1499,6 +1500,16 @@ def add_artifact(
1499
1500
- If no objects are found to add to the model description, a ValueError is raised.
1500
1501
"""
1501
1502
1503
+ if uri and (namespace or bucket ):
1504
+ raise ValueError ("Either 'uri' must be provided or both 'namespace' and 'bucket' must be provided." )
1505
+ if uri :
1506
+ object_storage_details = ObjectStorageDetails .from_path (uri )
1507
+ bucket = object_storage_details .bucket
1508
+ namespace = object_storage_details .namespace
1509
+ prefix = None if object_storage_details .filepath == "" else object_storage_details .filepath
1510
+ if ((not namespace ) or (not bucket )):
1511
+ raise ValueError ("Both 'namespace' and 'bucket' must be provided." )
1512
+
1502
1513
# Check if both prefix and files are provided
1503
1514
if prefix is not None and files is not None :
1504
1515
raise ValueError ("Both 'prefix' and 'files' cannot be provided. Please provide only one." )
@@ -1590,7 +1601,13 @@ def list_obj_versions_unpaginated():
1590
1601
)
1591
1602
self .set_spec (self .CONST_MODEL_FILE_DESCRIPTION , tmp_model_file_description )
1592
1603
1593
- def remove_artifact (self , namespace : str , bucket : str , prefix : Optional [str ] = None ):
1604
+ def remove_artifact (
1605
+ self ,
1606
+ uri : Optional [str ] = None ,
1607
+ namespace : Optional [str ] = None ,
1608
+ bucket : Optional [str ] = None ,
1609
+ prefix : Optional [str ] = None
1610
+ ):
1594
1611
"""
1595
1612
Removes information about objects in a specified bucket from the model description JSON.
1596
1613
@@ -1607,6 +1624,16 @@ def remove_artifact(self, namespace: str, bucket: str, prefix: Optional[str] = N
1607
1624
ValueError: If the model description JSON is None.
1608
1625
"""
1609
1626
1627
+ if uri and (namespace or bucket ):
1628
+ raise ValueError ("Either 'uri' must be provided or both 'namespace' and 'bucket' must be provided." )
1629
+ if uri :
1630
+ object_storage_details = ObjectStorageDetails .from_path (uri )
1631
+ bucket = object_storage_details .bucket
1632
+ namespace = object_storage_details .namespace
1633
+ prefix = None if object_storage_details .filepath == "" else object_storage_details .filepath
1634
+ if ((not namespace ) or (not bucket )):
1635
+ raise ValueError ("Both 'namespace' and 'bucket' must be provided." )
1636
+
1610
1637
def findModelIdx ():
1611
1638
for idx , model in enumerate (self .model_file_description ["models" ]):
1612
1639
if (
0 commit comments