Skip to content

Commit 386d836

Browse files
Merge branch 'master' into ch_integ_tests
2 parents 705ceb9 + e626647 commit 386d836

File tree

20 files changed

+103
-60
lines changed

20 files changed

+103
-60
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ ignore-mixin-members=yes
310310
# (useful for modules/projects where namespaces are manipulated during runtime
311311
# and thus existing member attributes cannot be deduced by static analysis. It
312312
# supports qualified module names, as well as Unix pattern matching.
313-
ignored-modules=distutils
313+
ignored-modules=
314314

315315
# List of class names for which member attributes should not be checked (useful
316316
# for classes with dynamically set attributes). This supports the use of

src/sagemaker/huggingface/model.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,7 @@ def deploy(
334334
container_startup_health_check_timeout=container_startup_health_check_timeout,
335335
inference_recommendation_id=inference_recommendation_id,
336336
explainer_config=explainer_config,
337-
endpoint_logging=kwargs.get("endpoint_logging", False),
338-
endpoint_type=kwargs.get("endpoint_type", None),
339-
resources=kwargs.get("resources", None),
340-
managed_instance_scaling=kwargs.get("managed_instance_scaling", None),
341-
routing_config=kwargs.get("routing_config", None),
337+
**kwargs,
342338
)
343339

344340
def register(

src/sagemaker/jumpstart/cache.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ def _model_id_retrieval_function(
293293
raise KeyError(error_msg)
294294

295295
error_msg = f"Unable to find model manifest for '{model_id}' with version '{version}'. "
296-
error_msg += f"Visit {MODEL_ID_LIST_WEB_URL} for updated list of models. "
296+
error_msg += "Specify a different model ID or try a different AWS Region. "
297+
error_msg += f"For a list of available models, see {MODEL_ID_LIST_WEB_URL}. "
297298

298299
other_model_id_version = None
299300
if model_type == JumpStartModelType.OPEN_WEIGHTS:

src/sagemaker/jumpstart/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
)
3333

3434
INVALID_MODEL_ID_ERROR_MSG = (
35-
"Invalid model ID: '{model_id}'. Please visit "
36-
f"{MODEL_ID_LIST_WEB_URL} for a list of valid model IDs. "
35+
"Invalid model ID: '{model_id}'. Specify a different model ID or try a different AWS Region. "
36+
f"For a list of available models, see {MODEL_ID_LIST_WEB_URL}. "
3737
"The module `sagemaker.jumpstart.notebook_utils` contains utilities for "
3838
"fetching model IDs. We recommend upgrading to the latest version of sagemaker "
3939
"to get access to the most models."

src/sagemaker/jumpstart/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@
5050
)
5151
from sagemaker.session import Session
5252
from sagemaker.config import load_sagemaker_config
53-
from sagemaker.utils import resolve_value_from_config, TagsDict, get_instance_rate_per_hour
53+
from sagemaker.utils import (
54+
resolve_value_from_config,
55+
TagsDict,
56+
get_instance_rate_per_hour,
57+
get_domain_for_region,
58+
)
5459
from sagemaker.workflow import is_pipeline_variable
5560
from sagemaker.user_agent import get_user_agent_extra_suffix
5661

@@ -553,7 +558,7 @@ def get_eula_message(model_specs: JumpStartModelSpecs, region: str) -> str:
553558
return (
554559
f"Model '{model_specs.model_id}' requires accepting end-user license agreement (EULA). "
555560
f"See https://{get_jumpstart_content_bucket(region=region)}.s3.{region}."
556-
f"amazonaws.com{'.cn' if region.startswith('cn-') else ''}"
561+
f"{get_domain_for_region(region)}"
557562
f"/{model_specs.hosting_eula_key} for terms of use."
558563
)
559564

src/sagemaker/local/image.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import tarfile
3131
import tempfile
3232

33-
from distutils.spawn import find_executable
3433
from threading import Thread
3534
from typing import Dict, List
3635
from six.moves.urllib.parse import urlparse
@@ -170,7 +169,7 @@ def _get_compose_cmd_prefix():
170169
compose_cmd_prefix.extend(["docker", "compose"])
171170
return compose_cmd_prefix
172171

173-
if find_executable("docker-compose") is not None:
172+
if shutil.which("docker-compose") is not None:
174173
logger.info("'Docker Compose' found using Docker Compose CLI.")
175174
compose_cmd_prefix.extend(["docker-compose"])
176175
return compose_cmd_prefix

src/sagemaker/local/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import re
2222
import errno
2323

24-
from distutils.dir_util import copy_tree
2524
from six.moves.urllib.parse import urlparse
2625

2726
from sagemaker import s3
@@ -102,7 +101,7 @@ def move_to_destination(source, destination, job_name, sagemaker_session, prefix
102101

103102

104103
def recursive_copy(source, destination):
105-
"""A wrapper around distutils.dir_util.copy_tree.
104+
"""A wrapper around shutil.copy_tree.
106105
107106
This won't throw any exception when the source directory does not exist.
108107
@@ -111,7 +110,7 @@ def recursive_copy(source, destination):
111110
destination (str): destination path
112111
"""
113112
if os.path.isdir(source):
114-
copy_tree(source, destination)
113+
shutil.copytree(source, destination, dirs_exist_ok=True)
115114

116115

117116
def kill_child_processes(pid):

src/sagemaker/utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
from sagemaker.workflow import is_pipeline_variable, is_pipeline_parameter_string
5353
from sagemaker.workflow.entities import PipelineVariable
5454

55+
ALTERNATE_DOMAINS = {
56+
"cn-north-1": "amazonaws.com.cn",
57+
"cn-northwest-1": "amazonaws.com.cn",
58+
"us-iso-east-1": "c2s.ic.gov",
59+
"us-isob-east-1": "sc2s.sgov.gov",
60+
"us-isof-south-1": "csp.hci.ic.gov",
61+
"us-isof-east-1": "csp.hci.ic.gov",
62+
}
63+
5564
ECR_URI_PATTERN = r"^(\d+)(\.)dkr(\.)ecr(\.)(.+)(\.)(.*)(/)(.*:.*)$"
5665
MODEL_PACKAGE_ARN_PATTERN = (
5766
r"arn:aws([a-z\-]*)?:sagemaker:([a-z0-9\-]*):([0-9]{12}):model-package/(.*)"
@@ -1905,3 +1914,12 @@ def remove_tag_with_key(key: str, tags: Optional[Tags]) -> Optional[Tags]:
19051914
if len(updated_tags) == 1:
19061915
return updated_tags[0]
19071916
return updated_tags
1917+
1918+
1919+
def get_domain_for_region(region: str) -> str:
1920+
"""Returns the domain for the given region.
1921+
1922+
Args:
1923+
region (str): AWS region name.
1924+
"""
1925+
return ALTERNATE_DOMAINS.get(region, "amazonaws.com")

src/sagemaker/workflow/_repack_model.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
# is unpacked for inference, the custom entry point will be used.
2828
# Reference: https://docs.aws.amazon.com/sagemaker/latest/dg/amazon-sagemaker-toolkits.html
2929

30-
# distutils.dir_util.copy_tree works way better than the half-baked
31-
# shutil.copytree which bombs on previously existing target dirs...
32-
# alas ... https://bugs.python.org/issue10948
33-
# we'll go ahead and use the copy_tree function anyways because this
34-
# repacking is some short-lived hackery, right??
35-
from distutils.dir_util import copy_tree
36-
3730
from os.path import abspath, realpath, dirname, normpath, join as joinpath
3831

3932
logger = logging.getLogger(__name__)
@@ -188,7 +181,7 @@ def repack(inference_script, model_archive, dependencies=None, source_dir=None):
188181

189182
# copy the "src" dir, which includes the previous training job's model and the
190183
# custom inference script, to the output of this training job
191-
copy_tree(src_dir, "/opt/ml/model")
184+
shutil.copytree(src_dir, "/opt/ml/model", dirs_exist_ok=True)
192185

193186

194187
if __name__ == "__main__": # pragma: no cover

src/sagemaker/workflow/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
logger = logging.getLogger(__name__)
4848

49-
FRAMEWORK_VERSION = "0.23-1"
49+
FRAMEWORK_VERSION = "1.2-1"
5050
INSTANCE_TYPE = "ml.m5.large"
5151
REPACK_SCRIPT = "_repack_model.py"
5252
REPACK_SCRIPT_LAUNCHER = "_repack_script_launcher.sh"

0 commit comments

Comments
 (0)