Skip to content

Commit 29724c2

Browse files
authored
Merge branch 'master' into feat/model-uri-with-script
2 parents b87f794 + 6c5c040 commit 29724c2

File tree

11 files changed

+68
-39
lines changed

11 files changed

+68
-39
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
concurrency = threading
33
omit = sagemaker/tests/*
44
timid = True
5+
disable_warnings = module-not-measured

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## v2.140.1 (2023-03-21)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* Fix cross account register model
8+
* Handle instance support for Hugging Face tests
9+
* Upgrade apache-airflow-providers-amazon version
10+
* build(deps): bump apache-airflow from 2.4.1 to 2.5.1
11+
* Mark test_create_model_package test for xfail
12+
* Disable module-not-measured warnings to avoid clutter in build logs
13+
314
## v2.140.0 (2023-03-17)
415

516
### Features

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.140.1.dev0
1+
2.140.2.dev0

requirements/extras/test_requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ awslogs==0.14.0
1212
black==22.3.0
1313
stopit==1.1.2
1414
# Update tox.ini to have correct version of airflow constraints file
15-
apache-airflow==2.4.1
16-
apache-airflow-providers-amazon==4.0.0
15+
apache-airflow==2.5.1
16+
apache-airflow-providers-amazon==7.2.1
1717
attrs==22.1.0
1818
fabric==2.6.0
1919
requests==2.27.1

src/sagemaker/session.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3222,7 +3222,9 @@ def create_model_package_from_containers(
32223222
)
32233223

32243224
def submit(request):
3225-
if model_package_group_name is not None:
3225+
if model_package_group_name is not None and not model_package_group_name.startswith(
3226+
"arn:"
3227+
):
32263228
_create_resource(
32273229
lambda: self.sagemaker_client.create_model_package_group(
32283230
ModelPackageGroupName=request["ModelPackageGroupName"]

tests/conftest.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,16 @@ def gpu_instance_type(sagemaker_session, request):
567567

568568
@pytest.fixture()
569569
def gpu_pytorch_instance_type(sagemaker_session, request):
570-
if "pytorch_inference_version" in request.fixturenames:
571-
fw_version = request.getfixturevalue("pytorch_inference_version")
572-
else:
570+
fw_version = None
571+
for pytorch_version_fixture in [
572+
"pytorch_inference_version",
573+
"huggingface_training_pytorch_latest_version",
574+
"huggingface_inference_pytorch_latest_version",
575+
]:
576+
if pytorch_version_fixture in request.fixturenames:
577+
fw_version = request.getfixturevalue(pytorch_version_fixture)
578+
if fw_version is None:
573579
fw_version = request.param
574-
575580
region = sagemaker_session.boto_session.region_name
576581
if region in NO_P3_REGIONS:
577582
if Version(fw_version) >= Version("1.13"):

tests/integ/test_airflow_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
import sagemaker.workflow.airflow as sm_airflow
5757
import airflow.utils as utils
5858
from airflow import DAG
59-
from airflow.providers.amazon.aws.operators.sagemaker import SageMakerTrainingOperator
60-
from airflow.providers.amazon.aws.operators.sagemaker_transform import (
59+
from airflow.providers.amazon.aws.operators.sagemaker import (
60+
SageMakerTrainingOperator,
6161
SageMakerTransformOperator,
6262
)
6363

tests/integ/test_huggingface.py

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,19 @@
1919
from sagemaker.huggingface import HuggingFace, HuggingFaceProcessor
2020
from sagemaker.huggingface.model import HuggingFaceModel, HuggingFacePredictor
2121
from sagemaker.utils import unique_name_from_base
22-
from tests import integ
23-
from tests.integ.utils import gpu_list, retry_with_instance_list
2422
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2523
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2624

2725
ROLE = "SageMakerRole"
2826

2927

3028
@pytest.mark.release
31-
@pytest.mark.skipif(
32-
integ.test_region() in integ.TRAINING_NO_P2_REGIONS
33-
and integ.test_region() in integ.TRAINING_NO_P3_REGIONS,
34-
reason="no ml.p2 or ml.p3 instances in this region",
35-
)
36-
@retry_with_instance_list(gpu_list(integ.test_region()))
3729
def test_framework_processing_job_with_deps(
3830
sagemaker_session,
3931
huggingface_training_latest_version,
4032
huggingface_training_pytorch_latest_version,
4133
huggingface_pytorch_latest_training_py_version,
42-
**kwargs,
34+
gpu_pytorch_instance_type,
4335
):
4436
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
4537
code_path = os.path.join(DATA_DIR, "dummy_code_bundle_with_reqs")
@@ -51,7 +43,7 @@ def test_framework_processing_job_with_deps(
5143
py_version=huggingface_pytorch_latest_training_py_version,
5244
role=ROLE,
5345
instance_count=1,
54-
instance_type=kwargs["instance_type"],
46+
instance_type=gpu_pytorch_instance_type,
5547
sagemaker_session=sagemaker_session,
5648
base_job_name="test-huggingface",
5749
)
@@ -64,18 +56,12 @@ def test_framework_processing_job_with_deps(
6456

6557

6658
@pytest.mark.release
67-
@pytest.mark.skipif(
68-
integ.test_region() in integ.TRAINING_NO_P2_REGIONS
69-
and integ.test_region() in integ.TRAINING_NO_P3_REGIONS,
70-
reason="no ml.p2 or ml.p3 instances in this region",
71-
)
72-
@retry_with_instance_list(gpu_list(integ.test_region()))
7359
def test_huggingface_training(
7460
sagemaker_session,
7561
huggingface_training_latest_version,
7662
huggingface_training_pytorch_latest_version,
7763
huggingface_pytorch_latest_training_py_version,
78-
**kwargs,
64+
gpu_pytorch_instance_type,
7965
):
8066
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
8167
data_path = os.path.join(DATA_DIR, "huggingface")
@@ -87,7 +73,7 @@ def test_huggingface_training(
8773
transformers_version=huggingface_training_latest_version,
8874
pytorch_version=huggingface_training_pytorch_latest_version,
8975
instance_count=1,
90-
instance_type=kwargs["instance_type"],
76+
instance_type=gpu_pytorch_instance_type,
9177
hyperparameters={
9278
"model_name_or_path": "distilbert-base-cased",
9379
"task_name": "wnli",
@@ -111,14 +97,6 @@ def test_huggingface_training(
11197

11298

11399
@pytest.mark.release
114-
@pytest.mark.skipif(
115-
integ.test_region() in integ.TRAINING_NO_P2_REGIONS
116-
and integ.test_region() in integ.TRAINING_NO_P3_REGIONS,
117-
reason="no ml.p2 or ml.p3 instances in this region",
118-
)
119-
@pytest.mark.skip(
120-
reason="need to re enable it later t.corp:V609860141",
121-
)
122100
def test_huggingface_training_tf(
123101
sagemaker_session,
124102
gpu_instance_type,
@@ -161,7 +139,7 @@ def test_huggingface_training_tf(
161139
)
162140
def test_huggingface_inference(
163141
sagemaker_session,
164-
gpu_instance_type,
142+
gpu_pytorch_instance_type,
165143
huggingface_inference_latest_version,
166144
huggingface_inference_pytorch_latest_version,
167145
huggingface_pytorch_latest_inference_py_version,
@@ -182,7 +160,9 @@ def test_huggingface_inference(
182160
)
183161
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
184162
model.deploy(
185-
instance_type=gpu_instance_type, initial_instance_count=1, endpoint_name=endpoint_name
163+
instance_type=gpu_pytorch_instance_type,
164+
initial_instance_count=1,
165+
endpoint_name=endpoint_name,
186166
)
187167

188168
predictor = HuggingFacePredictor(endpoint_name=endpoint_name)

tests/integ/test_marketplace.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ def iris_image(sagemaker_session):
233233
_delete_repository(ecr_client, algorithm_name)
234234

235235

236+
@pytest.mark.xfail(reason="marking this for xfail until we work on the test failure to be fixed")
236237
def test_create_model_package(sagemaker_session, boto_session, iris_image):
237238
MODEL_NAME = "iris-classifier-mp"
238239
# Prepare

tests/unit/test_session.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,6 +2650,35 @@ def test_create_model_package_from_containers(sagemaker_session):
26502650
sagemaker_session.sagemaker_client.create_model_package.assert_called_once()
26512651

26522652

2653+
def test_create_model_package_from_containers_cross_account_mpg_name(sagemaker_session):
2654+
mpg_name = "arn:aws:sagemaker:us-east-1:215995503607:model-package-group/stage-dev"
2655+
content_types = ["text/csv"]
2656+
response_types = ["text/csv"]
2657+
sagemaker_session.create_model_package_from_containers(
2658+
model_package_group_name=mpg_name,
2659+
content_types=content_types,
2660+
response_types=response_types,
2661+
)
2662+
sagemaker_session.sagemaker_client.create_model_package.assert_called_once()
2663+
2664+
2665+
def test_create_mpg_from_containers_cross_account_mpg_name(sagemaker_session):
2666+
mpg_name = "arn:aws:sagemaker:us-east-1:215995503607:model-package-group/stage-dev"
2667+
content_types = ["text/csv"]
2668+
response_types = ["text/csv"]
2669+
with pytest.raises(AssertionError) as error:
2670+
sagemaker_session.create_model_package_from_containers(
2671+
model_package_group_name=mpg_name,
2672+
content_types=content_types,
2673+
response_types=response_types,
2674+
)
2675+
sagemaker_session.sagemaker_client.create_model_package_group.assert_called_once()
2676+
assert (
2677+
"Expected 'create_model_package_group' to have been called once. "
2678+
"Called 0 times." == str(error)
2679+
)
2680+
2681+
26532682
def test_create_model_package_from_containers_name_conflict(sagemaker_session):
26542683
model_package_name = "sagemaker-model-package"
26552684
model_package_group_name = "sagemaker-model-package-group"

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ passenv =
7373
# Can be used to specify which tests to run, e.g.: tox -- -s
7474
commands =
7575
python -c "import os; os.system('install-custom-pkgs --install-boto-wheels')"
76-
pip install 'apache-airflow==2.4.1' --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.4.1/constraints-3.10.txt"
76+
pip install 'apache-airflow==2.5.1' --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.5.1/constraints-3.7.txt"
7777

7878
pytest --cov=sagemaker --cov-append {posargs}
7979
{env:IGNORE_COVERAGE:} coverage report -i --fail-under=86

0 commit comments

Comments
 (0)