From e747b442cd312fdba9366d57aac0b931b806f657 Mon Sep 17 00:00:00 2001 From: Ashwin Krishna Date: Thu, 14 Mar 2024 20:52:51 +0000 Subject: [PATCH 1/3] change: Create core integ tests folder and setup Moved few integration tests to core folder this subset will be run for every pull request to increase velocity of the pull requests independent contributors must still run the entire test suite added python 3.11 to the setup.py --- setup.py | 5 +++-- tests/integ/core/__init__.py | 13 ++++++++++++ tests/integ/core/conftest.py | 21 +++++++++++++++++++ tests/integ/{ => core}/test_byo_estimator.py | 0 tests/integ/{ => core}/test_data_upload.py | 0 tests/integ/{ => core}/test_huggingface.py | 0 .../integ/{ => core}/test_monitoring_files.py | 0 .../{ => core}/test_multi_variant_endpoint.py | 0 tests/integ/{ => core}/test_ntm.py | 0 tests/integ/{ => core}/test_object2vec.py | 0 tests/integ/{ => core}/test_pca.py | 0 tests/integ/{ => core}/test_processing.py | 0 tests/integ/{ => core}/test_pytorch.py | 0 tests/integ/{ => core}/test_record_set.py | 0 tests/integ/{ => core}/test_s3.py | 0 .../integ/{ => core}/test_sagemaker_config.py | 0 .../{ => core}/test_serverless_inference.py | 0 tests/integ/{ => core}/test_session.py | 0 tests/integ/{ => core}/test_sklearn.py | 0 .../integ/{ => core}/test_spark_processing.py | 0 tests/integ/{ => core}/test_tf.py | 0 tests/integ/test_pytorchddp.py | 2 +- tests/integ/test_smdataparallel_pt.py | 2 +- tests/integ/test_torch_distributed.py | 2 +- tox.ini | 2 ++ 25 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tests/integ/core/__init__.py create mode 100644 tests/integ/core/conftest.py rename tests/integ/{ => core}/test_byo_estimator.py (100%) rename tests/integ/{ => core}/test_data_upload.py (100%) rename tests/integ/{ => core}/test_huggingface.py (100%) rename tests/integ/{ => core}/test_monitoring_files.py (100%) rename tests/integ/{ => core}/test_multi_variant_endpoint.py (100%) rename tests/integ/{ => core}/test_ntm.py (100%) rename tests/integ/{ => core}/test_object2vec.py (100%) rename tests/integ/{ => core}/test_pca.py (100%) rename tests/integ/{ => core}/test_processing.py (100%) rename tests/integ/{ => core}/test_pytorch.py (100%) rename tests/integ/{ => core}/test_record_set.py (100%) rename tests/integ/{ => core}/test_s3.py (100%) rename tests/integ/{ => core}/test_sagemaker_config.py (100%) rename tests/integ/{ => core}/test_serverless_inference.py (100%) rename tests/integ/{ => core}/test_session.py (100%) rename tests/integ/{ => core}/test_sklearn.py (100%) rename tests/integ/{ => core}/test_spark_processing.py (100%) rename tests/integ/{ => core}/test_tf.py (100%) diff --git a/setup.py b/setup.py index f37058eb4a..cf0fab10ad 100644 --- a/setup.py +++ b/setup.py @@ -85,8 +85,8 @@ def read_requirements(filename): extras["all"] = [item for group in extras.values() for item in group] # Tests specific dependencies (do not need to be included in 'all') test_dependencies = read_requirements("requirements/extras/test_requirements.txt") -# remove torch and torchvision if python version is not 3.10 -if sys.version_info.minor != 10: +# remove torch and torchvision if python version is not 3.10 or 3.11 +if sys.version_info.minor != 10 or sys.version_info.minor != 11: test_dependencies = [ module for module in test_dependencies @@ -124,6 +124,7 @@ def read_requirements(filename): "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], install_requires=required_packages, extras_require=extras, diff --git a/tests/integ/core/__init__.py b/tests/integ/core/__init__.py new file mode 100644 index 0000000000..f0097d8ebb --- /dev/null +++ b/tests/integ/core/__init__.py @@ -0,0 +1,13 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +from __future__ import absolute_import \ No newline at end of file diff --git a/tests/integ/core/conftest.py b/tests/integ/core/conftest.py new file mode 100644 index 0000000000..24b8acd59c --- /dev/null +++ b/tests/integ/core/conftest.py @@ -0,0 +1,21 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You +# may not use this file except in compliance with the License. A copy of +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +from __future__ import absolute_import + +import pytest +import pathlib + +def pytest_collection_modifyitems(config, items): + for item in items: + if 'tests/integ/core' in str(item.fspath): + item.add_marker(pytest.mark.core) diff --git a/tests/integ/test_byo_estimator.py b/tests/integ/core/test_byo_estimator.py similarity index 100% rename from tests/integ/test_byo_estimator.py rename to tests/integ/core/test_byo_estimator.py diff --git a/tests/integ/test_data_upload.py b/tests/integ/core/test_data_upload.py similarity index 100% rename from tests/integ/test_data_upload.py rename to tests/integ/core/test_data_upload.py diff --git a/tests/integ/test_huggingface.py b/tests/integ/core/test_huggingface.py similarity index 100% rename from tests/integ/test_huggingface.py rename to tests/integ/core/test_huggingface.py diff --git a/tests/integ/test_monitoring_files.py b/tests/integ/core/test_monitoring_files.py similarity index 100% rename from tests/integ/test_monitoring_files.py rename to tests/integ/core/test_monitoring_files.py diff --git a/tests/integ/test_multi_variant_endpoint.py b/tests/integ/core/test_multi_variant_endpoint.py similarity index 100% rename from tests/integ/test_multi_variant_endpoint.py rename to tests/integ/core/test_multi_variant_endpoint.py diff --git a/tests/integ/test_ntm.py b/tests/integ/core/test_ntm.py similarity index 100% rename from tests/integ/test_ntm.py rename to tests/integ/core/test_ntm.py diff --git a/tests/integ/test_object2vec.py b/tests/integ/core/test_object2vec.py similarity index 100% rename from tests/integ/test_object2vec.py rename to tests/integ/core/test_object2vec.py diff --git a/tests/integ/test_pca.py b/tests/integ/core/test_pca.py similarity index 100% rename from tests/integ/test_pca.py rename to tests/integ/core/test_pca.py diff --git a/tests/integ/test_processing.py b/tests/integ/core/test_processing.py similarity index 100% rename from tests/integ/test_processing.py rename to tests/integ/core/test_processing.py diff --git a/tests/integ/test_pytorch.py b/tests/integ/core/test_pytorch.py similarity index 100% rename from tests/integ/test_pytorch.py rename to tests/integ/core/test_pytorch.py diff --git a/tests/integ/test_record_set.py b/tests/integ/core/test_record_set.py similarity index 100% rename from tests/integ/test_record_set.py rename to tests/integ/core/test_record_set.py diff --git a/tests/integ/test_s3.py b/tests/integ/core/test_s3.py similarity index 100% rename from tests/integ/test_s3.py rename to tests/integ/core/test_s3.py diff --git a/tests/integ/test_sagemaker_config.py b/tests/integ/core/test_sagemaker_config.py similarity index 100% rename from tests/integ/test_sagemaker_config.py rename to tests/integ/core/test_sagemaker_config.py diff --git a/tests/integ/test_serverless_inference.py b/tests/integ/core/test_serverless_inference.py similarity index 100% rename from tests/integ/test_serverless_inference.py rename to tests/integ/core/test_serverless_inference.py diff --git a/tests/integ/test_session.py b/tests/integ/core/test_session.py similarity index 100% rename from tests/integ/test_session.py rename to tests/integ/core/test_session.py diff --git a/tests/integ/test_sklearn.py b/tests/integ/core/test_sklearn.py similarity index 100% rename from tests/integ/test_sklearn.py rename to tests/integ/core/test_sklearn.py diff --git a/tests/integ/test_spark_processing.py b/tests/integ/core/test_spark_processing.py similarity index 100% rename from tests/integ/test_spark_processing.py rename to tests/integ/core/test_spark_processing.py diff --git a/tests/integ/test_tf.py b/tests/integ/core/test_tf.py similarity index 100% rename from tests/integ/test_tf.py rename to tests/integ/core/test_tf.py diff --git a/tests/integ/test_pytorchddp.py b/tests/integ/test_pytorchddp.py index c580fdebc2..c7f85225bf 100644 --- a/tests/integ/test_pytorchddp.py +++ b/tests/integ/test_pytorchddp.py @@ -18,7 +18,7 @@ import tests.integ as integ from sagemaker.pytorch import PyTorch from tests.integ import timeout -from tests.integ.test_pytorch import _upload_training_data +from tests.integ.core.test_pytorch import _upload_training_data pytorchddp_dir = os.path.join(os.path.dirname(__file__), "..", "data", "pytorch_ddp") diff --git a/tests/integ/test_smdataparallel_pt.py b/tests/integ/test_smdataparallel_pt.py index 38c38d8643..f3f5a4b1d9 100644 --- a/tests/integ/test_smdataparallel_pt.py +++ b/tests/integ/test_smdataparallel_pt.py @@ -21,7 +21,7 @@ from sagemaker.pytorch import PyTorch from tests.integ import timeout -from tests.integ.test_pytorch import _upload_training_data +from tests.integ.core.test_pytorch import _upload_training_data smdataparallel_dir = os.path.join( os.path.dirname(__file__), "..", "data", "smdistributed_dataparallel" diff --git a/tests/integ/test_torch_distributed.py b/tests/integ/test_torch_distributed.py index 860836b7d1..1c628570bd 100644 --- a/tests/integ/test_torch_distributed.py +++ b/tests/integ/test_torch_distributed.py @@ -18,7 +18,7 @@ import tests.integ as integ from sagemaker.pytorch import PyTorch from tests.integ import timeout -from tests.integ.test_pytorch import _upload_training_data +from tests.integ.core.test_pytorch import _upload_training_data torch_distributed_dir = os.path.join(os.path.dirname(__file__), "..", "data", "torch_distributed") diff --git a/tox.ini b/tox.ini index 0c1c347c0d..1853b94b66 100644 --- a/tox.ini +++ b/tox.ini @@ -85,6 +85,8 @@ commands = pip install 'torch==2.0.1+cpu' -f 'https://download.pytorch.org/whl/torch_stable.html' pip install 'torchvision==0.15.2+cpu' -f 'https://download.pytorch.org/whl/torch_stable.html' pip install 'dill>=0.3.8' + # present in test_requirements but install accelerate specifically to fix Module not found error + pip install 'accelerate>=0.24.1,<=0.27.0' pytest {posargs} deps = .[test] From e68d6e51a42e953eb6c5f636891c29d9f242f65e Mon Sep 17 00:00:00 2001 From: Ashwin Krishna Date: Thu, 14 Mar 2024 22:38:56 +0000 Subject: [PATCH 2/3] fix: integ test and black check --- tests/integ/core/__init__.py | 2 +- tests/integ/core/conftest.py | 9 ++++++++- tests/integ/core/test_tf.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/integ/core/__init__.py b/tests/integ/core/__init__.py index f0097d8ebb..a6987bc6a6 100644 --- a/tests/integ/core/__init__.py +++ b/tests/integ/core/__init__.py @@ -10,4 +10,4 @@ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. -from __future__ import absolute_import \ No newline at end of file +from __future__ import absolute_import diff --git a/tests/integ/core/conftest.py b/tests/integ/core/conftest.py index 24b8acd59c..e90797d23a 100644 --- a/tests/integ/core/conftest.py +++ b/tests/integ/core/conftest.py @@ -15,7 +15,14 @@ import pytest import pathlib + +def pytest_configure(config): + config.addinivalue_line( + "markers", "core: subset of integ tests that must run for every pull request" + ) + + def pytest_collection_modifyitems(config, items): for item in items: - if 'tests/integ/core' in str(item.fspath): + if "tests/integ/core" in str(item.fspath): item.add_marker(pytest.mark.core) diff --git a/tests/integ/core/test_tf.py b/tests/integ/core/test_tf.py index b03b0e60ec..b9a584b58e 100644 --- a/tests/integ/core/test_tf.py +++ b/tests/integ/core/test_tf.py @@ -32,7 +32,7 @@ ROLE = "SageMakerRole" -RESOURCE_PATH = os.path.join(os.path.dirname(__file__), "..", "data") +RESOURCE_PATH = os.path.join(os.path.dirname(__file__), "..", "..", "data") MNIST_RESOURCE_PATH = os.path.join(RESOURCE_PATH, "tensorflow_mnist") TFS_RESOURCE_PATH = os.path.join(RESOURCE_PATH, "tfs", "tfs-test-entrypoint-with-handler") From 9bcaf1220f51cfe3e0fe94311b3357e41c88c3ed Mon Sep 17 00:00:00 2001 From: Ashwin Krishna Date: Fri, 15 Mar 2024 00:15:29 +0000 Subject: [PATCH 3/3] fix: fix the flake8 --- tests/integ/core/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integ/core/conftest.py b/tests/integ/core/conftest.py index e90797d23a..1acf6ddb53 100644 --- a/tests/integ/core/conftest.py +++ b/tests/integ/core/conftest.py @@ -13,7 +13,6 @@ from __future__ import absolute_import import pytest -import pathlib def pytest_configure(config):