forked from aws/amazon-sagemaker-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: Update contents of key pipeline notebooks based on latest SDK…
… update (aws#3499) * change: Update contents of key pipeline notebooks based on latest SDK update * Add updated output notebooks Co-authored-by: Dewen Qi <[email protected]>
- Loading branch information
1 parent
d391107
commit b7efbbc
Showing
8 changed files
with
2,510 additions
and
2,807 deletions.
There are no files selected for viewing
355 changes: 237 additions & 118 deletions
355
...ne_build_train_deploy/sagemaker-pipelines-preprocess-train-evaluate-batch-transform.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
2,827 changes: 884 additions & 1,943 deletions
2,827
..._train_deploy/sagemaker-pipelines-preprocess-train-evaluate-batch-transform_outputs.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
import boto3 | ||
import json | ||
|
||
iam = boto3.client('iam') | ||
iam = boto3.client("iam") | ||
|
||
|
||
def create_lambda_role(role_name): | ||
try: | ||
response = iam.create_role( | ||
RoleName = role_name, | ||
AssumeRolePolicyDocument = json.dumps({ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
}, | ||
"Action": "sts:AssumeRole" | ||
} | ||
] | ||
}), | ||
Description='Role for Lambda to call SageMaker functions' | ||
RoleName=role_name, | ||
AssumeRolePolicyDocument=json.dumps( | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": {"Service": "lambda.amazonaws.com"}, | ||
"Action": "sts:AssumeRole", | ||
} | ||
], | ||
} | ||
), | ||
Description="Role for Lambda to call SageMaker functions", | ||
) | ||
|
||
role_arn = response['Role']['Arn'] | ||
role_arn = response["Role"]["Arn"] | ||
|
||
response = iam.attach_role_policy( | ||
RoleName=role_name, | ||
PolicyArn='arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole' | ||
PolicyArn="arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", | ||
) | ||
|
||
response = iam.attach_role_policy( | ||
PolicyArn='arn:aws:iam::aws:policy/AmazonSageMakerFullAccess', | ||
RoleName=role_name | ||
PolicyArn="arn:aws:iam::aws:policy/AmazonSageMakerFullAccess", RoleName=role_name | ||
) | ||
|
||
return role_arn | ||
|
||
except iam.exceptions.EntityAlreadyExistsException: | ||
print(f'Using ARN from existing role: {role_name}') | ||
print(f"Using ARN from existing role: {role_name}") | ||
response = iam.get_role(RoleName=role_name) | ||
return response['Role']['Arn'] | ||
return response["Role"]["Arn"] |
Oops, something went wrong.