Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

Commit 79bde07

Browse files
authored
Update to version v2.0.1
Update to version v2.0.1
2 parents 4d97391 + 482c9d0 commit 79bde07

File tree

7 files changed

+80
-11
lines changed

7 files changed

+80
-11
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.0.1] - 2022-08-12
9+
10+
### Updated
11+
12+
- The AWS IAM Role permissions with the new naming convention for the temporary Amazon SageMaker endpoints used by the Amazon SageMaker Clarify Model Bias Monitor and Amazon SageMaker Clarify Model Explainability Monitor pipelines.
13+
14+
### Fixed
15+
16+
- Environment variables of lambda functions by adding `PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python` to handle `protobuf` library breaking changes in versions greater than `3.20.1`.
17+
18+
- Empty string image url for the model training pipelines when using Amazon SageMaker Model Registry option.
19+
820
## [2.0.0] - 2022-05-31
921

1022
### Added

source/app.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from lib.blueprints.byom.autopilot_training_pipeline import AutopilotJobStack
2323
from lib.blueprints.byom.model_training_pipeline import TrainingJobStack
2424
from lib.aws_sdk_config_aspect import AwsSDKConfigAspect
25+
from lib.protobuf_config_aspect import ProtobufConfigAspect
2526
from lib.blueprints.byom.pipeline_definitions.cdk_context_value import get_cdk_context_value
2627

2728
app = core.App()
@@ -37,6 +38,10 @@
3738
# add AWS_SDK_USER_AGENT env variable to Lambda functions
3839
core.Aspects.of(mlops_stack_single).add(AwsSDKConfigAspect(app, "SDKUserAgentSingle", solution_id, version))
3940

41+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
42+
core.Aspects.of(mlops_stack_single).add(ProtobufConfigAspect(app, "ProtobufConfigSingle"))
43+
44+
4045
mlops_stack_multi = MLOpsStack(
4146
app,
4247
"mlops-workload-orchestrator-multi-account",
@@ -46,6 +51,9 @@
4651

4752
core.Aspects.of(mlops_stack_multi).add(AwsSDKConfigAspect(app, "SDKUserAgentMulti", solution_id, version))
4853

54+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
55+
core.Aspects.of(mlops_stack_multi).add(ProtobufConfigAspect(app, "ProtobufConfigMulti"))
56+
4957
BYOMCustomAlgorithmImageBuilderStack(
5058
app,
5159
"BYOMCustomAlgorithmImageBuilderStack",
@@ -65,6 +73,9 @@
6573

6674
core.Aspects.of(batch_stack).add(AwsSDKConfigAspect(app, "SDKUserAgentBatch", solution_id, version))
6775

76+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
77+
core.Aspects.of(batch_stack).add(ProtobufConfigAspect(app, "ProtobufConfigBatch"))
78+
6879
data_quality_monitor_stack = ModelMonitorStack(
6980
app,
7081
"DataQualityModelMonitorStack",
@@ -76,6 +87,10 @@
7687
AwsSDKConfigAspect(app, "SDKUserAgentDataMonitor", solution_id, version)
7788
)
7889

90+
91+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
92+
core.Aspects.of(data_quality_monitor_stack).add(ProtobufConfigAspect(app, "ProtobufConfigDataMonitor"))
93+
7994
model_quality_monitor_stack = ModelMonitorStack(
8095
app,
8196
"ModelQualityModelMonitorStack",
@@ -87,6 +102,9 @@
87102
AwsSDKConfigAspect(app, "SDKUserAgentModelQuality", solution_id, version)
88103
)
89104

105+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
106+
core.Aspects.of(model_quality_monitor_stack).add(ProtobufConfigAspect(app, "ProtobufConfigModelQuality"))
107+
90108
model_bias_monitor_stack = ModelMonitorStack(
91109
app,
92110
"ModelBiasModelMonitorStack",
@@ -96,6 +114,8 @@
96114

97115
core.Aspects.of(model_bias_monitor_stack).add(AwsSDKConfigAspect(app, "SDKUserAgentModelBias", solution_id, version))
98116

117+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
118+
core.Aspects.of(model_bias_monitor_stack).add(ProtobufConfigAspect(app, "ProtobufConfigModelBias"))
99119

100120
model_explainability_monitor_stack = ModelMonitorStack(
101121
app,
@@ -108,6 +128,8 @@
108128
AwsSDKConfigAspect(app, "SDKUserAgentModelExplainability", solution_id, version)
109129
)
110130

131+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
132+
core.Aspects.of(model_explainability_monitor_stack).add(ProtobufConfigAspect(app, "ProtobufConfigModelExplainability"))
111133

112134
realtime_stack = BYOMRealtimePipelineStack(
113135
app,
@@ -117,6 +139,8 @@
117139

118140
core.Aspects.of(realtime_stack).add(AwsSDKConfigAspect(app, "SDKUserAgentRealtime", solution_id, version))
119141

142+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
143+
core.Aspects.of(realtime_stack).add(ProtobufConfigAspect(app, "ProtobufConfigRealtime"))
120144

121145
autopilot_stack = AutopilotJobStack(
122146
app,
@@ -126,6 +150,8 @@
126150

127151
core.Aspects.of(autopilot_stack).add(AwsSDKConfigAspect(app, "SDKUserAgentAutopilot", solution_id, version))
128152

153+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
154+
core.Aspects.of(autopilot_stack).add(ProtobufConfigAspect(app, "ProtobufConfigAutopilot"))
129155

130156
training_stack = TrainingJobStack(
131157
app,
@@ -136,6 +162,8 @@
136162

137163
core.Aspects.of(training_stack).add(AwsSDKConfigAspect(app, "SDKUserAgentTraining", solution_id, version))
138164

165+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
166+
core.Aspects.of(training_stack).add(ProtobufConfigAspect(app, "ProtobufConfigTraining"))
139167

140168
hyperparameter_tunning_stack = TrainingJobStack(
141169
app,
@@ -148,6 +176,8 @@
148176
AwsSDKConfigAspect(app, "SDKUserAgentHyperparamater", solution_id, version)
149177
)
150178

179+
# add PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python to handle protobuf breaking changes
180+
core.Aspects.of(hyperparameter_tunning_stack).add(ProtobufConfigAspect(app, "ProtobufConfigHyperparamater"))
151181

152182
SingleAccountCodePipelineStack(
153183
app,

source/lambdas/pipeline_orchestration/lambda_helpers.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,7 @@ def get_model_training_specifc_params(event: Dict[str, Any], job_name: str) -> L
447447
return [
448448
("NotificationsSNSTopicArn", os.environ["MLOPS_NOTIFICATIONS_SNS_TOPIC"]),
449449
("JobName", job_name),
450-
(
451-
"ImageUri",
452-
get_image_uri(event.get("pipeline_type"), event, os.environ["REGION"])
453-
if os.environ["USE_MODEL_REGISTRY"] == "No"
454-
else "",
455-
),
450+
("ImageUri", get_image_uri(event.get("pipeline_type"), event, os.environ["REGION"])),
456451
("InstanceType", event.get("instance_type", "ml.m4.xlarge")),
457452
("JobInstanceCount", str(event.get("instance_count", "1"))),
458453
("InstanceVolumeSize", str(event.get("instance_volume_size", "20"))),

source/lib/blueprints/byom/pipeline_definitions/iam_policies.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def sagemaker_policy_statement(is_realtime_pipeline, endpoint_name, endpoint_nam
2929
"sagemaker:DescribeModel", # NOSONAR: permission needs to be repeated for clarity
3030
"sagemaker:DeleteModel",
3131
]
32-
resources = [f"{sagemaker_arn_prefix}:model/mlopssagemakermodel*"]
32+
resources = [
33+
f"{sagemaker_arn_prefix}:model/mlopssagemakermodel*" # NOSONAR: permission needs to be repeated for clarity
34+
]
3335

3436
if is_realtime_pipeline:
3537
# extend actions
@@ -95,8 +97,9 @@ def sagemaker_model_bias_explainability_baseline_job_policy():
9597
"sagemaker:InvokeEndpoint", # NOSONAR: permission needs to be repeated for clarity
9698
],
9799
resources=[
98-
f"{sagemaker_arn_prefix}:endpoint-config/sagemaker-clarify-endpoint-config*",
99-
f"{sagemaker_arn_prefix}:endpoint/sagemaker-clarify-endpoint*",
100+
f"{sagemaker_arn_prefix}:model/mlopssagemakermodel*",
101+
f"{sagemaker_arn_prefix}:endpoint-config/sm-clarify-config*",
102+
f"{sagemaker_arn_prefix}:endpoint/sm-clarify-*",
100103
],
101104
)
102105

@@ -174,6 +177,7 @@ def create_service_role(scope, id, service, description):
174177
def sagemaker_monitor_policy_statement(baseline_job_name, monitoring_schedule_name, endpoint_name, monitoring_type):
175178
# common permissions
176179
actions = [
180+
"sagemaker:DescribeModel",
177181
"sagemaker:DescribeEndpointConfig",
178182
"sagemaker:DescribeEndpoint",
179183
"sagemaker:CreateMonitoringSchedule",
@@ -184,6 +188,7 @@ def sagemaker_monitor_policy_statement(baseline_job_name, monitoring_schedule_na
184188
]
185189
# common resources
186190
resources = [
191+
f"{sagemaker_arn_prefix}:model/mlopssagemakermodel*",
187192
f"{sagemaker_arn_prefix}:endpoint-config/mlopssagemakerendpointconfig*",
188193
f"{sagemaker_arn_prefix}:endpoint/{endpoint_name}",
189194
f"{sagemaker_arn_prefix}:monitoring-schedule/{monitoring_schedule_name}",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# #####################################################################################################################
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
3+
# #
4+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance #
5+
# with the License. A copy of the License is located at #
6+
# #
7+
# http://www.apache.org/licenses/LICENSE-2.0 #
8+
# #
9+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES #
10+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions #
11+
# and limitations under the License. #
12+
# #####################################################################################################################
13+
import jsii
14+
from aws_cdk.core import IAspect, IConstruct, Construct
15+
from aws_cdk.aws_lambda import Function
16+
17+
18+
@jsii.implements(IAspect)
19+
class ProtobufConfigAspect(Construct):
20+
def __init__(self, scope: Construct, id: str):
21+
super().__init__(scope, id)
22+
23+
def visit(self, node: IConstruct):
24+
if isinstance(node, Function):
25+
# this is to handle the protobuf package breaking changes.
26+
node.add_environment(key="PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION", value="python")

source/requirements-test.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ boto3==1.17.23
33
crhelper==2.0.6
44
pytest==6.1.2
55
pytest-cov==2.10.1
6-
moto[all]==2.0.2
6+
moto[all]==2.0.2
7+
protobuf==3.20.*

source/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ aws-solutions-constructs.aws-apigateway-lambda==1.126.0
3131
aws-solutions-constructs.aws-lambda-sagemakerendpoint==1.126.0
3232
aws-solutions-constructs.core==1.126.0
3333
aws-cdk.cloudformation-include==1.126.0
34-
aws-cdk.aws-cloudformation==1.126.0
34+
aws-cdk.aws-cloudformation==1.126.0

0 commit comments

Comments
 (0)