Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 12433f3

Browse files
author
Chuyang Deng
committed
fix: run sagemaker tests for PR build
1 parent 1602159 commit 12433f3

File tree

14 files changed

+50
-19
lines changed

14 files changed

+50
-19
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ Multi-Model Endpoint can be used together with Pre/Post-Processing. Each model w
660660
|--lib
661661
|--external_module
662662
|--inference.py
663-
|--requirements.txt
664663

665664
## Contributing
666665

buildspec.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ phases:
2929
fi
3030
3131
# run SageMaker tests
32-
- |
33-
if is-release-build; then
34-
tox -e py37 -- -n 8 test/integration/sagemaker/test_tfs.py --versions 1.15.0
35-
tox -e py37 -- -n 8 test/integration/sagemaker/test_tfs.py --versions 2.1.0
36-
fi
32+
- tox -e py37 -- -n 8 test/integration/sagemaker/test_tfs.py --versions 1.15.0
33+
- tox -e py37 -- -n 8 test/integration/sagemaker/test_tfs.py --versions 2.1.0
34+
35+
- tox -e py37 -- test/integration/sagemaker/test_ei.py -n 8 --versions 1.14 --region {region} --registry {aws-id}
36+
3737

3838
# write deployment details to file
3939
# todo sort out eia versioning

docker/build_artifacts/sagemaker/serve.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def __init__(self):
8383

8484
def _create_tfs_config(self):
8585
models = tfs_utils.find_models()
86+
8687
if not models:
8788
raise ValueError('no SavedModel bundles found!')
8889

@@ -255,12 +256,6 @@ def start(self):
255256
self._state = 'starting'
256257
signal.signal(signal.SIGTERM, self._stop)
257258

258-
self._create_nginx_config()
259-
260-
if self._tfs_enable_batching:
261-
log.info('batching is enabled')
262-
tfs_utils.create_batching_config(self._tfs_batching_config_path)
263-
264259
if self._tfs_enable_multi_model_endpoint:
265260
log.info('multi-model endpoint is enabled, TFS model servers will be started later')
266261
else:
@@ -271,6 +266,12 @@ def start(self):
271266
self._create_tfs_config()
272267
self._start_tfs()
273268

269+
self._create_nginx_config()
270+
271+
if self._tfs_enable_batching:
272+
log.info('batching is enabled')
273+
tfs_utils.create_batching_config(self._tfs_batching_config_path)
274+
274275
if self._use_gunicorn:
275276
self._setup_gunicorn()
276277
self._start_gunicorn()

docker/build_artifacts/sagemaker/tfs_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ def create_tfs_config(
111111
config += ' }\n'
112112
config += '}\n'
113113

114-
log.info('tensorflow serving model config: \n%s\n', config)
115-
116114
with open(tfs_config_path, 'w') as f:
117115
f.write(config)
118116

scripts/build-all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -euo pipefail
66

77
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
88

9-
${DIR}/build.sh --version 1.14.0 --arch eia
9+
${DIR}/build.sh --version 2.0.0 --arch eia
1010
${DIR}/build.sh --version 1.15.0 --arch cpu
1111
${DIR}/build.sh --version 1.15.0 --arch gpu
1212
${DIR}/build.sh --version 2.1.0 --arch cpu

scripts/publish-all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -euo pipefail
66

77
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
88

9-
${DIR}/publish.sh --version 1.14.0 --arch eia
9+
${DIR}/publish.sh --version 2.0.0 --arch eia
1010
${DIR}/publish.sh --version 1.15.0 --arch cpu
1111
${DIR}/publish.sh --version 1.15.0 --arch gpu
1212
${DIR}/publish.sh --version 2.1.0 --arch cpu

test/integration/local/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,11 @@ def tag(request, framework_version, processor):
5353
if not image_tag:
5454
image_tag = '{}-{}'.format(framework_version, processor)
5555
return image_tag
56+
57+
58+
@pytest.fixture(autouse=True)
59+
def skip_by_device_type(request, processor):
60+
is_gpu = processor == "gpu"
61+
if (request.node.get_closest_marker('skip_gpu') and is_gpu) or \
62+
(request.node.get_closest_marker('skip_cpu') and not is_gpu):
63+
pytest.skip('Skipping because running on \'{}\' instance'.format(processor))

test/integration/local/test_container.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def container(request, docker_base_name, tag, runtime_config):
4545
command = (
4646
'docker run {}--name sagemaker-tensorflow-serving-test -p 8080:8080'
4747
' --mount type=volume,source=model_volume,target=/opt/ml/model,readonly'
48-
' -e SAGEMAKER_TFS_DEFAULT_MODEL_NAME=half_plus_three'
4948
' -e SAGEMAKER_TFS_NGINX_LOGLEVEL=info'
5049
' -e SAGEMAKER_BIND_TO_PORT=8080'
5150
' -e SAGEMAKER_SAFE_PORT_RANGE=9000-9999'

test/integration/local/test_multi_model_endpoint.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ def container(request, docker_base_name, tag, runtime_config):
6969
subprocess.check_call('docker rm -f sagemaker-tensorflow-serving-test'.split())
7070

7171

72+
@pytest.mark.skip_gpu
7273
def test_ping():
7374
res = requests.get(PING_URL)
7475
assert res.status_code == 200
7576

7677

78+
@pytest.mark.skip_gpu
7779
def test_container_start_invocation_fail():
7880
x = {
7981
'instances': [1.0, 2.0, 5.0]
@@ -84,13 +86,15 @@ def test_container_start_invocation_fail():
8486
assert "Model half_plus_three is not loaded yet." in str(y)
8587

8688

89+
@pytest.mark.skip_gpu
8790
def test_list_models_empty():
8891
code, res = make_list_model_request()
8992
res = json.loads(res)
9093
assert code == 200
9194
assert len(res) == 0
9295

9396

97+
@pytest.mark.skip_gpu
9498
def test_delete_unloaded_model():
9599
# unloads the given model/version, no-op if not loaded
96100
model_name = 'non-existing-model'
@@ -99,6 +103,7 @@ def test_delete_unloaded_model():
99103
assert 'Model {} is not loaded yet'.format(model_name) in res
100104

101105

106+
@pytest.mark.skip_gpu
102107
def test_delete_model():
103108
model_name = 'half_plus_three'
104109
model_data = {
@@ -125,6 +130,7 @@ def test_delete_model():
125130
assert 'Model {} is not loaded yet.'.format(model_name) in str(y2)
126131

127132

133+
@pytest.mark.skip_gpu
128134
def test_load_two_models():
129135
model_name_1 = 'half_plus_two'
130136
model_data_1 = {
@@ -165,6 +171,7 @@ def test_load_two_models():
165171
assert len(res3) == 2
166172

167173

174+
@pytest.mark.skip_gpu
168175
def test_load_one_model_two_times():
169176
model_name = 'cifar'
170177
model_data = {
@@ -180,6 +187,7 @@ def test_load_one_model_two_times():
180187
assert'Model {} is already loaded'.format(model_name) in res2
181188

182189

190+
@pytest.mark.skip_gpu
183191
def test_load_non_existing_model():
184192
model_name = 'non-existing'
185193
base_path = '/opt/ml/models/non-existing'
@@ -192,6 +200,7 @@ def test_load_non_existing_model():
192200
assert 'Could not find valid base path {} for servable {}'.format(base_path, model_name) in str(res)
193201

194202

203+
@pytest.mark.skip_gpu
195204
def test_bad_model_reqeust():
196205
bad_model_data = {
197206
'model_name': 'model_name',
@@ -201,6 +210,7 @@ def test_bad_model_reqeust():
201210
assert code == 500
202211

203212

213+
@pytest.mark.skip_gpu
204214
def test_invalid_model_version():
205215
model_name = 'invalid_version'
206216
base_path = '/opt/ml/models/invalid_version'

test/integration/local/test_pre_post_processing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def container(volume, docker_base_name, tag, runtime_config):
5353
command = (
5454
'docker run {}--name sagemaker-tensorflow-serving-test -p 8080:8080'
5555
' --mount type=volume,source={},target=/opt/ml/model,readonly'
56-
' -e SAGEMAKER_TFS_DEFAULT_MODEL_NAME=half_plus_three'
5756
' -e SAGEMAKER_TFS_NGINX_LOGLEVEL=info'
5857
' -e SAGEMAKER_BIND_TO_PORT=8080'
5958
' -e SAGEMAKER_SAFE_PORT_RANGE=9000-9999'

test/integration/local/test_pre_post_processing_mme.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,21 @@ def model():
9292
return MODEL_NAME
9393

9494

95+
@pytest.mark.skip_gpu
9596
def test_ping_service():
9697
response = requests.get(PING_URL)
9798
assert 200 == response.status_code
9899

99100

101+
@pytest.mark.skip_gpu
100102
def test_predict_json(model):
101103
headers = make_headers()
102104
data = '{"instances": [1.0, 2.0, 5.0]}'
103105
response = requests.post(INVOCATION_URL.format(model), data=data, headers=headers).json()
104106
assert response == {'predictions': [3.5, 4.0, 5.5]}
105107

106108

109+
@pytest.mark.skip_gpu
107110
def test_zero_content():
108111
headers = make_headers()
109112
x = ''
@@ -112,6 +115,7 @@ def test_zero_content():
112115
assert 'document is empty' in response.text
113116

114117

118+
@pytest.mark.skip_gpu
115119
def test_large_input():
116120
data_file = 'test/resources/inputs/test-large.csv'
117121

@@ -123,13 +127,15 @@ def test_large_input():
123127
assert len(predictions) == 753936
124128

125129

130+
@pytest.mark.skip_gpu
126131
def test_csv_input():
127132
headers = make_headers(content_type='text/csv')
128133
data = '1.0,2.0,5.0'
129134
response = requests.post(INVOCATION_URL.format(MODEL_NAME), data=data, headers=headers).json()
130135
assert response == {'predictions': [3.5, 4.0, 5.5]}
131136

132137

138+
@pytest.mark.skip_gpu
133139
def test_unsupported_content_type():
134140
headers = make_headers('unsupported-type', 'predict')
135141
data = 'aW1hZ2UgYnl0ZXM='

test/integration/local/test_tfs_batching.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def test_run_tfs_with_batching_parameters(docker_base_name, tag, runtime_config)
4141
' -e SAGEMAKER_TFS_BATCH_TIMEOUT_MICROS=500'
4242
' -e SAGEMAKER_TFS_NUM_BATCH_THREADS=100'
4343
' -e SAGEMAKER_TFS_MAX_ENQUEUED_BATCHES=1'
44-
' -e SAGEMAKER_TFS_DEFAULT_MODEL_NAME=half_plus_three'
4544
' -e SAGEMAKER_TFS_NGINX_LOGLEVEL=info'
4645
' -e SAGEMAKER_BIND_TO_PORT=8080'
4746
' -e SAGEMAKER_SAFE_PORT_RANGE=9000-9999'

test/integration/sagemaker/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,11 @@ def skip_gpu_instance_restricted_regions(region, instance_type):
121121
if (region in NO_P2_REGIONS and instance_type.startswith('ml.p2')) or \
122122
(region in NO_P3_REGIONS and instance_type.startswith('ml.p3')):
123123
pytest.skip('Skipping GPU test in region {}'.format(region))
124+
125+
126+
@pytest.fixture(autouse=True)
127+
def skip_by_device_type(request, instance_type):
128+
is_gpu = instance_type[3] in ['g', 'p']
129+
if (request.node.get_closest_marker('skip_gpu') and is_gpu) or \
130+
(request.node.get_closest_marker('skip_cpu') and not is_gpu):
131+
pytest.skip('Skipping because running on \'{}\' instance'.format(instance_type))

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ whitelist_externals =
7878
jshint
7979
commands =
8080
jshint docker/build_artifacts/
81+
82+
[pytest]
83+
markers =
84+
skip_gpu: skip test if running on gpu instance

0 commit comments

Comments
 (0)