Skip to content

change: get python version dynamically for remote function tests #4089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/data/remote_function/old_deps_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pandas==1.1.0
pandas==1.3.4
26 changes: 19 additions & 7 deletions tests/integ/sagemaker/remote_function/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pytest
import docker
import re
import sys

from sagemaker.utils import sagemaker_timestamp, _tmpdir, sts_regional_endpoint

Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!



@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


Expand Down
7 changes: 7 additions & 0 deletions tests/integ/sagemaker/remote_function/test_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ def divide(x, y):
def test_with_incompatible_dependencies(
sagemaker_session, dummy_container_without_error, cpu_instance_type
):
"""
This test is limited by the python version it is run with.
It is currently working with python 3.8+. However, running it with older versions
or versions in the future may require changes to 'old_deps_requirements.txt'
to fulfill testing scenario.
"""

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

Expand Down