Skip to content

Commit bed01f5

Browse files
authored
change: use new ECR images in us-iso-east-1 for TF and MXNet (#1050)
1 parent 52c7475 commit bed01f5

File tree

2 files changed

+57
-47
lines changed

2 files changed

+57
-47
lines changed

src/sagemaker/fw_utils.py

+10-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"). You
44
# may not use this file except in compliance with the License. A copy of
@@ -56,22 +56,25 @@
5656
VALID_PY_VERSIONS = ["py2", "py3"]
5757
VALID_EIA_FRAMEWORKS = ["tensorflow", "tensorflow-serving", "mxnet", "mxnet-serving"]
5858
VALID_ACCOUNTS_BY_REGION = {"us-gov-west-1": "246785580436", "us-iso-east-1": "744548109606"}
59+
ASIMOV_VALID_ACCOUNTS_BY_REGION = {"us-iso-east-1": "886529160074"}
5960
OPT_IN_ACCOUNTS_BY_REGION = {"ap-east-1": "057415533634"}
6061
ASIMOV_OPT_IN_ACCOUNTS_BY_REGION = {"ap-east-1": "871362719292"}
6162

6263
MERGED_FRAMEWORKS_REPO_MAP = {
6364
"tensorflow-scriptmode": "tensorflow-training",
64-
"mxnet": "mxnet-training",
6565
"tensorflow-serving": "tensorflow-inference",
6666
"tensorflow-serving-eia": "tensorflow-inference-eia",
67+
"mxnet": "mxnet-training",
68+
"mxnet-serving": "mxnet-inference",
6769
"mxnet-serving-eia": "mxnet-inference-eia",
6870
}
6971

7072
MERGED_FRAMEWORKS_LOWEST_VERSIONS = {
7173
"tensorflow-scriptmode": [1, 13, 1],
72-
"mxnet": [1, 4, 1],
7374
"tensorflow-serving": [1, 13, 0],
7475
"tensorflow-serving-eia": [1, 14, 0],
76+
"mxnet": [1, 4, 1],
77+
"mxnet-serving": [1, 4, 1],
7578
"mxnet-serving-eia": [1, 4, 1],
7679
}
7780

@@ -116,13 +119,9 @@ def _using_merged_images(region, framework, py_version, framework_version):
116119
is_py3 = py_version == "py3" or py_version is None
117120
is_merged_versions = _is_merged_versions(framework, framework_version)
118121
return (
119-
(not is_gov_region)
122+
((not is_gov_region) or region in ASIMOV_VALID_ACCOUNTS_BY_REGION)
120123
and is_merged_versions
121-
and (
122-
is_py3
123-
or _is_tf_14_or_later(framework, framework_version)
124-
or _is_mxnet_serving_141_or_later(framework, framework_version)
125-
)
124+
and (is_py3 or _is_tf_14_or_later(framework, framework_version))
126125
)
127126

128127

@@ -140,24 +139,6 @@ def _is_tf_14_or_later(framework, framework_version):
140139
)
141140

142141

143-
def _is_mxnet_serving_141_or_later(framework, framework_version):
144-
"""
145-
Args:
146-
framework:
147-
framework_version:
148-
"""
149-
asimov_lowest_mxnet = [1, 4, 1]
150-
151-
version = [int(s) for s in framework_version.split(".")]
152-
153-
if len(version) == 2:
154-
version.append(0)
155-
156-
return (
157-
framework.startswith("mxnet-serving") and version >= asimov_lowest_mxnet[0 : len(version)]
158-
)
159-
160-
161142
def _registry_id(region, framework, py_version, account, framework_version):
162143
"""
163144
Args:
@@ -171,6 +152,8 @@ def _registry_id(region, framework, py_version, account, framework_version):
171152
if _using_merged_images(region, framework, py_version, framework_version):
172153
if region in ASIMOV_OPT_IN_ACCOUNTS_BY_REGION:
173154
return ASIMOV_OPT_IN_ACCOUNTS_BY_REGION.get(region)
155+
if region in ASIMOV_VALID_ACCOUNTS_BY_REGION:
156+
return ASIMOV_VALID_ACCOUNTS_BY_REGION.get(region)
174157
return "763104351884"
175158
if region in OPT_IN_ACCOUNTS_BY_REGION:
176159
return OPT_IN_ACCOUNTS_BY_REGION.get(region)

tests/unit/test_fw_utils.py

+47-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"). You
44
# may not use this file except in compliance with the License. A copy of
@@ -150,31 +150,18 @@ def test_tf_eia_images():
150150
image_uri = fw_utils.create_image_uri(
151151
"us-west-2",
152152
"tensorflow-serving",
153-
"ml.p3.2xlarge",
153+
"ml.m4.xlarge",
154154
"1.14.0",
155155
"py3",
156156
accelerator_type="ml.eia1.medium",
157157
)
158158
assert (
159159
image_uri
160-
== "763104351884.dkr.ecr.us-west-2.amazonaws.com/tensorflow-inference-eia:1.14.0-gpu"
160+
== "763104351884.dkr.ecr.us-west-2.amazonaws.com/tensorflow-inference-eia:1.14.0-cpu"
161161
)
162162

163163

164164
def test_mxnet_eia_images():
165-
image_uri = fw_utils.create_image_uri(
166-
"us-west-2",
167-
"mxnet-serving",
168-
"ml.p3.2xlarge",
169-
"1.4.1",
170-
"py2",
171-
accelerator_type="ml.eia1.medium",
172-
)
173-
assert (
174-
image_uri
175-
== "763104351884.dkr.ecr.us-west-2.amazonaws.com/mxnet-inference-eia:1.4.1-gpu-py2"
176-
)
177-
178165
image_uri = fw_utils.create_image_uri(
179166
"us-east-1",
180167
"mxnet-serving",
@@ -218,10 +205,7 @@ def test_create_image_uri_merged():
218205
image_uri = fw_utils.create_image_uri(
219206
"us-west-2", "mxnet-serving", "ml.c4.2xlarge", "1.4.1", "py3"
220207
)
221-
assert (
222-
image_uri
223-
== "520713654638.dkr.ecr.us-west-2.amazonaws.com/sagemaker-mxnet-serving:1.4.1-cpu-py3"
224-
)
208+
assert image_uri == "763104351884.dkr.ecr.us-west-2.amazonaws.com/mxnet-inference:1.4.1-cpu-py3"
225209

226210
image_uri = fw_utils.create_image_uri(
227211
"us-west-2",
@@ -265,6 +249,49 @@ def test_create_image_uri_merged_py2():
265249
)
266250

267251

252+
def test_create_image_uri_merged_gov_regions():
253+
image_uri = fw_utils.create_image_uri(
254+
"us-iso-east-1", "tensorflow-scriptmode", "ml.m4.xlarge", "1.13.1", "py3"
255+
)
256+
assert (
257+
image_uri
258+
== "886529160074.dkr.ecr.us-iso-east-1.c2s.ic.gov/tensorflow-training:1.13.1-cpu-py3"
259+
)
260+
261+
image_uri = fw_utils.create_image_uri(
262+
"us-iso-east-1", "tensorflow-scriptmode", "ml.p3.2xlarge", "1.14", "py2"
263+
)
264+
assert (
265+
image_uri
266+
== "886529160074.dkr.ecr.us-iso-east-1.c2s.ic.gov/tensorflow-training:1.14-gpu-py2"
267+
)
268+
269+
image_uri = fw_utils.create_image_uri(
270+
"us-iso-east-1", "tensorflow-serving", "ml.m4.xlarge", "1.13.0"
271+
)
272+
assert (
273+
image_uri == "886529160074.dkr.ecr.us-iso-east-1.c2s.ic.gov/tensorflow-inference:1.13.0-cpu"
274+
)
275+
276+
image_uri = fw_utils.create_image_uri("us-iso-east-1", "mxnet", "ml.p3.2xlarge", "1.4.1", "py3")
277+
assert image_uri == "886529160074.dkr.ecr.us-iso-east-1.c2s.ic.gov/mxnet-training:1.4.1-gpu-py3"
278+
279+
image_uri = fw_utils.create_image_uri(
280+
"us-iso-east-1", "mxnet-serving", "ml.c4.2xlarge", "1.4.1", "py3"
281+
)
282+
assert (
283+
image_uri == "886529160074.dkr.ecr.us-iso-east-1.c2s.ic.gov/mxnet-inference:1.4.1-cpu-py3"
284+
)
285+
286+
image_uri = fw_utils.create_image_uri(
287+
"us-iso-east-1", "mxnet-serving", "ml.c4.2xlarge", "1.3.1", "py3"
288+
)
289+
assert (
290+
image_uri
291+
== "744548109606.dkr.ecr.us-iso-east-1.c2s.ic.gov/sagemaker-mxnet-serving:1.3.1-cpu-py3"
292+
)
293+
294+
268295
def test_create_image_uri_accelerator_tf():
269296
image_uri = fw_utils.create_image_uri(
270297
MOCK_REGION, "tensorflow", "ml.p3.2xlarge", "1.0", "py3", accelerator_type="ml.eia1.medium"

0 commit comments

Comments
 (0)