Skip to content

breaking: use images_uris.retrieve() for Debugger #1778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 4 additions & 29 deletions src/sagemaker/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
30 changes: 30 additions & 0 deletions src/sagemaker/image_uri_config/debugger.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
28 changes: 14 additions & 14 deletions src/sagemaker/image_uri_config/model-monitor.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
50 changes: 50 additions & 0 deletions tests/unit/sagemaker/image_uris/test_debugger.py
Original file line number Diff line number Diff line change
@@ -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
26 changes: 13 additions & 13 deletions tests/unit/sagemaker/image_uris/test_model_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}


Expand Down