@@ -1496,8 +1496,10 @@ def add_artifact(
14961496 If `files` is provided, it only retrieves information about objects with matching file names.
14971497 - If no objects are found to add to the model description, a ValueError is raised.
14981498 """
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
15011503
15021504 if self .model_file_description == None :
15031505 self .empty_json = {
@@ -1602,8 +1604,10 @@ def remove_artifact(self, uri: str):
16021604 ------
16031605 ValueError: If the model description JSON is None.
16041606 """
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
16071611
16081612 def findModelIdx ():
16091613 for idx , model in enumerate (self .model_file_description ["models" ]):
@@ -1623,27 +1627,4 @@ def findModelIdx():
16231627 return
16241628 else :
16251629 # 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