diff --git a/src/sagemaker/model.py b/src/sagemaker/model.py index 4292c3efdf..2fe0243917 100644 --- a/src/sagemaker/model.py +++ b/src/sagemaker/model.py @@ -684,11 +684,11 @@ def prepare_container_def( Returns: dict: A container definition object usable with the CreateModel API. """ - deploy_key_prefix = fw_utils.model_code_key_prefix( - self.key_prefix, self.name, self.image_uri - ) deploy_env = copy.deepcopy(self.env) if self.source_dir or self.dependencies or self.entry_point or self.git_config: + deploy_key_prefix = fw_utils.model_code_key_prefix( + self.key_prefix, self.name, self.image_uri + ) self._upload_code(deploy_key_prefix, repack=self.is_repack()) deploy_env.update(self._script_mode_env_vars())