Skip to content

Commit 2eb2802

Browse files
authored
Merge branch 'master' into fix/remove-unnecessary-get-caller-identity-call
2 parents cad998e + 6c1a3a1 commit 2eb2802

35 files changed

+669
-64
lines changed

CHANGELOG.md

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

3+
## v2.171.0 (2023-07-06)
4+
5+
### Features
6+
7+
* Add PipelineDefinitionConfig to pipelines to toggle custom job …
8+
9+
### Bug Fixes and Other Changes
10+
11+
* Upgrade DJL deepspeed versions
12+
* Remove unused dependency `protobuf3-to-dict`
13+
* skip intelligent volume_size allocation based on instance type if it is a pipeline parameter
14+
315
## v2.170.0 (2023-07-05)
416

517
### Features

VERSION

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

doc/workflows/pipelines/sagemaker.workflow.pipelines.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ Parallelism Configuration
103103
.. autoclass:: sagemaker.workflow.parallelism_config.ParallelismConfiguration
104104
:members:
105105

106+
Pipeline Definition Config
107+
--------------------------
108+
109+
.. autoclass:: sagemaker.workflow.pipeline_definition_config.PipelineDefinitionConfig
110+
106111
Pipeline Experiment Config
107112
--------------------------
108113

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def read_requirements(filename):
5353
"google-pasta",
5454
"numpy>=1.9.0,<2.0",
5555
"protobuf>=3.1,<4.0",
56-
"protobuf3-to-dict>=0.1.5,<1.0",
5756
"smdebug_rulesconfig==1.0.1",
5857
"importlib-metadata>=1.4.0,<5.0",
5958
"packaging>=20.0",

src/sagemaker/clarify.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
},
268268
},
269269
SchemaOptional("seed"): int,
270+
SchemaOptional("features_to_explain"): [Or(int, str)],
270271
},
271272
SchemaOptional("pre_training_bias"): {"methods": Or(str, [str])},
272273
SchemaOptional("post_training_bias"): {"methods": Or(str, [str])},
@@ -1308,6 +1309,7 @@ def __init__(
13081309
num_clusters: Optional[int] = None,
13091310
text_config: Optional[TextConfig] = None,
13101311
image_config: Optional[ImageConfig] = None,
1312+
features_to_explain: Optional[List[Union[str, int]]] = None,
13111313
):
13121314
"""Initializes config for SHAP analysis.
13131315
@@ -1343,6 +1345,14 @@ def __init__(
13431345
text features. Default is None.
13441346
image_config (:class:`~sagemaker.clarify.ImageConfig`): Config for handling image
13451347
features. Default is None.
1348+
features_to_explain: A list of names or indices of dataset features to compute SHAP
1349+
values for. If not provided, SHAP values are computed for all features by default.
1350+
Currently only supported for tabular datasets.
1351+
1352+
Raises:
1353+
ValueError: when ``agg_method`` is invalid, ``baseline`` and ``num_clusters`` are provided
1354+
together, or ``features_to_explain`` is specified when ``text_config`` or
1355+
``image_config`` is provided
13461356
""" # noqa E501 # pylint: disable=c0301
13471357
if agg_method is not None and agg_method not in [
13481358
"mean_abs",
@@ -1376,6 +1386,13 @@ def __init__(
13761386
)
13771387
if image_config:
13781388
_set(image_config.get_image_config(), "image_config", self.shap_config)
1389+
if features_to_explain is not None and (
1390+
text_config is not None or image_config is not None
1391+
):
1392+
raise ValueError(
1393+
"`features_to_explain` is not supported for datasets containing text features or images."
1394+
)
1395+
_set(features_to_explain, "features_to_explain", self.shap_config)
13791396

13801397
def get_explainability_config(self):
13811398
"""Returns a shap config dictionary."""

src/sagemaker/djl_inference/model.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _create_estimator(
196196
image_uri: str,
197197
role: str,
198198
sagemaker_session: Optional[Session],
199-
volume_size: int = 30,
199+
volume_size: int,
200200
vpc_config: Optional[
201201
Dict[
202202
str,
@@ -453,7 +453,9 @@ def partition(
453453
self,
454454
instance_type: str,
455455
s3_output_uri: str = None,
456+
s3_output_prefix: str = "aot-partitioned-checkpoints",
456457
job_name: Optional[str] = None,
458+
volume_size: int = 30,
457459
volume_kms_key: Optional[str] = None,
458460
output_kms_key: Optional[str] = None,
459461
use_spot_instances: bool = False,
@@ -469,8 +471,13 @@ def partition(
469471
artifacts and output files). If not specified, results are
470472
stored to a default bucket. If the bucket with the specific name
471473
does not exist, it will be created.
474+
s3_output_prefix (str): Name of the prefix where all the partitioned
475+
checkpoints to be uploaded. If not provided, the default value is
476+
aot-partitioned-checkpoints.
472477
job_name (str): Training job name. If not specified, a unique training job
473478
name will be created.
479+
volume_size (int): Size in GB of the storage volume to use for
480+
storing input and output data during training (default: 30).
474481
volume_kms_key (str): Optional. KMS key ID for encrypting EBS
475482
volume attached to the training instance (default: None).
476483
output_kms_key (str): Optional. KMS key ID for encrypting the
@@ -499,20 +506,19 @@ def partition(
499506
region_name = self.sagemaker_session.boto_session.region_name
500507
self.image_uri = self.serving_image_uri(region_name)
501508

502-
deploy_key_prefix = fw_utils.model_code_key_prefix(
503-
self.key_prefix, self.name, self.image_uri
504-
)
505509
if s3_output_uri is None:
510+
deploy_key_prefix = fw_utils.model_code_key_prefix(
511+
self.key_prefix, self.name, self.image_uri
512+
)
513+
506514
bucket, deploy_key_prefix = s3.determine_bucket_and_prefix(
507515
bucket=self.bucket,
508516
key_prefix=deploy_key_prefix,
509517
sagemaker_session=self.sagemaker_session,
510518
)
511519
s3_output_uri = s3_path_join("s3://", bucket, deploy_key_prefix)
512-
else:
513-
s3_output_uri = s3_path_join(s3_output_uri, deploy_key_prefix)
514520

515-
self.save_mp_checkpoint_path = s3_path_join(s3_output_uri, "aot-partitioned-checkpoints")
521+
self.save_mp_checkpoint_path = s3_path_join(s3_output_uri, s3_output_prefix)
516522

517523
container_def = self._upload_model_to_s3(upload_as_tar=False)
518524
estimator = _create_estimator(
@@ -521,6 +527,7 @@ def partition(
521527
image_uri=self.image_uri,
522528
role=self.role,
523529
sagemaker_session=self.sagemaker_session,
530+
volume_size=volume_size,
524531
vpc_config=self.vpc_config,
525532
volume_kms_key=volume_kms_key,
526533
output_kms_key=output_kms_key,
@@ -924,7 +931,9 @@ def partition(
924931
self,
925932
instance_type: str,
926933
s3_output_uri: str = None,
934+
s3_output_prefix: str = "aot-partitioned-checkpoints",
927935
job_name: Optional[str] = None,
936+
volume_size: int = 30,
928937
volume_kms_key: Optional[str] = None,
929938
output_kms_key: Optional[str] = None,
930939
use_spot_instances: bool = False,
@@ -940,8 +949,13 @@ def partition(
940949
artifacts and output files). If not specified, results are
941950
stored to a default bucket. If the bucket with the specific name
942951
does not exist, it will be created.
952+
s3_output_prefix (str): Name of the prefix where all the partitioned
953+
checkpoints to be uploaded. If not provided, the default value is
954+
aot-partitioned-checkpoints.
943955
job_name (str): Training job name. If not specified, a unique training job
944956
name will be created.
957+
volume_size (int): Size in GB of the storage volume to use for
958+
storing input and output data during training (default: 30).
945959
volume_kms_key (str): Optional. KMS key ID for encrypting EBS
946960
volume attached to the training instance (default: None).
947961
output_kms_key (str): Optional. KMS key ID for encrypting the
@@ -969,7 +983,9 @@ def partition(
969983
super(DeepSpeedModel, self).partition(
970984
instance_type,
971985
s3_output_uri,
972-
job_name,
986+
s3_output_prefix=s3_output_prefix,
987+
job_name=job_name,
988+
volume_size=volume_size,
973989
volume_kms_key=volume_kms_key,
974990
output_kms_key=output_kms_key,
975991
use_spot_instances=use_spot_instances,
@@ -1096,7 +1112,9 @@ def partition(
10961112
self,
10971113
instance_type: str,
10981114
s3_output_uri: str = None,
1115+
s3_output_prefix: str = "aot-partitioned-checkpoints",
10991116
job_name: Optional[str] = None,
1117+
volume_size: int = 30,
11001118
volume_kms_key: Optional[str] = None,
11011119
output_kms_key: Optional[str] = None,
11021120
use_spot_instances: bool = False,
@@ -1112,8 +1130,13 @@ def partition(
11121130
artifacts and output files). If not specified, results are
11131131
stored to a default bucket. If the bucket with the specific name
11141132
does not exist, it will be created.
1133+
s3_output_prefix (str): Name of the prefix where all the partitioned
1134+
checkpoints to be uploaded. If not provided, the default value is
1135+
aot-partitioned-checkpoints.
11151136
job_name (str): Training job name. If not specified, a unique training job
11161137
name will be created.
1138+
volume_size (int): Size in GB of the storage volume to use for
1139+
storing input and output data during training (default: 30).
11171140
volume_kms_key (str): Optional. KMS key ID for encrypting EBS
11181141
volume attached to the training instance (default: None).
11191142
output_kms_key (str): Optional. KMS key ID for encrypting the

src/sagemaker/image_uri_config/djl-deepspeed.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"us-west-2": "763104351884"
3131
},
3232
"repository": "djl-inference",
33-
"tag_prefix": "0.22.1-deepspeed0.8.3-cu118"
33+
"tag_prefix": "0.22.1-deepspeed0.9.2-cu118"
3434
},
3535
"0.21.0": {
3636
"registries": {

src/sagemaker/model_monitor/clarify_model_monitoring.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def _create_baselining_processor(self):
175175
network_config=self.network_config,
176176
)
177177
baselining_processor.image_uri = self.image_uri
178+
baselining_processor.base_job_name = self.base_job_name
178179
return baselining_processor
179180

180181
def _upload_analysis_config(self, analysis_config, output_s3_uri, job_definition_name):

src/sagemaker/workflow/_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
)
3535
from sagemaker.utils import _save_model, download_file_from_url
3636
from sagemaker.workflow.retry import RetryPolicy
37+
from sagemaker.workflow.utilities import trim_request_dict
3738

3839
if TYPE_CHECKING:
3940
from sagemaker.workflow.step_collections import StepCollection
@@ -412,6 +413,8 @@ def __init__(
412413
@property
413414
def arguments(self) -> RequestType:
414415
"""The arguments dict that are used to call `create_model_package`."""
416+
from sagemaker.workflow.utilities import _pipeline_config
417+
415418
model_name = self.name
416419

417420
if self.step_args:
@@ -492,9 +495,9 @@ def arguments(self) -> RequestType:
492495
if "Description" in request_dict:
493496
request_dict.pop("Description")
494497
logger.warning(warn_msg_template, "Description")
495-
if "ModelPackageName" in request_dict:
496-
request_dict.pop("ModelPackageName")
497-
logger.warning(warn_msg_template, "ModelPackageName")
498+
499+
# Continue to pop job name if not explicitly opted-in via config
500+
request_dict = trim_request_dict(request_dict, "ModelPackageName", _pipeline_config)
498501

499502
return request_dict
500503

src/sagemaker/workflow/automl_step.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from sagemaker.workflow.properties import Properties
2424
from sagemaker.workflow.retry import RetryPolicy
2525
from sagemaker.workflow.steps import ConfigurableRetryStep, CacheConfig, Step, StepTypeEnum
26-
from sagemaker.workflow.utilities import validate_step_args_input
26+
from sagemaker.workflow.utilities import validate_step_args_input, trim_request_dict
2727
from sagemaker.workflow.step_collections import StepCollection
2828

2929

@@ -89,10 +89,11 @@ def arguments(self) -> RequestType:
8989
NOTE: The `CreateAutoMLJob` request is not quite the
9090
args list that workflow needs.
9191
92-
The `AutoMLJobName`, `ModelDeployConfig` and `GenerateCandidateDefinitionsOnly`
92+
`ModelDeployConfig` and `GenerateCandidateDefinitionsOnly`
9393
attribute cannot be included.
9494
"""
9595
from sagemaker.workflow.utilities import execute_job_functions
96+
from sagemaker.workflow.utilities import _pipeline_config
9697

9798
# execute fit function in AutoML with saved parameters,
9899
# and store args in PipelineSession's _context
@@ -114,7 +115,10 @@ def arguments(self) -> RequestType:
114115
request_dict.pop("ModelDeployConfig", None)
115116
if "GenerateCandidateDefinitionsOnly" in request_dict:
116117
request_dict.pop("GenerateCandidateDefinitionsOnly", None)
117-
request_dict.pop("AutoMLJobName", None)
118+
# Continue to pop job name if not explicitly opted-in via config
119+
# AutoML Trims to AutoMLJo-2023-06-23-22-57-39-083
120+
request_dict = trim_request_dict(request_dict, "AutoMLJobName", _pipeline_config)
121+
118122
return request_dict
119123

120124
@property

src/sagemaker/workflow/clarify_check_step.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from sagemaker.workflow.step_collections import StepCollection
4545
from sagemaker.workflow.steps import Step, StepTypeEnum, CacheConfig
4646
from sagemaker.workflow.check_job_config import CheckJobConfig
47+
from sagemaker.workflow.utilities import trim_request_dict
4748

4849
_DATA_BIAS_TYPE = "DATA_BIAS"
4950
_MODEL_BIAS_TYPE = "MODEL_BIAS"
@@ -253,6 +254,8 @@ def __init__(
253254
@property
254255
def arguments(self) -> RequestType:
255256
"""The arguments dict that is used to define the ClarifyCheck step."""
257+
from sagemaker.workflow.utilities import _pipeline_config
258+
256259
normalized_inputs, normalized_outputs = self._baselining_processor._normalize_args(
257260
inputs=[self._processing_params["config_input"], self._processing_params["data_input"]],
258261
outputs=[self._processing_params["result_output"]],
@@ -266,8 +269,8 @@ def arguments(self) -> RequestType:
266269
request_dict = self._baselining_processor.sagemaker_session._get_process_request(
267270
**process_args
268271
)
269-
if "ProcessingJobName" in request_dict:
270-
request_dict.pop("ProcessingJobName")
272+
# Continue to pop job name if not explicitly opted-in via config
273+
request_dict = trim_request_dict(request_dict, "ProcessingJobName", _pipeline_config)
271274

272275
return request_dict
273276

src/sagemaker/workflow/pipeline.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
)
3838
from sagemaker.workflow.execution_variables import ExecutionVariables
3939
from sagemaker.workflow.parameters import Parameter
40+
from sagemaker.workflow.pipeline_definition_config import PipelineDefinitionConfig
4041
from sagemaker.workflow.pipeline_experiment_config import PipelineExperimentConfig
4142
from sagemaker.workflow.parallelism_config import ParallelismConfiguration
4243
from sagemaker.workflow.properties import Properties
@@ -52,6 +53,8 @@
5253
ExecutionVariables.PIPELINE_NAME, ExecutionVariables.PIPELINE_EXECUTION_ID
5354
)
5455

56+
_DEFAULT_DEFINITION_CFG = PipelineDefinitionConfig(use_custom_job_prefix=False)
57+
5558

5659
class Pipeline(Entity):
5760
"""Pipeline for workflow."""
@@ -63,6 +66,7 @@ def __init__(
6366
pipeline_experiment_config: Optional[PipelineExperimentConfig] = _DEFAULT_EXPERIMENT_CFG,
6467
steps: Optional[Sequence[Union[Step, StepCollection]]] = None,
6568
sagemaker_session: Optional[Session] = None,
69+
pipeline_definition_config: Optional[PipelineDefinitionConfig] = _DEFAULT_DEFINITION_CFG,
6670
):
6771
"""Initialize a Pipeline
6872
@@ -84,12 +88,16 @@ def __init__(
8488
sagemaker_session (sagemaker.session.Session): Session object that manages interactions
8589
with Amazon SageMaker APIs and any other AWS services needed. If not specified, the
8690
pipeline creates one using the default AWS configuration chain.
91+
pipeline_definition_config (Optional[PipelineDefinitionConfig]): If set,
92+
the workflow customizes the pipeline definition using the configurations
93+
specified. By default, custom job-prefixing is turned off.
8794
"""
8895
self.name = name
8996
self.parameters = parameters if parameters else []
9097
self.pipeline_experiment_config = pipeline_experiment_config
9198
self.steps = steps if steps else []
9299
self.sagemaker_session = sagemaker_session if sagemaker_session else Session()
100+
self.pipeline_definition_config = pipeline_definition_config
93101

94102
self._version = "2020-12-01"
95103
self._metadata = dict()
@@ -105,7 +113,11 @@ def to_request(self) -> RequestType:
105113
"PipelineExperimentConfig": self.pipeline_experiment_config.to_request()
106114
if self.pipeline_experiment_config is not None
107115
else None,
108-
"Steps": build_steps(self.steps, self.name),
116+
"Steps": build_steps(
117+
self.steps,
118+
self.name,
119+
self.pipeline_definition_config,
120+
),
109121
}
110122

111123
def create(

0 commit comments

Comments
 (0)