11
11
import unittest
12
12
import pandas
13
13
from unittest .mock import MagicMock , patch
14
+ from ads .common import utils
14
15
from ads .common .oci_datascience import OCIDataScienceMixin
15
16
from ads .common .oci_logging import ConsolidatedLog , OCILog
16
17
from ads .common .oci_mixin import OCIModelMixin
22
23
ModelDeployment ,
23
24
ModelDeploymentLogType ,
24
25
ModelDeploymentFailedError ,
26
+ MAX_ARTIFACT_SIZE_IN_BYTES ,
25
27
)
26
28
from ads .model .deployment .model_deployment_infrastructure import (
27
29
ModelDeploymentInfrastructure ,
@@ -1388,8 +1390,10 @@ def test_model_deployment_with_subnet_id(self):
1388
1390
"create_model_deployment" ,
1389
1391
)
1390
1392
@patch .object (DataScienceModel , "upload_artifact" )
1393
+ @patch .object (utils , "folder_size" )
1391
1394
def test_model_deployment_with_large_size_artifact (
1392
1395
self ,
1396
+ mock_folder_size ,
1393
1397
mock_upload_artifact ,
1394
1398
mock_create_model_deployment ,
1395
1399
mock_sync
@@ -1400,7 +1404,6 @@ def test_model_deployment_with_large_size_artifact(
1400
1404
model_deployment = self .initialize_model_deployment ()
1401
1405
(
1402
1406
model_deployment .runtime
1403
- .with_bucket_uri ("test_bucket_uri" )
1404
1407
.with_auth ({"test_key" :"test_value" })
1405
1408
.with_region ("test_region" )
1406
1409
.with_overwrite_existing_artifact (True )
@@ -1409,7 +1412,6 @@ def test_model_deployment_with_large_size_artifact(
1409
1412
)
1410
1413
1411
1414
runtime_dict = model_deployment .runtime .to_dict ()["spec" ]
1412
- assert runtime_dict ["bucketUri" ] == "test_bucket_uri"
1413
1415
assert runtime_dict ["auth" ] == {"test_key" : "test_value" }
1414
1416
assert runtime_dict ["region" ] == "test_region"
1415
1417
assert runtime_dict ["overwriteExistingArtifact" ] == True
@@ -1421,6 +1423,14 @@ def test_model_deployment_with_large_size_artifact(
1421
1423
mock_create_model_deployment .return_value = response
1422
1424
model_deployment = self .initialize_model_deployment ()
1423
1425
model_deployment .set_spec (model_deployment .CONST_ID , "test_model_deployment_id" )
1426
+
1427
+ mock_folder_size .return_value = MAX_ARTIFACT_SIZE_IN_BYTES + 1
1428
+ with pytest .raises (ValueError ):
1429
+ model_deployment .deploy (wait_for_completion = False )
1430
+
1431
+ model_deployment .runtime .with_bucket_uri ("test_bucket_uri" )
1432
+ runtime_dict = model_deployment .runtime .to_dict ()["spec" ]
1433
+ assert runtime_dict ["bucketUri" ] == "test_bucket_uri"
1424
1434
create_model_deployment_details = (
1425
1435
model_deployment ._build_model_deployment_details ()
1426
1436
)
0 commit comments