@@ -2954,70 +2954,54 @@ def test_from_create_model_deployment_details(self):
29542954 )
29552955
29562956
2957- @patch ("ads.aqua.app.default_signer" )
2958- class TestSingleModelParamResolution (unittest .TestCase ):
2959- """Tests strictly for the SMM parameter resolution logic in Single Model."""
2960-
2957+ class TestSingleModelParamResolution (TestAquaDeployment ):
29612958 def setUp (self ):
2962- self .app = AquaDeploymentApp ()
2963- self .app .region = "us-ashburn-1"
2959+ super ().setUp ()
29642960
2965- # Mock internal helpers to avoid real API calls
29662961 self .app .get_container_config = MagicMock ()
29672962 self .app .get_container_image = MagicMock (return_value = "docker/image:latest" )
2963+
29682964 mock_shape = MagicMock ()
29692965 mock_shape .name = "VM.GPU.A10.1"
29702966 self .app .list_shapes = MagicMock (return_value = [mock_shape ])
29712967
2972- # Mock the SMM Defaults (What happens if user sends nothing)
29732968 self .mock_config = MagicMock ()
2974- # Assume default SMM config is "--default-param 100"
29752969 self .mock_config .configuration .get .return_value .parameters .get .return_value = (
29762970 "--default-param 100"
29772971 )
29782972 self .app .get_deployment_config = MagicMock (return_value = self .mock_config )
29792973
2980- # Mock Container Defaults (The mandatory left-side params)
29812974 self .mock_container_item = MagicMock ()
29822975 self .mock_container_item .spec .cli_param = "--mandatory-param 1"
2983- # Ensure restricted params are empty by default for this mock
29842976 self .mock_container_item .spec .restricted_params = []
29852977 self .app .get_container_config_item = MagicMock (
29862978 return_value = self .mock_container_item
29872979 )
29882980
2989- @patch ("ads.aqua.modeldeployment.deployment.ModelDeployment" )
2990- @patch ("ads.aqua.modeldeployment.deployment.AquaModelApp" )
2991- def test_case_1_none_loads_defaults (self , mock_model_app , mock_deploy , mock_signer ):
2992- """Case 1: User input None -> Should load SMM defaults."""
2981+ @patch ("ads.model.deployment.model_deployment.ModelDeployment" )
2982+ @patch ("ads.aqua.model.AquaModelApp" )
2983+ def test_case_1_none_loads_defaults (self , mock_model_app , mock_deploy ):
29932984 details = CreateModelDeploymentDetails (
29942985 model_id = "ocid1.model..." ,
29952986 instance_shape = "VM.GPU.A10.1" ,
2996- # PARAMS is missing (None)
29972987 env_var = {},
29982988 )
29992989
3000- # Mock the internal call to capture arguments
30012990 with patch .object (self .app , "_create_deployment" ) as mock_create_internal :
30022991 self .app .create (create_deployment_details = details )
30032992
30042993 call_args = mock_create_internal .call_args [1 ]
30052994 final_params = call_args ["env_var" ]["PARAMS" ]
30062995
3007- # Should have Mandatory + SMM Default
30082996 self .assertIn ("--mandatory-param 1" , final_params )
30092997 self .assertIn ("--default-param 100" , final_params )
30102998
3011- @patch ("ads.aqua.modeldeployment.deployment.ModelDeployment" )
3012- @patch ("ads.aqua.modeldeployment.deployment.AquaModelApp" )
3013- def test_case_2_empty_clears_defaults (
3014- self , mock_model_app , mock_deploy , mock_signer
3015- ):
3016- """Case 2: User input Empty String -> Should clear SMM defaults."""
2999+ @patch ("ads.model.deployment.model_deployment.ModelDeployment" )
3000+ @patch ("ads.aqua.model.AquaModelApp" )
3001+ def test_case_2_empty_clears_defaults (self , mock_model_app , mock_deploy ):
30173002 details = CreateModelDeploymentDetails (
30183003 model_id = "ocid1.model..." ,
30193004 instance_shape = "VM.GPU.A10.1" ,
3020- # PARAMS is explicitly empty
30213005 env_var = {"PARAMS" : "" },
30223006 )
30233007
@@ -3027,21 +3011,15 @@ def test_case_2_empty_clears_defaults(
30273011 call_args = mock_create_internal .call_args [1 ]
30283012 final_params = call_args ["env_var" ]["PARAMS" ]
30293013
3030- # Should have Mandatory ONLY
30313014 self .assertIn ("--mandatory-param 1" , final_params )
3032- # SMM Default should be GONE
30333015 self .assertNotIn ("--default-param 100" , final_params )
30343016
3035- @patch ("ads.aqua.modeldeployment.deployment.ModelDeployment" )
3036- @patch ("ads.aqua.modeldeployment.deployment.AquaModelApp" )
3037- def test_case_3_value_overrides_defaults (
3038- self , mock_model_app , mock_deploy , mock_signer
3039- ):
3040- """Case 3: User input Value -> Should use exact value (No Merge)."""
3017+ @patch ("ads.model.deployment.model_deployment.ModelDeployment" )
3018+ @patch ("ads.aqua.model.AquaModelApp" )
3019+ def test_case_3_value_overrides_defaults (self , mock_model_app , mock_deploy ):
30413020 details = CreateModelDeploymentDetails (
30423021 model_id = "ocid1.model..." ,
30433022 instance_shape = "VM.GPU.A10.1" ,
3044- # PARAMS is a custom value
30453023 env_var = {"PARAMS" : "--user-override 99" },
30463024 )
30473025
@@ -3051,21 +3029,13 @@ def test_case_3_value_overrides_defaults(
30513029 call_args = mock_create_internal .call_args [1 ]
30523030 final_params = call_args ["env_var" ]["PARAMS" ]
30533031
3054- # Should have Mandatory + User Override
30553032 self .assertIn ("--mandatory-param 1" , final_params )
30563033 self .assertIn ("--user-override 99" , final_params )
3057- # SMM Default should be GONE
30583034 self .assertNotIn ("--default-param 100" , final_params )
30593035
3060- @patch ("ads.aqua.modeldeployment.deployment.ModelDeployment" )
3061- @patch ("ads.aqua.modeldeployment.deployment.AquaModelApp" )
3062- def test_validation_blocks_restricted_params (
3063- self , mock_model_app , mock_deploy , mock_signer
3064- ):
3065- """Test that restricted params cause error regardless of input source."""
3066-
3067- # Setup: Override the container config for THIS test only
3068- # We create a new mock to ensure we don't pollute other tests
3036+ @patch ("ads.model.deployment.model_deployment.ModelDeployment" )
3037+ @patch ("ads.aqua.model.AquaModelApp" )
3038+ def test_validation_blocks_restricted_params (self , mock_model_app , mock_deploy ):
30693039 restricted_mock_item = MagicMock ()
30703040 restricted_mock_item .spec .cli_param = "--mandatory 1"
30713041 restricted_mock_item .spec .restricted_params = ["--seed" ]
@@ -3074,7 +3044,6 @@ def test_validation_blocks_restricted_params(
30743044 return_value = restricted_mock_item
30753045 )
30763046
3077- # User tries to override restricted param
30783047 details = CreateModelDeploymentDetails (
30793048 model_id = "ocid1.model..." ,
30803049 instance_shape = "VM.GPU.A10.1" ,
@@ -3088,14 +3057,10 @@ def test_validation_blocks_restricted_params(
30883057
30893058
30903059class TestMultiModelParamResolution (unittest .TestCase ):
3091- """Tests strictly for the SMM parameter resolution logic in Multi-Model."""
3092-
30933060 def setUp (self ):
3094- # Mock Config Summary structure
30953061 self .mock_config_summary = MagicMock ()
30963062 self .mock_deploy_config = MagicMock ()
30973063
3098- # Set SMM Default
30993064 self .mock_deploy_config .configuration .get .return_value .parameters .get .return_value = (
31003065 "--smm-default 500"
31013066 )
@@ -3106,14 +3071,10 @@ def setUp(self):
31063071 self .mock_details = MagicMock ()
31073072 self .mock_details .instance_shape = "VM.GPU.A10.2"
31083073
3109- # Set Container Mandatory Params
31103074 self .container_params = "--mandatory 1"
31113075
31123076 def test_case_1_none_loads_defaults (self ):
3113- """Case 1: params=None -> Load Defaults"""
3114- model = AquaMultiModelRef (
3115- model_id = "ocid1..." , gpu_count = 1 , params = None # User sent nothing
3116- )
3077+ model = AquaMultiModelRef (model_id = "ocid1..." , gpu_count = 1 , params = None )
31173078
31183079 result = ModelGroupConfig ._merge_gpu_count_params (
31193080 model ,
@@ -3127,10 +3088,7 @@ def test_case_1_none_loads_defaults(self):
31273088 self .assertIn ("--smm-default 500" , result )
31283089
31293090 def test_case_2_empty_clears_defaults (self ):
3130- """Case 2: params={} -> Clear Defaults"""
3131- model = AquaMultiModelRef (
3132- model_id = "ocid1..." , gpu_count = 1 , params = {} # User sent Empty Dict
3133- )
3091+ model = AquaMultiModelRef (model_id = "ocid1..." , gpu_count = 1 , params = {})
31343092
31353093 result = ModelGroupConfig ._merge_gpu_count_params (
31363094 model ,
@@ -3141,15 +3099,13 @@ def test_case_2_empty_clears_defaults(self):
31413099 )
31423100
31433101 self .assertIn ("--mandatory 1" , result )
3144- # SMM Default should be missing
31453102 self .assertNotIn ("--smm-default 500" , result )
31463103
31473104 def test_case_3_value_overrides_defaults (self ):
3148- """Case 3: params={val} -> Override Defaults"""
31493105 model = AquaMultiModelRef (
31503106 model_id = "ocid1..." ,
31513107 gpu_count = 1 ,
3152- params = {"--custom" : "99" }, # User sent Value
3108+ params = {"--custom" : "99" },
31533109 )
31543110
31553111 result = ModelGroupConfig ._merge_gpu_count_params (
@@ -3162,5 +3118,4 @@ def test_case_3_value_overrides_defaults(self):
31623118
31633119 self .assertIn ("--mandatory 1" , result )
31643120 self .assertIn ("--custom 99" , result )
3165- # SMM Default should be missing
31663121 self .assertNotIn ("--smm-default 500" , result )
0 commit comments