-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(stepfunctions-tasks): support for sagemaker tasks #6639
Conversation
Closes: aws#6572 Added: - createModel - createEndpointConfig - createEndpoint - updateEndpoint
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
* | ||
* @experimental | ||
*/ | ||
export interface ProductionVariants { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface should be renamed to ProductionVariant instead of ProductionVariants, as it defines one ProductionVariant.
Also defining this interface here will introduce code duplication when PR for L2 sagemaker constructs is merged and ProductionVariant gets into the package. After mentioned PR being live, created step function tasks should use the real defined ProductionVariant in sagemaker instead of introducing another one.
* | ||
* @experimental | ||
*/ | ||
export interface ModelContainer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface should be named ContainerDefinition instead of ModelContainer to be consistent with sagemaker api
Also it should be replaced with ContainerDefinition in sagemaker constructs when #6107 is merged to avoid code duplication
readonly endpointConfigName: string; | ||
|
||
/** | ||
* Isolates the model container. No inbound or outbound network calls can be made to or from the model container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not relevant to the below property
} | ||
|
||
private makePolicyStatements(task: sfn.Task): iam.PolicyStatement[] { | ||
Stack.of(task); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stack.of(task);
is unused in this methods context
const policyStatements = [ | ||
new iam.PolicyStatement({ | ||
actions: ['sagemaker:CreateEndpointConfig'], | ||
resources: ['*'], | ||
}), | ||
new iam.PolicyStatement({ | ||
actions: ['sagemaker:ListTags'], | ||
resources: ['*'] | ||
}), | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to define the resources as follows
const stack = Stack.of(task);
const policyStatements = [
new PolicyStatement({
actions: ['sagemaker:CreateEndpointConfig'],
resources: [
stack.formatArn({
service: 'sagemaker',
resource: 'endpoint-config',
resourceName: '*',
}),
],
}),
new PolicyStatement({
actions: ['sagemaker:ListTags'],
resources: [
stack.formatArn({
service: 'sagemaker',
resource: 'endpoint-config',
resourceName: '*',
}),
],
}),
];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 but I'll also add - given that we know the name of the endpoint config at this point, we should be able to add that to resourceName
and avoid *
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest specifying the resource name as well similar to:
new PolicyStatement({
actions: ['sagemaker:CreateEndpointConfig'],
resources: [
stack.formatArn({
service: 'sagemaker',
resource: 'endpoint-config',
// resource name in sagemaker is lowercase
resourceName: Data.isJsonPathString(this.props.endpointConfigName) ? '*' : `${this.props.endpointConfigName.toLowerCase()}`,
}),
],
}),
Please note that it is essential to convert resource name to lower case as Sagemaker arns lowercase the name by default(for any resource be it training job, endpoint, ,model etc). I found this case undocumented
} | ||
|
||
private makePolicyStatements(task: sfn.Task): iam.PolicyStatement[] { | ||
Stack.of(task); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is unused.
const policyStatements = [ | ||
new iam.PolicyStatement({ | ||
actions: ['sagemaker:createEndpoint'], | ||
resources: ['*'], | ||
}), | ||
new iam.PolicyStatement({ | ||
actions: ['sagemaker:ListTags'], | ||
resources: ['*'] | ||
}) | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to comment for EndpointConfig task
} | ||
|
||
private makePolicyStatements(task: sfn.Task): iam.PolicyStatement[] { | ||
Stack.of(task); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused line
} | ||
|
||
private makePolicyStatements(task: sfn.Task): iam.PolicyStatement[] { | ||
Stack.of(task); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused line
This PR will introduce code repetition if merged before #6107 as it defines interfaces that should come from L2 sagemaker constructs P.S. I've left my suggestions on potential improvements as I've also implemented those tasks as they were required for my project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this PR. This is going to add much value to CDK customers when it's made available.
Given that this is a big one, I wanted to make you aware that this is going to take several iterations and several weeks for it to be ready to be merged.
* `tasks.SagemakerCreateModelTask` -- create a SageMaker model | ||
* `tasks.SagemakerCreateEndpointConfigTask` -- create a SageMaker Endpoint Config | ||
* `tasks.SagemakerCreateEndpointTask` -- create a new SageMaker Endpoint | ||
* `tasks.SagemakerUpdateEndpointTask` -- update an existing SageMaker Endpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide examples for each of these. (see below)
import { Stack } from '@aws-cdk/core'; | ||
import { getResourceArn } from './resource-arn-suffix'; | ||
import { DataCaptureConfig, ProductionVariants } from './sagemaker-task-base-types'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch to using 2 space indent everywhere. From what I can see the rest of the stepfunction-tasks package uses 2-space indent. Follow the same consistency.
import { DataCaptureConfig, ProductionVariants } from './sagemaker-task-base-types'; | ||
|
||
/** | ||
* @experimental |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the following text and to all other modules to which this apply.
* @experimental | |
* @experimental - since the API may change when higher level constructs in the `aws-sagemaker` module is available |
/** | ||
* The request accepts the following data in JSON format. | ||
* | ||
* @default - None | ||
*/ | ||
readonly dataCaptureConfig?: DataCaptureConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see this as a supported parameter here - https://docs.aws.amazon.com/step-functions/latest/dg/connect-sagemaker.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all parameters of the API is supported by step functions. You can only configure the ones that are explicitly mentioned in the stepfunctions document (that I linked above).
It seems to me that DataCaptureConfig
is not supported.
/** | ||
* The service integration pattern indicates different ways to call SageMaker APIs. | ||
* | ||
* The valid value is FIRE_AND_FORGE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
@@ -129,6 +129,51 @@ | |||
"stability": "experimental", | |||
"awslint": { | |||
"exclude": [ | |||
"props-default-doc:@aws-cdk/aws-stepfunctions-tasks.SagemakerUpdateEndpointTaskProps.retainAllVariantProperties", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address all of these exclusions. The general guidance is no new exclusions should be added. It should be rare that we add one here.
const policyStatements = [ | ||
new iam.PolicyStatement({ | ||
actions: ['sagemaker:CreateEndpointConfig'], | ||
resources: ['*'], | ||
}), | ||
new iam.PolicyStatement({ | ||
actions: ['sagemaker:ListTags'], | ||
resources: ['*'] | ||
}), | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 but I'll also add - given that we know the name of the endpoint config at this point, we should be able to add that to resourceName
and avoid *
.
Thanks for your comments on here @Stacy-D. We appreciate all contributions that keep our CDK repo healthy and updated. 😊
I wouldn't be too worried about that yet. It's not clear when PR #6107 would land. |
I'll put out an iteration soon. |
This PR has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Description
I needed support for these SageMaker endpoints for a project I'm working on. I verified this works by using this in my project to create a workflow that creates a training job, updates the model and then updates the endpoint.
Commit Message
feat(stepfunctions-tasks): support for sagemaker tasks (#6639)
closes #6572
End Commit Message
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license