1111import unittest
1212import pandas
1313from unittest .mock import MagicMock , patch
14+ from ads .common import utils
1415from ads .common .oci_datascience import OCIDataScienceMixin
1516from ads .common .oci_logging import ConsolidatedLog , OCILog
1617from ads .common .oci_mixin import OCIModelMixin
2223 ModelDeployment ,
2324 ModelDeploymentLogType ,
2425 ModelDeploymentFailedError ,
26+ MAX_ARTIFACT_SIZE_IN_BYTES ,
2527)
2628from ads .model .deployment .model_deployment_infrastructure import (
2729 ModelDeploymentInfrastructure ,
@@ -1388,8 +1390,10 @@ def test_model_deployment_with_subnet_id(self):
13881390 "create_model_deployment" ,
13891391 )
13901392 @patch .object (DataScienceModel , "upload_artifact" )
1393+ @patch .object (utils , "folder_size" )
13911394 def test_model_deployment_with_large_size_artifact (
13921395 self ,
1396+ mock_folder_size ,
13931397 mock_upload_artifact ,
13941398 mock_create_model_deployment ,
13951399 mock_sync
@@ -1400,7 +1404,6 @@ def test_model_deployment_with_large_size_artifact(
14001404 model_deployment = self .initialize_model_deployment ()
14011405 (
14021406 model_deployment .runtime
1403- .with_bucket_uri ("test_bucket_uri" )
14041407 .with_auth ({"test_key" :"test_value" })
14051408 .with_region ("test_region" )
14061409 .with_overwrite_existing_artifact (True )
@@ -1409,7 +1412,6 @@ def test_model_deployment_with_large_size_artifact(
14091412 )
14101413
14111414 runtime_dict = model_deployment .runtime .to_dict ()["spec" ]
1412- assert runtime_dict ["bucketUri" ] == "test_bucket_uri"
14131415 assert runtime_dict ["auth" ] == {"test_key" : "test_value" }
14141416 assert runtime_dict ["region" ] == "test_region"
14151417 assert runtime_dict ["overwriteExistingArtifact" ] == True
@@ -1421,6 +1423,14 @@ def test_model_deployment_with_large_size_artifact(
14211423 mock_create_model_deployment .return_value = response
14221424 model_deployment = self .initialize_model_deployment ()
14231425 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"
14241434 create_model_deployment_details = (
14251435 model_deployment ._build_model_deployment_details ()
14261436 )
0 commit comments