@@ -1496,8 +1496,10 @@ def add_artifact(
1496
1496
If `files` is provided, it only retrieves information about objects with matching file names.
1497
1497
- If no objects are found to add to the model description, a ValueError is raised.
1498
1498
"""
1499
-
1500
- bucket , namespace , prefix = self ._extract_oci_uri_components (uri )
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
1501
1503
1502
1504
if self .model_file_description == None :
1503
1505
self .empty_json = {
@@ -1602,8 +1604,10 @@ def remove_artifact(self, uri: str):
1602
1604
------
1603
1605
ValueError: If the model description JSON is None.
1604
1606
"""
1605
-
1606
- bucket , namespace , prefix = self ._extract_oci_uri_components (uri )
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
1607
1611
1608
1612
def findModelIdx ():
1609
1613
for idx , model in enumerate (self .model_file_description ["models" ]):
@@ -1623,27 +1627,4 @@ def findModelIdx():
1623
1627
return
1624
1628
else :
1625
1629
# model found case
1626
- self .model_file_description ["models" ].pop (modelSearchIdx )
1627
-
1628
- def _extract_oci_uri_components (self , uri : str ):
1629
- if not uri .startswith ("oci://" ):
1630
- raise ValueError ("Invalid URI format" )
1631
-
1632
- # Remove the "oci://" prefix
1633
- uri = uri [len ("oci://" ):]
1634
-
1635
- # Split by "@" to get bucket_name and the rest
1636
- bucket_and_rest = uri .split ("@" , 1 )
1637
- if len (bucket_and_rest ) != 2 :
1638
- raise ValueError ("Invalid URI format" )
1639
-
1640
- bucket_name = bucket_and_rest [0 ]
1641
-
1642
- # Split the rest by "/" to get namespace and prefix
1643
- namespace_and_prefix = bucket_and_rest [1 ].split ("/" , 1 )
1644
- if len (namespace_and_prefix ) == 1 :
1645
- namespace , prefix = namespace_and_prefix [0 ], ""
1646
- else :
1647
- namespace , prefix = namespace_and_prefix
1648
-
1649
- return bucket_name , namespace , None if prefix == '' else prefix
1630
+ self .model_file_description ["models" ].pop (modelSearchIdx )
0 commit comments