From a39a57374f2d28ce46cc2b8f13e7f60fd2fa9df7 Mon Sep 17 00:00:00 2001 From: Chuyang Deng Date: Thu, 30 Jul 2020 09:17:17 -0700 Subject: [PATCH] breaking: use images_uris.retrieve() for Debugger --- src/sagemaker/debugger.py | 33 ++---------- src/sagemaker/image_uri_config/debugger.json | 30 +++++++++++ .../image_uri_config/model-monitor.json | 28 +++++------ .../sagemaker/image_uris/test_debugger.py | 50 +++++++++++++++++++ .../image_uris/test_model_monitor.py | 26 +++++----- 5 files changed, 111 insertions(+), 56 deletions(-) create mode 100644 src/sagemaker/image_uri_config/debugger.json create mode 100644 tests/unit/sagemaker/image_uris/test_debugger.py diff --git a/src/sagemaker/debugger.py b/src/sagemaker/debugger.py index 8e040ca890..d6403eb342 100644 --- a/src/sagemaker/debugger.py +++ b/src/sagemaker/debugger.py @@ -23,32 +23,9 @@ import smdebug_rulesconfig as rule_configs # noqa: F401 # pylint: disable=unused-import -from sagemaker.utils import get_ecr_image_uri_prefix - -RULES_ECR_REPO_NAME = "sagemaker-debugger-rules" - -SAGEMAKER_RULE_CONTAINERS_ACCOUNTS_MAP = { - "eu-north-1": {RULES_ECR_REPO_NAME: "314864569078"}, - "me-south-1": {RULES_ECR_REPO_NAME: "986000313247"}, - "ap-south-1": {RULES_ECR_REPO_NAME: "904829902805"}, - "eu-west-3": {RULES_ECR_REPO_NAME: "447278800020"}, - "us-east-2": {RULES_ECR_REPO_NAME: "915447279597"}, - "eu-west-1": {RULES_ECR_REPO_NAME: "929884845733"}, - "eu-central-1": {RULES_ECR_REPO_NAME: "482524230118"}, - "sa-east-1": {RULES_ECR_REPO_NAME: "818342061345"}, - "ap-east-1": {RULES_ECR_REPO_NAME: "199566480951"}, - "us-east-1": {RULES_ECR_REPO_NAME: "503895931360"}, - "ap-northeast-2": {RULES_ECR_REPO_NAME: "578805364391"}, - "eu-west-2": {RULES_ECR_REPO_NAME: "250201462417"}, - "ap-northeast-1": {RULES_ECR_REPO_NAME: "430734990657"}, - "us-west-2": {RULES_ECR_REPO_NAME: "895741380848"}, - "us-west-1": {RULES_ECR_REPO_NAME: "685455198987"}, - "ap-southeast-1": {RULES_ECR_REPO_NAME: "972752614525"}, - "ap-southeast-2": {RULES_ECR_REPO_NAME: "184798709955"}, - "ca-central-1": {RULES_ECR_REPO_NAME: "519511493484"}, - "cn-north-1": {RULES_ECR_REPO_NAME: "618459771430"}, - "cn-northwest-1": {RULES_ECR_REPO_NAME: "658757709296"}, -} +from sagemaker import image_uris + +framework_name = "debugger" def get_rule_container_image_uri(region): @@ -61,9 +38,7 @@ def get_rule_container_image_uri(region): Returns: str: Formatted image uri for the given region and the rule container type """ - registry_id = SAGEMAKER_RULE_CONTAINERS_ACCOUNTS_MAP.get(region).get(RULES_ECR_REPO_NAME) - image_uri_prefix = get_ecr_image_uri_prefix(registry_id, region) - return "{}/{}:latest".format(image_uri_prefix, RULES_ECR_REPO_NAME) + return image_uris.retrieve(framework_name, region) class Rule(object): diff --git a/src/sagemaker/image_uri_config/debugger.json b/src/sagemaker/image_uri_config/debugger.json new file mode 100644 index 0000000000..41fb0ff6f1 --- /dev/null +++ b/src/sagemaker/image_uri_config/debugger.json @@ -0,0 +1,30 @@ +{ + "scope": ["debugger"], + "versions": { + "latest": { + "registries": { + "ap-east-1": "199566480951", + "ap-northeast-1": "430734990657", + "ap-northeast-2": "578805364391", + "ap-south-1": "904829902805", + "ap-southeast-1": "972752614525", + "ap-southeast-2": "184798709955", + "ca-central-1": "519511493484", + "cn-north-1": "618459771430", + "cn-northwest-1": "658757709296", + "eu-central-1": "482524230118", + "eu-north-1": "314864569078", + "eu-west-1": "929884845733", + "eu-west-2": "250201462417", + "eu-west-3": "447278800020", + "me-south-1": "986000313247", + "sa-east-1": "818342061345", + "us-east-1": "199566480951", + "us-east-2": "915447279597", + "us-west-1": "685455198987", + "us-west-2": "895741380848" + }, + "repository": "sagemaker-debugger-rules" + } + } +} \ No newline at end of file diff --git a/src/sagemaker/image_uri_config/model-monitor.json b/src/sagemaker/image_uri_config/model-monitor.json index 867657e27b..479cd98893 100644 --- a/src/sagemaker/image_uri_config/model-monitor.json +++ b/src/sagemaker/image_uri_config/model-monitor.json @@ -3,26 +3,26 @@ "versions": { "": { "registries": { - "eu-north-1": "895015795356", - "me-south-1": "607024016150", - "ap-south-1": "126357580389", - "us-east-2": "777275614652", - "eu-west-1": "468650794304", - "eu-central-1": "048819808253", - "sa-east-1": "539772159869", "ap-east-1": "001633400207", - "us-east-1": "156813124566", - "ap-northeast-2": "709848358524", - "eu-west-2": "749857270468", - "eu-west-3": "680080141114", "ap-northeast-1": "574779866223", - "us-west-2": "159807026194", - "us-west-1": "890145073186", + "ap-northeast-2": "709848358524", + "ap-south-1": "126357580389", "ap-southeast-1": "245545462676", "ap-southeast-2": "563025443158", "ca-central-1": "536280801234", "cn-north-1": "453000072557", - "cn-northwest-1": "453252182341" + "cn-northwest-1": "453252182341", + "eu-central-1": "048819808253", + "eu-north-1": "895015795356", + "eu-west-1": "468650794304", + "eu-west-2": "749857270468", + "eu-west-3": "680080141114", + "me-south-1": "607024016150", + "sa-east-1": "539772159869", + "us-east-1": "156813124566", + "us-east-2": "777275614652", + "us-west-1": "890145073186", + "us-west-2": "159807026194" }, "repository": "sagemaker-model-monitor-analyzer" } diff --git a/tests/unit/sagemaker/image_uris/test_debugger.py b/tests/unit/sagemaker/image_uris/test_debugger.py new file mode 100644 index 0000000000..d65257bd6c --- /dev/null +++ b/tests/unit/sagemaker/image_uris/test_debugger.py @@ -0,0 +1,50 @@ +# Copyright 2020 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 + +from sagemaker import image_uris +from tests.unit.sagemaker.image_uris import expected_uris, regions + +ACCOUNTS = { + "ap-east-1": "199566480951", + "ap-northeast-1": "430734990657", + "ap-northeast-2": "578805364391", + "ap-south-1": "904829902805", + "ap-southeast-1": "972752614525", + "ap-southeast-2": "184798709955", + "ca-central-1": "519511493484", + "cn-north-1": "618459771430", + "cn-northwest-1": "658757709296", + "eu-central-1": "482524230118", + "eu-north-1": "314864569078", + "eu-west-1": "929884845733", + "eu-west-2": "250201462417", + "eu-west-3": "447278800020", + "me-south-1": "986000313247", + "sa-east-1": "818342061345", + "us-east-1": "199566480951", + "us-east-2": "915447279597", + "us-west-1": "685455198987", + "us-west-2": "895741380848", +} + + +def test_debugger(): + for region in regions.regions(): + if region in ACCOUNTS.keys(): + uri = image_uris.retrieve("debugger", region=region) + + expected = expected_uris.algo_uri( + "sagemaker-debugger-rules", ACCOUNTS[region], region, version="latest" + ) + assert expected == uri diff --git a/tests/unit/sagemaker/image_uris/test_model_monitor.py b/tests/unit/sagemaker/image_uris/test_model_monitor.py index fba0d60958..7b0caeed2b 100644 --- a/tests/unit/sagemaker/image_uris/test_model_monitor.py +++ b/tests/unit/sagemaker/image_uris/test_model_monitor.py @@ -16,26 +16,26 @@ from tests.unit.sagemaker.image_uris import expected_uris, regions ACCOUNTS = { - "eu-north-1": "895015795356", - "me-south-1": "607024016150", - "ap-south-1": "126357580389", - "us-east-2": "777275614652", - "eu-west-1": "468650794304", - "eu-central-1": "048819808253", - "sa-east-1": "539772159869", "ap-east-1": "001633400207", - "us-east-1": "156813124566", - "ap-northeast-2": "709848358524", - "eu-west-2": "749857270468", - "eu-west-3": "680080141114", "ap-northeast-1": "574779866223", - "us-west-2": "159807026194", - "us-west-1": "890145073186", + "ap-northeast-2": "709848358524", + "ap-south-1": "126357580389", "ap-southeast-1": "245545462676", "ap-southeast-2": "563025443158", "ca-central-1": "536280801234", "cn-north-1": "453000072557", "cn-northwest-1": "453252182341", + "eu-central-1": "048819808253", + "eu-north-1": "895015795356", + "eu-west-1": "468650794304", + "eu-west-2": "749857270468", + "eu-west-3": "680080141114", + "me-south-1": "607024016150", + "sa-east-1": "539772159869", + "us-east-1": "156813124566", + "us-east-2": "777275614652", + "us-west-1": "890145073186", + "us-west-2": "159807026194", }