From 32bfa18384b52aa3ce99a8e441b932985919170b Mon Sep 17 00:00:00 2001 From: Erick Benitez-Ramos Date: Thu, 24 Aug 2023 14:43:49 -0700 Subject: [PATCH] change: get python version dynamically for remote function tests --- .../remote_function/old_deps_requirements.txt | 2 +- .../sagemaker/remote_function/conftest.py | 26 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/data/remote_function/old_deps_requirements.txt b/tests/data/remote_function/old_deps_requirements.txt index 684864f2bc..d3bddebad1 100644 --- a/tests/data/remote_function/old_deps_requirements.txt +++ b/tests/data/remote_function/old_deps_requirements.txt @@ -1 +1 @@ -pandas==1.1.0 +pandas==1.3.4 diff --git a/tests/integ/sagemaker/remote_function/conftest.py b/tests/integ/sagemaker/remote_function/conftest.py index 509e283ff4..d9bc331da3 100644 --- a/tests/integ/sagemaker/remote_function/conftest.py +++ b/tests/integ/sagemaker/remote_function/conftest.py @@ -19,6 +19,7 @@ import pytest import docker import re +import sys from sagemaker.utils import sagemaker_timestamp, _tmpdir, sts_regional_endpoint @@ -87,21 +88,32 @@ @pytest.fixture(scope="package") -def dummy_container_without_error(sagemaker_session): - # TODO: the python version should be dynamically specified instead of hardcoding - ecr_uri = _build_container(sagemaker_session, "3.7", DOCKERFILE_TEMPLATE) +def compatible_python_version(): + return "{}.{}".format(sys.version_info.major, sys.version_info.minor) + + +@pytest.fixture(scope="package") +def incompatible_python_version(): + return "{}.{}".format(sys.version_info.major, sys.version_info.minor - 1) + + +@pytest.fixture(scope="package") +def dummy_container_without_error(sagemaker_session, compatible_python_version): + ecr_uri = _build_container(sagemaker_session, compatible_python_version, DOCKERFILE_TEMPLATE) return ecr_uri @pytest.fixture(scope="package") -def dummy_container_incompatible_python_runtime(sagemaker_session): - ecr_uri = _build_container(sagemaker_session, "3.10", DOCKERFILE_TEMPLATE) +def dummy_container_incompatible_python_runtime(sagemaker_session, incompatible_python_version): + ecr_uri = _build_container(sagemaker_session, incompatible_python_version, DOCKERFILE_TEMPLATE) return ecr_uri @pytest.fixture(scope="package") -def dummy_container_with_conda(sagemaker_session): - ecr_uri = _build_container(sagemaker_session, "3.7", DOCKERFILE_TEMPLATE_WITH_CONDA) +def dummy_container_with_conda(sagemaker_session, compatible_python_version): + ecr_uri = _build_container( + sagemaker_session, compatible_python_version, DOCKERFILE_TEMPLATE_WITH_CONDA + ) return ecr_uri