Skip to content

Commit 7cff1c2

Browse files
authored
Merge branch 'zwei' into v2-docs
2 parents 2186fe7 + 284eddc commit 7cff1c2

File tree

16 files changed

+142
-371
lines changed

16 files changed

+142
-371
lines changed

src/sagemaker/debugger.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,9 @@
2323

2424
import smdebug_rulesconfig as rule_configs # noqa: F401 # pylint: disable=unused-import
2525

26-
from sagemaker.utils import get_ecr_image_uri_prefix
27-
28-
RULES_ECR_REPO_NAME = "sagemaker-debugger-rules"
29-
30-
SAGEMAKER_RULE_CONTAINERS_ACCOUNTS_MAP = {
31-
"eu-north-1": {RULES_ECR_REPO_NAME: "314864569078"},
32-
"me-south-1": {RULES_ECR_REPO_NAME: "986000313247"},
33-
"ap-south-1": {RULES_ECR_REPO_NAME: "904829902805"},
34-
"eu-west-3": {RULES_ECR_REPO_NAME: "447278800020"},
35-
"us-east-2": {RULES_ECR_REPO_NAME: "915447279597"},
36-
"eu-west-1": {RULES_ECR_REPO_NAME: "929884845733"},
37-
"eu-central-1": {RULES_ECR_REPO_NAME: "482524230118"},
38-
"sa-east-1": {RULES_ECR_REPO_NAME: "818342061345"},
39-
"ap-east-1": {RULES_ECR_REPO_NAME: "199566480951"},
40-
"us-east-1": {RULES_ECR_REPO_NAME: "503895931360"},
41-
"ap-northeast-2": {RULES_ECR_REPO_NAME: "578805364391"},
42-
"eu-west-2": {RULES_ECR_REPO_NAME: "250201462417"},
43-
"ap-northeast-1": {RULES_ECR_REPO_NAME: "430734990657"},
44-
"us-west-2": {RULES_ECR_REPO_NAME: "895741380848"},
45-
"us-west-1": {RULES_ECR_REPO_NAME: "685455198987"},
46-
"ap-southeast-1": {RULES_ECR_REPO_NAME: "972752614525"},
47-
"ap-southeast-2": {RULES_ECR_REPO_NAME: "184798709955"},
48-
"ca-central-1": {RULES_ECR_REPO_NAME: "519511493484"},
49-
"cn-north-1": {RULES_ECR_REPO_NAME: "618459771430"},
50-
"cn-northwest-1": {RULES_ECR_REPO_NAME: "658757709296"},
51-
}
26+
from sagemaker import image_uris
27+
28+
framework_name = "debugger"
5229

5330

5431
def get_rule_container_image_uri(region):
@@ -61,9 +38,7 @@ def get_rule_container_image_uri(region):
6138
Returns:
6239
str: Formatted image uri for the given region and the rule container type
6340
"""
64-
registry_id = SAGEMAKER_RULE_CONTAINERS_ACCOUNTS_MAP.get(region).get(RULES_ECR_REPO_NAME)
65-
image_uri_prefix = get_ecr_image_uri_prefix(registry_id, region)
66-
return "{}/{}:latest".format(image_uri_prefix, RULES_ECR_REPO_NAME)
41+
return image_uris.retrieve(framework_name, region)
6742

6843

6944
class Rule(object):

src/sagemaker/estimator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@
2929
from sagemaker.debugger import DebuggerHookConfig
3030
from sagemaker.debugger import TensorBoardOutputConfig # noqa: F401 # pylint: disable=unused-import
3131
from sagemaker.debugger import get_rule_container_image_uri
32-
from sagemaker.s3 import S3Uploader
32+
from sagemaker.s3 import S3Uploader, parse_s3_url
3333

3434
from sagemaker.fw_utils import (
3535
tar_and_upload_dir,
36-
parse_s3_url,
3736
UploadedCode,
3837
validate_source_dir,
3938
_region_supports_debugger,

src/sagemaker/fw_utils.py

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from collections import namedtuple
2222

2323
import sagemaker.utils
24-
from sagemaker import s3
2524

2625
logger = logging.getLogger("sagemaker")
2726

@@ -33,15 +32,6 @@
3332
instantiated with positional or keyword arguments.
3433
"""
3534

36-
EMPTY_FRAMEWORK_VERSION_WARNING = (
37-
"No framework_version specified, defaulting to version {}. "
38-
"framework_version will be required in SageMaker Python SDK v2."
39-
)
40-
LATER_FRAMEWORK_VERSION_WARNING = (
41-
"This is not the latest supported version. "
42-
"If you would like to use version {latest}, "
43-
"please add framework_version={latest} to your constructor."
44-
)
4535
PYTHON_2_DEPRECATION_WARNING = (
4636
"{latest_supported_version} is the latest version of {framework} that supports "
4737
"Python 2. Newer versions of {framework} will only be available for Python 3."
@@ -54,21 +44,10 @@
5444
"fully leverage all GPU cores; the parameter server will be configured to run "
5545
"only one worker per host regardless of the number of GPUs."
5646
)
57-
PARAMETER_V2_RENAME_WARNING = (
58-
"Parameter {v1_parameter_name} will be renamed to {v2_parameter_name} "
59-
"in SageMaker Python SDK v2."
60-
)
61-
62-
63-
EMPTY_FRAMEWORK_VERSION_ERROR = (
64-
"framework_version is required for script mode estimator. "
65-
"Please add framework_version={} to your constructor to avoid this error."
66-
)
6747

48+
DEBUGGER_UNSUPPORTED_REGIONS = ("us-gov-west-1", "us-iso-east-1")
6849
SINGLE_GPU_INSTANCE_TYPES = ("ml.p2.xlarge", "ml.p3.2xlarge")
6950

70-
DEBUGGER_UNSUPPORTED_REGIONS = ["us-gov-west-1", "us-iso-east-1"]
71-
7251

7352
def is_version_equal_or_higher(lowest_version, framework_version):
7453
"""Determine whether the ``framework_version`` is equal to or higher than
@@ -264,20 +243,6 @@ def framework_version_from_tag(image_tag):
264243
return None if tag_match is None else tag_match.group(1)
265244

266245

267-
def parse_s3_url(url):
268-
"""Calls the method with the same name in the s3 module.
269-
270-
:func:~sagemaker.s3.parse_s3_url
271-
272-
Args:
273-
url: A URL, expected with an s3 scheme.
274-
275-
Returns: The return value of s3.parse_s3_url, which is a tuple containing:
276-
str: S3 bucket name str: S3 key
277-
"""
278-
return s3.parse_s3_url(url)
279-
280-
281246
def model_code_key_prefix(code_location_key_prefix, model_name, image):
282247
"""Returns the s3 key prefix for uploading code during model deployment
283248
The location returned is a potential concatenation of 2 parts
@@ -294,26 +259,6 @@ def model_code_key_prefix(code_location_key_prefix, model_name, image):
294259
return "/".join(filter(None, [code_location_key_prefix, model_name or training_job_name]))
295260

296261

297-
def empty_framework_version_warning(default_version, latest_version):
298-
"""
299-
Args:
300-
default_version:
301-
latest_version:
302-
"""
303-
msgs = [EMPTY_FRAMEWORK_VERSION_WARNING.format(default_version)]
304-
if default_version != latest_version:
305-
msgs.append(later_framework_version_warning(latest_version))
306-
return " ".join(msgs)
307-
308-
309-
def later_framework_version_warning(latest_version):
310-
"""
311-
Args:
312-
latest_version:
313-
"""
314-
return LATER_FRAMEWORK_VERSION_WARNING.format(latest=latest_version)
315-
316-
317262
def warn_if_parameter_server_with_multi_gpu(training_instance_type, distribution):
318263
"""Warn the user that training will not fully leverage all the GPU
319264
cores if parameter server is enabled and a multi-GPU instance is selected.
@@ -363,17 +308,6 @@ def python_deprecation_warning(framework, latest_supported_version):
363308
)
364309

365310

366-
def parameter_v2_rename_warning(v1_parameter_name, v2_parameter_name):
367-
"""
368-
Args:
369-
v1_parameter_name: parameter name used in SageMaker Python SDK v1
370-
v2_parameter_name: parameter name used in SageMaker Python SDK v2
371-
"""
372-
return PARAMETER_V2_RENAME_WARNING.format(
373-
v1_parameter_name=v1_parameter_name, v2_parameter_name=v2_parameter_name
374-
)
375-
376-
377311
def _region_supports_debugger(region_name):
378312
"""Returns boolean indicating whether the region supports Amazon SageMaker Debugger.
379313
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"scope": ["debugger"],
3+
"versions": {
4+
"latest": {
5+
"registries": {
6+
"ap-east-1": "199566480951",
7+
"ap-northeast-1": "430734990657",
8+
"ap-northeast-2": "578805364391",
9+
"ap-south-1": "904829902805",
10+
"ap-southeast-1": "972752614525",
11+
"ap-southeast-2": "184798709955",
12+
"ca-central-1": "519511493484",
13+
"cn-north-1": "618459771430",
14+
"cn-northwest-1": "658757709296",
15+
"eu-central-1": "482524230118",
16+
"eu-north-1": "314864569078",
17+
"eu-west-1": "929884845733",
18+
"eu-west-2": "250201462417",
19+
"eu-west-3": "447278800020",
20+
"me-south-1": "986000313247",
21+
"sa-east-1": "818342061345",
22+
"us-east-1": "199566480951",
23+
"us-east-2": "915447279597",
24+
"us-west-1": "685455198987",
25+
"us-west-2": "895741380848"
26+
},
27+
"repository": "sagemaker-debugger-rules"
28+
}
29+
}
30+
}

src/sagemaker/image_uri_config/model-monitor.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
"versions": {
44
"": {
55
"registries": {
6-
"eu-north-1": "895015795356",
7-
"me-south-1": "607024016150",
8-
"ap-south-1": "126357580389",
9-
"us-east-2": "777275614652",
10-
"eu-west-1": "468650794304",
11-
"eu-central-1": "048819808253",
12-
"sa-east-1": "539772159869",
136
"ap-east-1": "001633400207",
14-
"us-east-1": "156813124566",
15-
"ap-northeast-2": "709848358524",
16-
"eu-west-2": "749857270468",
17-
"eu-west-3": "680080141114",
187
"ap-northeast-1": "574779866223",
19-
"us-west-2": "159807026194",
20-
"us-west-1": "890145073186",
8+
"ap-northeast-2": "709848358524",
9+
"ap-south-1": "126357580389",
2110
"ap-southeast-1": "245545462676",
2211
"ap-southeast-2": "563025443158",
2312
"ca-central-1": "536280801234",
2413
"cn-north-1": "453000072557",
25-
"cn-northwest-1": "453252182341"
14+
"cn-northwest-1": "453252182341",
15+
"eu-central-1": "048819808253",
16+
"eu-north-1": "895015795356",
17+
"eu-west-1": "468650794304",
18+
"eu-west-2": "749857270468",
19+
"eu-west-3": "680080141114",
20+
"me-south-1": "607024016150",
21+
"sa-east-1": "539772159869",
22+
"us-east-1": "156813124566",
23+
"us-east-2": "777275614652",
24+
"us-west-1": "890145073186",
25+
"us-west-2": "159807026194"
2626
},
2727
"repository": "sagemaker-model-monitor-analyzer"
2828
}

src/sagemaker/model.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import os
1919

2020
import sagemaker
21-
from sagemaker import fw_utils, image_uris, local, session, utils, git_utils
22-
from sagemaker.fw_utils import UploadedCode
21+
from sagemaker import fw_utils, image_uris, local, s3, session, utils, git_utils
2322
from sagemaker.transformer import Transformer
2423

2524
LOGGER = logging.getLogger("sagemaker")
@@ -715,7 +714,7 @@ def __init__(
715714
self.git_config = git_config
716715
self.container_log_level = container_log_level
717716
if code_location:
718-
self.bucket, self.key_prefix = fw_utils.parse_s3_url(code_location)
717+
self.bucket, self.key_prefix = s3.parse_s3_url(code_location)
719718
else:
720719
self.bucket, self.key_prefix = None, None
721720
if self.git_config:
@@ -788,7 +787,7 @@ def _upload_code(self, key_prefix, repack=False):
788787
)
789788

790789
self.repacked_model_data = repacked_model_data
791-
self.uploaded_code = UploadedCode(
790+
self.uploaded_code = fw_utils.UploadedCode(
792791
s3_prefix=self.repacked_model_data, script_name=os.path.basename(self.entry_point)
793792
)
794793

src/sagemaker/session.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,29 +3370,6 @@ def __init__(self, seed):
33703370
self.seed = seed
33713371

33723372

3373-
class ModelContainer(object):
3374-
"""Amazon SageMaker Model configurations for inference pipelines.
3375-
3376-
Attributes:
3377-
model_data (str): S3 Model artifact location
3378-
image_uri (str): Docker image URL in ECR
3379-
env (dict[str,str]): Environment variable mapping
3380-
"""
3381-
3382-
def __init__(self, model_data, image_uri, env=None):
3383-
"""Create a definition of a model which can be part of an Inference Pipeline
3384-
3385-
Args:
3386-
model_data (str): The S3 location of a SageMaker model data ``.tar.gz`` file.
3387-
image_uri (str): A Docker image URI.
3388-
env (dict[str, str]): Environment variables to run with ``image_uri`` when hosted in
3389-
SageMaker (default: None).
3390-
"""
3391-
self.model_data = model_data
3392-
self.image_uri = image_uri
3393-
self.env = env
3394-
3395-
33963373
def _create_model_request(
33973374
name, role, container_def=None, tags=None
33983375
): # pylint: disable=redefined-outer-name

0 commit comments

Comments
 (0)