@@ -1592,17 +1592,32 @@ def test_create_deployment_for_foundation_model(
15921592 model_deployment_obj .dsc_model_deployment .workflow_req_id = "workflow_req_id"
15931593 mock_deploy .return_value = model_deployment_obj
15941594
1595- result = self .app .create (
1596- model_id = TestDataset .MODEL_ID ,
1597- instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAME ,
1598- display_name = "model-deployment-name" ,
1599- log_group_id = "ocid1.loggroup.oc1.<region>.<OCID>" ,
1600- access_log_id = "ocid1.log.oc1.<region>.<OCID>" ,
1601- predict_log_id = "ocid1.log.oc1.<region>.<OCID>" ,
1602- freeform_tags = freeform_tags ,
1603- defined_tags = defined_tags ,
1604- )
1595+ # TEST CASE 1: None (no PARAMS) - should load defaults from config
1596+ with patch .object (
1597+ self .app , "_create_deployment" , wraps = self .app ._create_deployment
1598+ ) as mock_spy :
1599+ result = self .app .create (
1600+ model_id = TestDataset .MODEL_ID ,
1601+ instance_shape = "VM.GPU.A10.4" ,
1602+ display_name = "no-params-deployment" ,
1603+ log_group_id = "ocid1.loggroup.oc1.<region>.<OCID>" ,
1604+ access_log_id = "ocid1.log.oc1.<region>.<OCID>" ,
1605+ predict_log_id = "ocid1.log.oc1.<region>.<OCID>" ,
1606+ freeform_tags = freeform_tags ,
1607+ defined_tags = defined_tags ,
1608+ )
16051609
1610+ call_kwargs = mock_spy .call_args .kwargs
1611+ captured_env = call_kwargs ["env_var" ]
1612+ assert "PARAMS" in captured_env
1613+ # SMM defaults from tests/unitary/with_extras/aqua/test_data/deployment/deployment_config.json
1614+ assert "--max-model-len 4096" in captured_env ["PARAMS" ]
1615+ # Container params should also be present
1616+ assert "--served-model-name odsc-llm" in captured_env ["PARAMS" ]
1617+ assert "--disable-custom-all-reduce" in captured_env ["PARAMS" ]
1618+ assert "--seed 42" in captured_env ["PARAMS" ]
1619+
1620+ # Verify original test assertions
16061621 mock_validate_base_model .assert_called ()
16071622 mock_create .assert_called_with (
16081623 model = mock_validate_base_model .return_value ,
@@ -1617,11 +1632,51 @@ def test_create_deployment_for_foundation_model(
16171632 expected_attributes = set (AquaDeployment .__annotations__ .keys ())
16181633 actual_attributes = result .to_dict ()
16191634 assert set (actual_attributes ) == set (expected_attributes ), "Attributes mismatch"
1620- expected_result = copy .deepcopy (TestDataset .aqua_deployment_object )
1621- expected_result ["state" ] = "CREATING"
1622- expected_result ["tags" ].update (freeform_tags )
1623- expected_result ["tags" ].update (defined_tags )
1624- assert actual_attributes == expected_result
1635+
1636+ # TEST CASE 2: Empty String - should clear SMM defaults
1637+ with patch .object (
1638+ self .app , "_create_deployment" , wraps = self .app ._create_deployment
1639+ ) as mock_spy :
1640+ self .app .create (
1641+ model_id = TestDataset .MODEL_ID ,
1642+ instance_shape = "VM.GPU.A10.4" ,
1643+ display_name = "empty-params-deployment" ,
1644+ env_var = {"PARAMS" : "" },
1645+ )
1646+
1647+ call_kwargs = mock_spy .call_args .kwargs
1648+ captured_env = call_kwargs ["env_var" ]
1649+ # SMM defaults should NOT be present
1650+ assert "--max-model-len 4096" not in captured_env ["PARAMS" ]
1651+ assert "--tensor-parallel-size 2" not in captured_env ["PARAMS" ]
1652+ # Container params should still be present
1653+ assert "--served-model-name odsc-llm" in captured_env ["PARAMS" ]
1654+ assert "--disable-custom-all-reduce" in captured_env ["PARAMS" ]
1655+ assert "--seed 42" in captured_env ["PARAMS" ]
1656+
1657+ # TEST CASE 3: User value - should use exact user value, no SMM defaults
1658+ with patch .object (
1659+ self .app , "_create_deployment" , wraps = self .app ._create_deployment
1660+ ) as mock_spy :
1661+ self .app .create (
1662+ model_id = TestDataset .MODEL_ID ,
1663+ instance_shape = "VM.GPU.A10.4" ,
1664+ display_name = "custom-params-deployment" ,
1665+ env_var = {"PARAMS" : "--my-custom-param 123" },
1666+ )
1667+
1668+ call_kwargs = mock_spy .call_args .kwargs
1669+ captured_env = call_kwargs ["env_var" ]
1670+ assert "PARAMS" in captured_env
1671+ # User value should be present
1672+ assert "--my-custom-param 123" in captured_env ["PARAMS" ]
1673+ # SMM defaults should NOT be present
1674+ assert "--max-model-len 4096" not in captured_env ["PARAMS" ]
1675+ assert "--tensor-parallel-size 2" not in captured_env ["PARAMS" ]
1676+ # All container params should be present
1677+ assert "--served-model-name odsc-llm" in captured_env ["PARAMS" ]
1678+ assert "--disable-custom-all-reduce" in captured_env ["PARAMS" ]
1679+ assert "--seed 42" in captured_env ["PARAMS" ]
16251680
16261681 @patch .object (AquaApp , "get_container_config_item" )
16271682 @patch ("ads.aqua.model.AquaModelApp.create" )
@@ -2952,3 +3007,95 @@ def test_from_create_model_deployment_details(self):
29523007 model_group_config_no_ft .model_dump ()
29533008 == TestDataset .multi_model_deployment_group_config_no_ft
29543009 )
3010+
3011+ # Case 1: params=None - should load defaults from config
3012+ model_with_none_params = AquaMultiModelRef (
3013+ model_id = "model_a" ,
3014+ model_name = "test_model_1" ,
3015+ model_task = "text_embedding" ,
3016+ gpu_count = 2 ,
3017+ artifact_location = "oci://test_location_1" ,
3018+ params = None ,
3019+ )
3020+
3021+ create_details_none = CreateModelDeploymentDetails (
3022+ models = [model_with_none_params ],
3023+ instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAME , # BM.GPU.A10.4
3024+ display_name = "test-deployment" ,
3025+ )
3026+
3027+ config_none = ModelGroupConfig .from_model_deployment_details (
3028+ deployment_details = create_details_none ,
3029+ model_config_summary = model_config_summary ,
3030+ container_type_key = "odsc-vllm-serving" ,
3031+ container_params = "--container-param test" ,
3032+ )
3033+
3034+ model_params_none = config_none .models [0 ].params
3035+ # SMM defaults from config should be present (gpu_count=2 on BM.GPU.A10.4)
3036+ assert "--trust-remote-code" in model_params_none
3037+ assert "--max-model-len 32000" in model_params_none
3038+ # Container params should also be present
3039+ assert "--container-param test" in model_params_none
3040+
3041+ # Case 2: params={} (empty dict) - should clear SMM defaults
3042+ model_with_empty_params = AquaMultiModelRef (
3043+ model_id = "model_a" ,
3044+ model_name = "test_model_1" ,
3045+ model_task = "text_embedding" ,
3046+ gpu_count = 2 ,
3047+ artifact_location = "oci://test_location_1" ,
3048+ params = {},
3049+ )
3050+
3051+ create_details_empty = CreateModelDeploymentDetails (
3052+ models = [model_with_empty_params ],
3053+ instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAME ,
3054+ display_name = "test-deployment" ,
3055+ )
3056+
3057+ config_empty = ModelGroupConfig .from_model_deployment_details (
3058+ deployment_details = create_details_empty ,
3059+ model_config_summary = model_config_summary ,
3060+ container_type_key = "odsc-vllm-serving" ,
3061+ container_params = "--container-param test" ,
3062+ )
3063+
3064+ model_params_empty = config_empty .models [0 ].params
3065+ # SMM defaults should NOT be present
3066+ assert "--trust-remote-code" not in model_params_empty
3067+ assert "--max-model-len 32000" not in model_params_empty
3068+ # Container params should still be present
3069+ assert "--container-param test" in model_params_empty
3070+
3071+ # Case 3: params={'--custom-param': '99'} - should use user value, no SMM defaults
3072+ model_with_custom_params = AquaMultiModelRef (
3073+ model_id = "model_a" ,
3074+ model_name = "test_model_1" ,
3075+ model_task = "text_embedding" ,
3076+ gpu_count = 2 , # Changed from 1 to 2
3077+ artifact_location = "oci://test_location_1" ,
3078+ params = {"--custom-param" : "99" },
3079+ )
3080+
3081+ create_details_custom = CreateModelDeploymentDetails (
3082+ models = [model_with_custom_params ],
3083+ instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAME ,
3084+ display_name = "test-deployment" ,
3085+ )
3086+
3087+ config_custom = ModelGroupConfig .from_model_deployment_details (
3088+ deployment_details = create_details_custom ,
3089+ model_config_summary = model_config_summary ,
3090+ container_type_key = "odsc-vllm-serving" ,
3091+ container_params = "--container-param test" ,
3092+ )
3093+
3094+ model_params_custom = config_custom .models [0 ].params
3095+ # User value should be present
3096+ assert "--custom-param 99" in model_params_custom
3097+ # SMM defaults should NOT be present
3098+ assert "--trust-remote-code" not in model_params_custom
3099+ assert "--max-model-len 32000" not in model_params_custom
3100+ # Container params should still be present
3101+ assert "--container-param test" in model_params_custom
0 commit comments