Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated workshop Oct. 2022 #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions assets/deploy-model-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Resources:
Model:
Type: "AWS::SageMaker::Model"
Properties:
ModelName: !Sub ${ModelName}-dev-${TrainJobId}
ModelName: !Sub ${ModelName}-dev
PrimaryContainer:
Image: !Ref ImageRepoUri
ModelDataUrl: !Sub s3://sagemaker-${AWS::Region}-${AWS::AccountId}/${ModelName}/${ModelName}-${TrainJobId}/output/model.tar.gz
Expand All @@ -38,11 +38,11 @@ Resources:
InstanceType: ml.t2.medium
ModelName: !GetAtt Model.ModelName
VariantName: !Sub ${ModelVariant}-${ModelName}
EndpointConfigName: !Sub ${ModelName}-dec-${TrainJobId}
EndpointConfigName: !Sub ${ModelName}-dec
KmsKeyId: !Ref KmsKeyId

Endpoint:
Type: "AWS::SageMaker::Endpoint"
Properties:
EndpointName: !Sub ${ModelName}-dev-${TrainJobId}
EndpointConfigName: !GetAtt EndpointConfig.EndpointConfigName
EndpointName: !Sub ${ModelName}-dev
EndpointConfigName: !GetAtt EndpointConfig.EndpointConfigName
20 changes: 11 additions & 9 deletions assets/deploy-model-prd.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Transform: AWS::Serverless-2016-10-31
Description: Deploy the production Amazon SageMaker Endpoint with Autoscaling, Model Monitoring Schedule and API Gateway Lambda.
Description: Deploy the production Amazon SageMaker Endpoint with Autoscaling, Model
Monitoring Schedule and API Gateway Lambda.
Parameters:
ImageRepoUri:
Type: String
Expand All @@ -23,7 +24,8 @@ Parameters:
Type: Number
Description: The metric alarm threshold
KmsKeyId:
Description: AWS KMS key ID used to encrypt data at rest on the ML storage volume attached to endpoint config and S3 data capture.
Description: AWS KMS key ID used to encrypt data at rest on the ML storage volume
attached to endpoint config and S3 data capture.
Type: String
NotificationArn:
Description: The arn for notification topic
Expand Down Expand Up @@ -81,7 +83,7 @@ Resources:
Model:
Type: "AWS::SageMaker::Model"
Properties:
ModelName: !Sub ${ModelName}-prd-${TrainJobId}
ModelName: !Sub ${ModelName}-prd
PrimaryContainer:
Image: !Ref ImageRepoUri
ModelDataUrl: !Sub s3://sagemaker-${AWS::Region}-${AWS::AccountId}/${ModelName}/${ModelName}-${TrainJobId}/output/model.tar.gz
Expand Down Expand Up @@ -109,13 +111,13 @@ Resources:
EnableCapture: True
InitialSamplingPercentage: 100
KmsKeyId: !Ref KmsKeyId
EndpointConfigName: !Sub ${ModelName}-pec-${TrainJobId}
EndpointConfigName: !Sub ${ModelName}-pec
KmsKeyId: !Ref KmsKeyId

Endpoint:
Type: "AWS::SageMaker::Endpoint"
Properties:
EndpointName: !Sub ${ModelName}-prd-${TrainJobId}
EndpointName: !Sub ${ModelName}-prd
EndpointConfigName: !GetAtt EndpointConfig.EndpointConfigName

ApiFunction:
Expand Down Expand Up @@ -189,7 +191,7 @@ Resources:
PreTrafficLambdaFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "CodeDeployHook_mlops-${ModelName}-PreTrafficLambdaFunction"
FunctionName: !Sub "${ModelName}-PreTrafficLambdaFunction"
CodeUri: ../api
Handler: pre_traffic_hook.lambda_handler
Runtime: python3.7
Expand Down Expand Up @@ -221,7 +223,7 @@ Resources:
PostTrafficLambdaFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "CodeDeployHook_mlops-${ModelName}-PostTrafficLambdaFunction"
FunctionName: !Sub "${ModelName}-PostTrafficLambdaFunction"
CodeUri: ../api
Handler: post_traffic_hook.lambda_handler
Runtime: python3.7
Expand Down Expand Up @@ -351,7 +353,7 @@ Resources:
Properties:
MaxCapacity: 10
MinCapacity: 2
ResourceId: !Sub endpoint/${ModelName}-prd-${TrainJobId}/variant/${ModelVariant}-${ModelName}
ResourceId: !Sub endpoint/${ModelName}-prd/variant/${ModelVariant}-${ModelName}
RoleARN: !Sub arn:aws:iam::${AWS::AccountId}:role/MLOps
ScalableDimension: sagemaker:variant:DesiredInstanceCount
ServiceNamespace: sagemaker
Expand All @@ -362,7 +364,7 @@ Resources:
Properties:
PolicyName: SageMakerVariantInvocationsPerInstance
PolicyType: TargetTrackingScaling
ResourceId: !Sub endpoint/${ModelName}-prd-${TrainJobId}/variant/${ModelVariant}-${ModelName}
ResourceId: !Sub endpoint/${ModelName}-prd/variant/${ModelVariant}-${ModelName}
ScalableDimension: sagemaker:variant:DesiredInstanceCount
ServiceNamespace: sagemaker
TargetTrackingScalingPolicyConfiguration:
Expand Down
2 changes: 1 addition & 1 deletion notebook/mlops.ipynb

Large diffs are not rendered by default.

Binary file added notebook/nyc-tlc.parquet
Binary file not shown.
4 changes: 2 additions & 2 deletions pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Resources:
RepositoryDescription: !Sub SageMaker safe deployment pipeline for project ${SageMakerProjectName} with id ${SageMakerProjectId}, prefix ${ProjectPrefix} and model name ${ModelName}
Code:
S3:
Bucket: "S3_BUCKET_NAME"
Bucket: !Sub "${AWS::AccountId}-pipelineyaml-bucket"
Key: "project.zip"
BranchName: !Ref GitBranch

Expand Down Expand Up @@ -966,4 +966,4 @@ Outputs:
KMSKey:
Value: !Ref KMSKey
NotificationTopic:
Value: !Ref NotificationTopic
Value: !Ref NotificationTopic
6 changes: 6 additions & 0 deletions pipeline_bucket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Resources:
S3Bucket:
Type: 'AWS::S3::Bucket'
DeletionPolicy: Retain
Properties:
BucketName: !Sub "${AWS::AccountId}-pipelineyaml-bucket"