Skip to content
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

change: Create core integ tests folder and setup #4505

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions tests/integ/core/__init__.py
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions tests/integ/core/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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


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):
item.add_marker(pytest.mark.core)
Copy link
Contributor

@benieric benieric Mar 15, 2024

Choose a reason for hiding this comment

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

So with this we can do tox -e py310 -- test/integ -m core?

Idea being that we'll be able to split things up here and later on in our buildspec do

tox -e py310 -- test/integ -m $SUB_TESTS

where we pass $SUB_TESTS (or whatever we call it) as an environment variable from our github actions yml. In this case we could set SUB_TESTS='core' to only run core tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup! that's correct.

This is applied as a filter after pytest performs collection and adds a marker to the tests that are in this directory.
Locally the collection runs quickly <3mins

pytest tests/integ --collect-only --quiet -m core

Copy link
Contributor

Choose a reason for hiding this comment

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

nicee

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/integ/test_tf.py → tests/integ/core/test_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tests/integ/test_pytorchddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tests/integ/test_smdataparallel_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/integ/test_torch_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down