2828
2929UploadedCode = namedtuple ("UserCode" , ["s3_prefix" , "script_name" ])
3030"""sagemaker.fw_utils.UserCode: An object containing the S3 prefix and script name.
31-
3231This is for the source code used for the entry point with an ``Estimator``. It can be
3332instantiated with positional or keyword arguments.
3433"""
5453VALID_PY_VERSIONS = ["py2" , "py3" ]
5554VALID_EIA_FRAMEWORKS = ["tensorflow" , "tensorflow-serving" , "mxnet" , "mxnet-serving" ]
5655VALID_ACCOUNTS_BY_REGION = {"us-gov-west-1" : "246785580436" , "us-iso-east-1" : "744548109606" }
56+ OPT_IN_ACCOUNTS_BY_REGION = {"ap-east-1" : "057415533634" }
57+ ASIMOV_OPT_IN_ACCOUNTS_BY_REGION = {"ap-east-1" : "871362719292" }
5758
5859MERGED_FRAMEWORKS_REPO_MAP = {
5960 "tensorflow-scriptmode" : "tensorflow-training" ,
7374def is_version_equal_or_higher (lowest_version , framework_version ):
7475 """Determine whether the ``framework_version`` is equal to or higher than
7576 ``lowest_version``
76-
7777 Args:
7878 lowest_version (List[int]): lowest version represented in an integer
7979 list
8080 framework_version (str): framework version string
81-
8281 Returns:
8382 bool: Whether or not framework_version is equal to or higher than
8483 lowest_version
@@ -125,7 +124,11 @@ def _registry_id(region, framework, py_version, account, accelerator_type, frame
125124 framework_version:
126125 """
127126 if _using_merged_images (region , framework , py_version , accelerator_type , framework_version ):
127+ if region in ASIMOV_OPT_IN_ACCOUNTS_BY_REGION :
128+ return ASIMOV_OPT_IN_ACCOUNTS_BY_REGION .get (region )
128129 return "763104351884"
130+ if region in OPT_IN_ACCOUNTS_BY_REGION :
131+ return OPT_IN_ACCOUNTS_BY_REGION .get (region )
129132 return VALID_ACCOUNTS_BY_REGION .get (region , account )
130133
131134
@@ -140,7 +143,6 @@ def create_image_uri(
140143 optimized_families = None ,
141144):
142145 """Return the ECR URI of an image.
143-
144146 Args:
145147 region (str): AWS region where the image is uploaded.
146148 framework (str): framework used by the image.
@@ -155,7 +157,6 @@ def create_image_uri(
155157 accelerator_type (str): SageMaker Elastic Inference accelerator type.
156158 optimized_families (str): Instance families for which there exist
157159 specific optimized images.
158-
159160 Returns:
160161 str: The appropriate image URI based on the given parameters.
161162 """
@@ -249,11 +250,9 @@ def _accelerator_type_valid_for_framework(
249250
250251def validate_source_dir (script , directory ):
251252 """Validate that the source directory exists and it contains the user script
252-
253253 Args:
254254 script (str): Script filename.
255255 directory (str): Directory containing the source file.
256-
257256 Raises:
258257 ValueError: If ``directory`` does not exist, is not a directory, or does
259258 not contain ``script``.
@@ -272,18 +271,14 @@ def tar_and_upload_dir(
272271):
273272 """Package source files and upload a compress tar file to S3. The S3
274273 location will be ``s3://<bucket>/s3_key_prefix/sourcedir.tar.gz``.
275-
276274 If directory is an S3 URI, an UploadedCode object will be returned, but
277275 nothing will be uploaded to S3 (this allow reuse of code already in S3).
278-
279276 If directory is None, the script will be added to the archive at
280277 ``./<basename of script>``.
281-
282278 If directory is not None, the (recursive) contents of the directory will
283279 be added to the archive. directory is treated as the base path of the
284280 archive, and the script name is assumed to be a filename or relative path
285281 inside the directory.
286-
287282 Args:
288283 session (boto3.Session): Boto session used to access S3.
289284 bucket (str): S3 bucket to which the compressed file is uploaded.
@@ -296,7 +291,6 @@ def tar_and_upload_dir(
296291 copied into /opt/ml/lib
297292 kms_key (str): Optional. KMS key ID used to upload objects to the bucket
298293 (default: None).
299-
300294 Returns:
301295 sagemaker.fw_utils.UserCode: An object with the S3 bucket and key (S3 prefix) and
302296 script name.
@@ -343,7 +337,6 @@ def _list_files_to_compress(script, directory):
343337def framework_name_from_image (image_name ):
344338 # noinspection LongLine
345339 """Extract the framework and Python version from the image name.
346-
347340 Args:
348341 image_name (str): Image URI, which should be one of the following forms:
349342 legacy:
@@ -354,7 +347,6 @@ def framework_name_from_image(image_name):
354347 '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<fw>:<fw_version>-<device>-<py_ver>'
355348 current:
356349 '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-rl-<fw>:<rl_toolkit><rl_version>-<device>-<py_ver>'
357-
358350 Returns:
359351 tuple: A tuple containing:
360352 str: The framework name str: The Python version str: The image tag
@@ -390,11 +382,9 @@ def framework_name_from_image(image_name):
390382
391383def framework_version_from_tag (image_tag ):
392384 """Extract the framework version from the image tag.
393-
394385 Args:
395386 image_tag (str): Image tag, which should take the form
396387 '<framework_version>-<device>-<py_version>'
397-
398388 Returns:
399389 str: The framework version.
400390 """
@@ -406,10 +396,8 @@ def framework_version_from_tag(image_tag):
406396def parse_s3_url (url ):
407397 """Returns an (s3 bucket, key name/prefix) tuple from a url with an s3
408398 scheme
409-
410399 Args:
411400 url (str):
412-
413401 Returns:
414402 tuple: A tuple containing:
415403 str: S3 bucket name str: S3 key
@@ -422,16 +410,13 @@ def parse_s3_url(url):
422410
423411def model_code_key_prefix (code_location_key_prefix , model_name , image ):
424412 """Returns the s3 key prefix for uploading code during model deployment
425-
426413 The location returned is a potential concatenation of 2 parts
427414 1. code_location_key_prefix if it exists
428415 2. model_name or a name derived from the image
429-
430416 Args:
431417 code_location_key_prefix (str): the s3 key prefix from code_location
432418 model_name (str): the name of the model
433419 image (str): the image from which a default name can be extracted
434-
435420 Returns:
436421 str: the key prefix to be used in uploading code
437422 """
0 commit comments