Skip to content

Commit de08c76

Browse files
authored
Merge branch 'master' into patch-1
2 parents 4262d2d + 2bac010 commit de08c76

File tree

15 files changed

+596
-132
lines changed

15 files changed

+596
-132
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## v2.149.0 (2023-04-25)
4+
5+
### Features
6+
7+
* Support TF2.12 SageMaker DLC
8+
9+
### Bug Fixes and Other Changes
10+
11+
* update the doc for Join function
12+
* change s3UploadMode of sagemaker clarify processing output for computer vision jobs.
13+
14+
### Documentation Changes
15+
16+
* Add Remote Function updates
17+
318
## v2.148.0 (2023-04-20)
419

520
### Features

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.148.1.dev0
1+
2.149.1.dev0

doc/overview.rst

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,32 @@ set default values for. For the full schema, see ``sagemaker.config.config_schem
20212021
    Tags:
20222022
    - Key: 'tag_key'
20232023
      Value: 'tag_value'
2024+
PythonSDK:
2025+
Modules:
2026+
RemoteFunction:
2027+
Dependencies: 'path/to/requirements.txt'
2028+
EnableInterContainerTrafficEncryption: true
2029+
EnvironmentVariables: {'EnvVarKey': 'EnvVarValue'}
2030+
ImageUri: '555555555555.dkr.ecr.us-west-2.amazonaws.com/my-image:latest'
2031+
IncludeLocalWorkDir: true
2032+
InstanceType: 'ml.m5.large'
2033+
JobCondaEnvironment: 'your_conda_env'
2034+
PreExecutionCommands:
2035+
- 'command_1'
2036+
- 'command_2'
2037+
PreExecutionScript: 'path/to/script.sh'
2038+
RoleArn: 'arn:aws:iam::555555555555:role/MyRole'
2039+
S3KmsKeyId: 'yourkmskeyid'
2040+
S3RootUri: 's3://my-bucket/my-project'
2041+
VpcConfig:
2042+
SecurityGroupIds:
2043+
- 'sg123'
2044+
Subnets:
2045+
- 'subnet-1234'
2046+
Tags:
2047+
- Key: 'tag_key'
2048+
Value: 'tag_value'
2049+
VolumeKmsKeyId: 'yourkmskeyid'
20242050
20252051
Configuration file locations
20262052
============================
@@ -2170,8 +2196,8 @@ types support setting defaults with a configuration file.
21702196
- Tags
21712197
- Enable inter-container traffic encryption
21722198
2173-
List of APIs supported
2174-
----------------------
2199+
List of APIs and SDK capabilities supported
2200+
-------------------------------------------
21752201
21762202
Default values for the supported parameters of these APIs apply to
21772203
all create and update calls for that API. For example, if a supported
@@ -2202,6 +2228,10 @@ configuration file.
22022228
Hyperparameter Tuning Job: Supported indirectly via ``TrainingJob`` API. While this API is not directly supported, it includes the training job definition as a parameter.
22032229
If you provide defaults for this parameter as part of the ``TrainingJob`` API, these defaults are also used for Hyperparameter Tuning Job.
22042230
2231+
The following goups of SDK capabilities support defaults with a configuration file.
2232+
2233+
- Remote Function ``@remote decorator``, ``RemoteExecutor```
2234+
22052235
Configuration file resolution
22062236
=============================
22072237
@@ -2413,6 +2443,45 @@ specifically the contents of ``'body': b'{...}`` .
24132443
'query_string': ..., 'method': 'POST', 'headers': {...}, 'body': b'{...}', 'url': 'https://api.sagemaker.us-west-2.amazonaws.com/',
24142444
'context': {...}}
24152445
2446+
2447+
************************************************************
2448+
Run Machine Learning code on SageMaker using remote function
2449+
************************************************************
2450+
2451+
You can integrate your local machine language (ML) code to run in a Amazon SageMaker Training job by wrapping
2452+
your code inside a @remote decorator as shown in the following code example.
2453+
2454+
.. code-block:: python
2455+
2456+
from sagemaker.remote_function import remote
2457+
import numpy as np
2458+
2459+
@remote(instance_type="ml.m5.large")
2460+
def matrix_multiply(a, b):
2461+
return np.matmul(a, b)
2462+
2463+
a = np.array([[1, 0],
2464+
[0, 1]])
2465+
b = np.array([1, 2])
2466+
2467+
assert (matrix_multiply(a, b) == np.array([1,2])).all()
2468+
2469+
The SageMaker Python SDK will automatically translate your existing workspace environment and any associated data
2470+
processing code and datasets into a SageMaker Training job that runs on the SageMaker Training platform.
2471+
You can also activate a persistent cache feature, which will further reduce job start up latency by caching previously
2472+
downloaded dependency packages. This reduction in job latency is greater than the reduction in latency from using
2473+
SageMaker managed warm pools alone. The following sections show you how to wrap your local ML code and tailor your
2474+
experience for your use case including customizing your environment and integrating with SageMaker Experiments.
2475+
2476+
See the `Run your local code as a SageMaker Training job <https://docs.aws.amazon.com/sagemaker/latest/dg/train-remote-decorator.html>`__ for detailed developer guide.
2477+
2478+
Follow is the API specification for methods and classes related to remote function feature.
2479+
2480+
.. toctree::
2481+
:maxdepth: 1
2482+
2483+
remote_function/sagemaker.remote_function.rst
2484+
24162485
***
24172486
FAQ
24182487
***
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Remote function classes and methods specification
2+
=================================================
3+
4+
5+
@remote decorator
6+
-----------------
7+
8+
.. automethod:: sagemaker.remote_function.client.remote
9+
10+
11+
RemoteExcutor
12+
-------------
13+
14+
.. autoclass:: sagemaker.remote_function.RemoteExecutor
15+
:members:
16+
17+
18+
Future
19+
------
20+
21+
.. autoclass:: sagemaker.remote_function.client.Future
22+
:members:
23+
24+
.. automethod:: sagemaker.remote_function.client.list_futures
25+
26+
.. automethod:: sagemaker.remote_function.client.get_future

src/sagemaker/clarify.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import tempfile
2727
from abc import ABC, abstractmethod
2828
from typing import List, Union, Dict, Optional, Any
29-
29+
from enum import Enum
3030
from schema import Schema, And, Use, Or, Optional as SchemaOptional, Regex
3131

3232
from sagemaker import image_uris, s3, utils
@@ -304,6 +304,16 @@
304304
)
305305

306306

307+
class DatasetType(Enum):
308+
"""Enum to store different dataset types supported in the Analysis config file"""
309+
310+
TEXTCSV = "text/csv"
311+
JSONLINES = "application/jsonlines"
312+
JSON = "application/json"
313+
PARQUET = "application/x-parquet"
314+
IMAGE = "application/x-image"
315+
316+
307317
class DataConfig:
308318
"""Config object related to configurations of the input and output dataset."""
309319

@@ -1451,7 +1461,7 @@ def _run(
14511461
source=self._CLARIFY_OUTPUT,
14521462
destination=data_config.s3_output_path,
14531463
output_name="analysis_result",
1454-
s3_upload_mode="EndOfJob",
1464+
s3_upload_mode=ProcessingOutputHandler.get_s3_upload_mode(analysis_config),
14551465
)
14561466

14571467
return super().run(
@@ -2171,6 +2181,33 @@ def _upload_analysis_config(analysis_config_file, s3_output_path, sagemaker_sess
21712181
)
21722182

21732183

2184+
class ProcessingOutputHandler:
2185+
"""Class to handle the parameters for SagemakerProcessor.Processingoutput"""
2186+
2187+
class S3UploadMode(Enum):
2188+
"""Enum values for different uplaod modes to s3 bucket"""
2189+
2190+
CONTINUOUS = "Continuous"
2191+
ENDOFJOB = "EndOfJob"
2192+
2193+
@classmethod
2194+
def get_s3_upload_mode(cls, analysis_config: Dict[str, Any]) -> str:
2195+
"""Fetches s3_upload mode based on the shap_config values
2196+
2197+
Args:
2198+
analysis_config (dict): dict Config following the analysis_config.json format
2199+
2200+
Returns:
2201+
The s3_upload_mode type for the processing output.
2202+
"""
2203+
dataset_type = analysis_config["dataset_type"]
2204+
return (
2205+
ProcessingOutputHandler.S3UploadMode.CONTINUOUS.value
2206+
if dataset_type == DatasetType.IMAGE.value
2207+
else ProcessingOutputHandler.S3UploadMode.ENDOFJOB.value
2208+
)
2209+
2210+
21742211
def _set(value, key, dictionary):
21752212
"""Sets dictionary[key] = value if value is not None."""
21762213
if value is not None:

src/sagemaker/image_uri_config/tensorflow.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,8 @@
20212021
"2.8": "2.8.0",
20222022
"2.9": "2.9.2",
20232023
"2.10": "2.10.1",
2024-
"2.11": "2.11.0"
2024+
"2.11": "2.11.0",
2025+
"2.12": "2.12.0"
20252026
},
20262027
"versions": {
20272028
"1.10.0": {
@@ -3755,6 +3756,37 @@
37553756
"us-west-2": "763104351884"
37563757
},
37573758
"repository": "tensorflow-training"
3759+
},
3760+
"2.12.0": {
3761+
"py_versions": [
3762+
"py310"
3763+
],
3764+
"registries": {
3765+
"af-south-1": "626614931356",
3766+
"ap-east-1": "871362719292",
3767+
"ap-northeast-1": "763104351884",
3768+
"ap-northeast-2": "763104351884",
3769+
"ap-northeast-3": "364406365360",
3770+
"ap-south-1": "763104351884",
3771+
"ap-southeast-1": "763104351884",
3772+
"ap-southeast-2": "763104351884",
3773+
"ap-southeast-3": "907027046896",
3774+
"ap-southeast-4": "457447274322",
3775+
"ca-central-1": "763104351884",
3776+
"eu-central-1": "763104351884",
3777+
"eu-north-1": "763104351884",
3778+
"eu-south-1": "692866216735",
3779+
"eu-west-1": "763104351884",
3780+
"eu-west-2": "763104351884",
3781+
"eu-west-3": "763104351884",
3782+
"me-south-1": "217643126080",
3783+
"sa-east-1": "763104351884",
3784+
"us-east-1": "763104351884",
3785+
"us-east-2": "763104351884",
3786+
"us-west-1": "763104351884",
3787+
"us-west-2": "763104351884"
3788+
},
3789+
"repository": "tensorflow-training"
37583790
}
37593791
}
37603792
}

src/sagemaker/image_uris.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,15 @@ def _config_for_framework_and_scope(framework, image_scope, accelerator_type=Non
369369

370370
def _validate_instance_deprecation(framework, instance_type, version):
371371
"""Check if instance type is deprecated for a certain framework with a certain version"""
372-
if (
373-
framework == "pytorch"
374-
and _get_instance_type_family(instance_type) == "p2"
375-
and Version(version) >= Version("1.13")
376-
):
377-
raise ValueError(
378-
"P2 instances have been deprecated for sagemaker jobs with PyTorch 1.13 and above. "
379-
"For information about supported instance types please refer to "
380-
"https://aws.amazon.com/sagemaker/pricing/"
381-
)
372+
if _get_instance_type_family(instance_type) == "p2":
373+
if (framework == "pytorch" and Version(version) >= Version("1.13")) or (
374+
framework == "tensorflow" and Version(version) >= Version("2.12")
375+
):
376+
raise ValueError(
377+
"P2 instances have been deprecated for sagemaker jobs starting PyTorch 1.13 and TensorFlow 2.12"
378+
"For information about supported instance types please refer to "
379+
"https://aws.amazon.com/sagemaker/pricing/"
380+
)
382381

383382

384383
def _validate_for_suppported_frameworks_and_instance_type(framework, instance_type):

0 commit comments

Comments
 (0)