@@ -1467,7 +1467,7 @@ def _download_file_description_artifact(self) -> Tuple[Union[str, List[str]], in
1467
1467
bucket_uri .append (uri )
1468
1468
1469
1469
return bucket_uri [0 ] if len (bucket_uri ) == 1 else bucket_uri , artifact_size
1470
-
1470
+
1471
1471
def add_artifact (
1472
1472
self ,
1473
1473
uri : Optional [str ] = None ,
@@ -1512,29 +1512,39 @@ def add_artifact(
1512
1512
"""
1513
1513
1514
1514
if uri and (namespace or bucket ):
1515
- raise ValueError ("Either 'uri' must be provided or both 'namespace' and 'bucket' must be provided." )
1515
+ raise ValueError (
1516
+ "Either 'uri' must be provided or both 'namespace' and 'bucket' must be provided."
1517
+ )
1516
1518
if uri :
1517
1519
object_storage_details = ObjectStorageDetails .from_path (uri )
1518
1520
bucket = object_storage_details .bucket
1519
1521
namespace = object_storage_details .namespace
1520
- prefix = None if object_storage_details .filepath == "" else object_storage_details .filepath
1521
- if ((not namespace ) or (not bucket )):
1522
+ prefix = (
1523
+ None
1524
+ if object_storage_details .filepath == ""
1525
+ else object_storage_details .filepath
1526
+ )
1527
+ if (not namespace ) or (not bucket ):
1522
1528
raise ValueError ("Both 'namespace' and 'bucket' must be provided." )
1523
1529
1524
1530
# Check if both prefix and files are provided
1525
1531
if prefix is not None and files is not None :
1526
- raise ValueError ("Both 'prefix' and 'files' cannot be provided. Please provide only one." )
1527
-
1532
+ raise ValueError (
1533
+ "Both 'prefix' and 'files' cannot be provided. Please provide only one."
1534
+ )
1535
+
1528
1536
if self .model_file_description == None :
1529
1537
self .empty_json = {
1530
1538
"version" : "1.0" ,
1531
1539
"type" : "modelOSSReferenceDescription" ,
1532
1540
"models" : [],
1533
1541
}
1534
1542
self .set_spec (self .CONST_MODEL_FILE_DESCRIPTION , self .empty_json )
1535
-
1543
+
1536
1544
# Get object storage client
1537
- self .object_storage_client = oc .OCIClientFactory (** (self .dsc_model .auth )).object_storage
1545
+ self .object_storage_client = oc .OCIClientFactory (
1546
+ ** (self .dsc_model .auth )
1547
+ ).object_storage
1538
1548
1539
1549
# Remove if the model already exists
1540
1550
self .remove_artifact (namespace = namespace , bucket = bucket , prefix = prefix )
@@ -1611,14 +1621,14 @@ def list_obj_versions_unpaginated():
1611
1621
}
1612
1622
)
1613
1623
self .set_spec (self .CONST_MODEL_FILE_DESCRIPTION , tmp_model_file_description )
1614
-
1624
+
1615
1625
def remove_artifact (
1616
- self ,
1617
- uri : Optional [str ] = None ,
1618
- namespace : Optional [str ] = None ,
1619
- bucket : Optional [str ] = None ,
1620
- prefix : Optional [str ] = None
1621
- ):
1626
+ self ,
1627
+ uri : Optional [str ] = None ,
1628
+ namespace : Optional [str ] = None ,
1629
+ bucket : Optional [str ] = None ,
1630
+ prefix : Optional [str ] = None ,
1631
+ ):
1622
1632
"""
1623
1633
Removes information about objects in a specified bucket or using a specified URI from the model description JSON.
1624
1634
@@ -1644,15 +1654,21 @@ def remove_artifact(
1644
1654
- If neither 'uri' nor both 'namespace' and 'bucket' are provided.
1645
1655
- If the model description JSON is None.
1646
1656
"""
1647
-
1657
+
1648
1658
if uri and (namespace or bucket ):
1649
- raise ValueError ("Either 'uri' must be provided or both 'namespace' and 'bucket' must be provided." )
1659
+ raise ValueError (
1660
+ "Either 'uri' must be provided or both 'namespace' and 'bucket' must be provided."
1661
+ )
1650
1662
if uri :
1651
1663
object_storage_details = ObjectStorageDetails .from_path (uri )
1652
1664
bucket = object_storage_details .bucket
1653
1665
namespace = object_storage_details .namespace
1654
- prefix = None if object_storage_details .filepath == "" else object_storage_details .filepath
1655
- if ((not namespace ) or (not bucket )):
1666
+ prefix = (
1667
+ None
1668
+ if object_storage_details .filepath == ""
1669
+ else object_storage_details .filepath
1670
+ )
1671
+ if (not namespace ) or (not bucket ):
1656
1672
raise ValueError ("Both 'namespace' and 'bucket' must be provided." )
1657
1673
1658
1674
def findModelIdx ():
@@ -1667,10 +1683,10 @@ def findModelIdx():
1667
1683
1668
1684
if self .model_file_description == None :
1669
1685
return
1670
-
1686
+
1671
1687
modelSearchIdx = findModelIdx ()
1672
1688
if modelSearchIdx == - 1 :
1673
1689
return
1674
1690
else :
1675
1691
# model found case
1676
- self .model_file_description ["models" ].pop (modelSearchIdx )
1692
+ self .model_file_description ["models" ].pop (modelSearchIdx )
0 commit comments