Skip to content

Commit d87e930

Browse files
danabensTusharKanekiDeyYYStreet
authored
upgrade to latest sagemaker-experiments (#286)
Co-authored-by: TusharKanekiDey <dey.tushar@yahoo.com> Co-authored-by: Zhuo Weng <wenzhuo@amazon.com>
1 parent 05d94bc commit d87e930

File tree

5 files changed

+115
-3
lines changed

5 files changed

+115
-3
lines changed

docker/1.15.2/py3/Dockerfile.cpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ RUN pip install --no-cache-dir -U \
101101
requests==2.22.0 \
102102
smdebug==0.7.0 \
103103
sagemaker==1.50.17 \
104-
sagemaker-experiments==0.1.3 \
104+
sagemaker-experiments==0.1.7 \
105105
mpi4py==3.0.2 \
106106
"cryptography>=2.3" \
107107
"sagemaker-tensorflow>=1.15,<1.16" \

docker/1.15.2/py3/Dockerfile.gpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ RUN pip install --no-cache-dir -U \
139139
keras==2.3.1 \
140140
smdebug==0.7.0 \
141141
sagemaker==1.50.17 \
142-
sagemaker-experiments==0.1.3 \
142+
sagemaker-experiments==0.1.7 \
143143
mpi4py==3.0.2 \
144144
"cryptography>=2.3" \
145145
"sagemaker-tensorflow>=1.15,<1.16" \

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def read_version():
6060
'sagemaker==1.50.1', 'tensorflow<2.0', 'docker-compose', 'boto3==1.10.50',
6161
'six==1.13.0', 'python-dateutil>=2.1,<2.8.1', 'botocore==1.13.50',
6262
'requests-mock', 'awscli==1.16.314'],
63-
'benchmark': ['click']
63+
'benchmark': ['click'],
64+
':python_version=="3.6"': ['sagemaker-experiments==0.1.7']
6465
},
6566
)

test/integration/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ def instance_type(request, processor):
9292
return provided_instance_type if provided_instance_type is not None else default_instance_type
9393

9494

95+
@pytest.fixture()
96+
def py_version():
97+
if 'TEST_PY_VERSIONS' in os.environ:
98+
return os.environ['TEST_PY_VERSIONS'].split(',')
99+
return None
100+
101+
102+
@pytest.fixture()
103+
def processor():
104+
if 'TEST_PROCESSORS' in os.environ:
105+
return os.environ['TEST_PROCESSORS'].split(',')
106+
return None
107+
108+
95109
@pytest.fixture(autouse=True)
96110
def skip_by_device_type(request, processor):
97111
is_gpu = (processor == 'gpu')
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License").
4+
# You may not use this file except in compliance with the License.
5+
# A copy of the License is located at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# or in the "license" file accompanying this file. This file is distributed
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
# express or implied. See the License for the specific language governing
12+
# permissions and limitations under the License.
13+
from __future__ import absolute_import
14+
15+
import os
16+
import time
17+
18+
import pytest
19+
from sagemaker import utils
20+
from sagemaker.tensorflow import TensorFlow
21+
22+
from test.integration import RESOURCE_PATH
23+
from timeout import timeout
24+
25+
DATA_PATH = os.path.join(RESOURCE_PATH, "mnist")
26+
SCRIPT_PATH = os.path.join(DATA_PATH, "mnist_gluon_basic_hook_demo.py")
27+
28+
29+
@pytest.mark.skip_py2_containers
30+
def test_training(sagemaker_session, ecr_image, instance_type, framework_version, py_version):
31+
32+
if py_version is None or '2' in py_version:
33+
pytest.skip('Skipping python2 {}'.format(py_version))
34+
return
35+
36+
from smexperiments.experiment import Experiment
37+
from smexperiments.trial import Trial
38+
from smexperiments.trial_component import TrialComponent
39+
40+
sm_client = sagemaker_session.sagemaker_client
41+
42+
experiment_name = "tf-container-integ-test-{}".format(int(time.time()))
43+
44+
experiment = Experiment.create(
45+
experiment_name=experiment_name,
46+
description="Integration test experiment from sagemaker-tf-container",
47+
sagemaker_boto_client=sm_client,
48+
)
49+
50+
trial_name = "tf-container-integ-test-{}".format(int(time.time()))
51+
trial = Trial.create(
52+
experiment_name=experiment_name, trial_name=trial_name, sagemaker_boto_client=sm_client
53+
)
54+
55+
training_job_name = utils.unique_name_from_base("test-tf-experiments-mnist")
56+
57+
# create a training job and wait for it to complete
58+
with timeout(minutes=15):
59+
resource_path = os.path.join(os.path.dirname(__file__), "..", "..", "resources")
60+
script = os.path.join(resource_path, "mnist", "mnist.py")
61+
estimator = TensorFlow(
62+
entry_point=script,
63+
role="SageMakerRole",
64+
train_instance_type=instance_type,
65+
train_instance_count=1,
66+
sagemaker_session=sagemaker_session,
67+
image_name=ecr_image,
68+
framework_version=framework_version,
69+
script_mode=True,
70+
)
71+
inputs = estimator.sagemaker_session.upload_data(
72+
path=os.path.join(resource_path, "mnist", "data"), key_prefix="scriptmode/mnist"
73+
)
74+
estimator.fit(inputs, job_name=training_job_name)
75+
76+
training_job = sm_client.describe_training_job(TrainingJobName=training_job_name)
77+
training_job_arn = training_job["TrainingJobArn"]
78+
79+
# verify trial component auto created from the training job
80+
trial_components = list(
81+
TrialComponent.list(source_arn=training_job_arn, sagemaker_boto_client=sm_client)
82+
)
83+
84+
trial_component_summary = trial_components[0]
85+
trial_component = TrialComponent.load(
86+
trial_component_name=trial_component_summary.trial_component_name,
87+
sagemaker_boto_client=sm_client,
88+
)
89+
90+
# associate the trial component with the trial
91+
trial.add_trial_component(trial_component)
92+
93+
# cleanup
94+
trial.remove_trial_component(trial_component_summary.trial_component_name)
95+
trial_component.delete()
96+
trial.delete()
97+
experiment.delete()

0 commit comments

Comments
 (0)