Skip to content

Commit eb2fd2a

Browse files
committed
fix: Move sagemaker pysdk version check after bootstrap in remote job
1 parent 7fecc33 commit eb2fd2a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/sagemaker/remote_function/runtime_environment/bootstrap_runtime_environment.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ def main(sys_args=None):
6565
conda_env = job_conda_env or os.getenv("SAGEMAKER_JOB_CONDA_ENV")
6666

6767
RuntimeEnvironmentManager()._validate_python_version(client_python_version, conda_env)
68-
RuntimeEnvironmentManager()._validate_sagemaker_pysdk_version(
69-
client_sagemaker_pysdk_version
70-
)
7168

7269
user = getpass.getuser()
7370
if user != "root":
@@ -89,6 +86,10 @@ def main(sys_args=None):
8986
client_python_version, conda_env, dependency_settings
9087
)
9188

89+
RuntimeEnvironmentManager()._validate_sagemaker_pysdk_version(
90+
client_sagemaker_pysdk_version
91+
)
92+
9293
exit_code = SUCCESS_EXIT_CODE
9394
except Exception as e: # pylint: disable=broad-except
9495
logger.exception("Error encountered while bootstrapping runtime environment: %s", e)

src/sagemaker/remote_function/runtime_environment/runtime_environment_manager.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import dataclasses
2525
import json
2626

27-
import sagemaker
28-
2927

3028
class _UTCFormatter(logging.Formatter):
3129
"""Class that overrides the default local time provider in log formatter."""
@@ -330,6 +328,7 @@ def _current_python_version(self):
330328

331329
def _current_sagemaker_pysdk_version(self):
332330
"""Returns the current sagemaker python sdk version where program is running"""
331+
import sagemaker
333332

334333
return sagemaker.__version__
335334

@@ -368,8 +367,8 @@ def _validate_sagemaker_pysdk_version(self, client_sagemaker_pysdk_version):
368367
"Inconsistent sagemaker versions found: "
369368
"sagemaker pysdk version found in the container is "
370369
"'%s' which does not match the '%s' on the local client. "
371-
"Please make sure that the python version used in the training container "
372-
"is the same as the local python version in case of unexpected behaviors.",
370+
"Please make sure that the pysdk version used in the training container "
371+
"is the same as the local pysdk version in case of unexpected behaviors.",
373372
job_sagemaker_pysdk_version,
374373
client_sagemaker_pysdk_version,
375374
)

0 commit comments

Comments
 (0)