Skip to content

Commit 5f9a6be

Browse files
change: get python version dynamically for remote function tests (#4089)
Co-authored-by: Mufaddal Rohawala <[email protected]>
1 parent f35b48c commit 5f9a6be

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pandas==1.1.0
1+
pandas==1.3.4

tests/integ/sagemaker/remote_function/conftest.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import pytest
2020
import docker
2121
import re
22+
import sys
2223

2324
from sagemaker.utils import sagemaker_timestamp, _tmpdir, sts_regional_endpoint
2425

@@ -87,21 +88,32 @@
8788

8889

8990
@pytest.fixture(scope="package")
90-
def dummy_container_without_error(sagemaker_session):
91-
# TODO: the python version should be dynamically specified instead of hardcoding
92-
ecr_uri = _build_container(sagemaker_session, "3.7", DOCKERFILE_TEMPLATE)
91+
def compatible_python_version():
92+
return "{}.{}".format(sys.version_info.major, sys.version_info.minor)
93+
94+
95+
@pytest.fixture(scope="package")
96+
def incompatible_python_version():
97+
return "{}.{}".format(sys.version_info.major, sys.version_info.minor + 1)
98+
99+
100+
@pytest.fixture(scope="package")
101+
def dummy_container_without_error(sagemaker_session, compatible_python_version):
102+
ecr_uri = _build_container(sagemaker_session, compatible_python_version, DOCKERFILE_TEMPLATE)
93103
return ecr_uri
94104

95105

96106
@pytest.fixture(scope="package")
97-
def dummy_container_incompatible_python_runtime(sagemaker_session):
98-
ecr_uri = _build_container(sagemaker_session, "3.10", DOCKERFILE_TEMPLATE)
107+
def dummy_container_incompatible_python_runtime(sagemaker_session, incompatible_python_version):
108+
ecr_uri = _build_container(sagemaker_session, incompatible_python_version, DOCKERFILE_TEMPLATE)
99109
return ecr_uri
100110

101111

102112
@pytest.fixture(scope="package")
103-
def dummy_container_with_conda(sagemaker_session):
104-
ecr_uri = _build_container(sagemaker_session, "3.7", DOCKERFILE_TEMPLATE_WITH_CONDA)
113+
def dummy_container_with_conda(sagemaker_session, compatible_python_version):
114+
ecr_uri = _build_container(
115+
sagemaker_session, compatible_python_version, DOCKERFILE_TEMPLATE_WITH_CONDA
116+
)
105117
return ecr_uri
106118

107119

tests/integ/sagemaker/remote_function/test_decorator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ def divide(x, y):
272272
def test_with_incompatible_dependencies(
273273
sagemaker_session, dummy_container_without_error, cpu_instance_type
274274
):
275+
"""
276+
This test is limited by the python version it is run with.
277+
It is currently working with python 3.8+. However, running it with older versions
278+
or versions in the future may require changes to 'old_deps_requirements.txt'
279+
to fulfill testing scenario.
280+
281+
"""
275282

276283
dependencies_path = os.path.join(DATA_DIR, "remote_function", "old_deps_requirements.txt")
277284

0 commit comments

Comments
 (0)