From ab50d4a98fa060cb3f4dbd7f732b5e30d5a219f9 Mon Sep 17 00:00:00 2001 From: ewezy Date: Fri, 6 Oct 2023 17:19:29 +0800 Subject: [PATCH] Set env name as either the default or the existing endpoint's env when not specified --- python/sdk/merlin/model.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/sdk/merlin/model.py b/python/sdk/merlin/model.py index 403f8470f..da18980ff 100644 --- a/python/sdk/merlin/model.py +++ b/python/sdk/merlin/model.py @@ -1093,9 +1093,6 @@ def deploy( current_endpoint = self.endpoint env_list = self._get_env_list() - # target_env_name can never be set as null - target_env_name = environment_name if environment_name is not None else ModelVersion._get_default_target_env_name(env_list) - target_deployment_mode = None target_protocol = None target_resource_request = None @@ -1107,6 +1104,7 @@ def deploy( # Get the currently deployed endpoint and if there's no deployed endpoint yet, use the default values for # non-nullable fields if current_endpoint is None: + target_env_name = ModelVersion._get_default_target_env_name(env_list) target_deployment_mode = DeploymentMode.SERVERLESS.value target_protocol = Protocol.HTTP_JSON.value target_resource_request = ModelVersion._get_default_resource_request(target_env_name, env_list) @@ -1114,6 +1112,13 @@ def deploy( deployment_mode.value if deployment_mode is not None else target_deployment_mode ) + if environment_name is not None: + target_env_name = environment_name + elif current_endpoint is not None: + # when we are updating a deployment but environment_name is not specified, we reuse the existing endpoint's + # environment name + target_env_name = current_endpoint.environment_name + if deployment_mode is not None: target_deployment_mode = deployment_mode.value