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
fix(stepfunctions-tasks): instance type for SageMakerCreateTrainingJob cannot be specified dynamically through JSONPath #15215
Conversation
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 the contribution @JonBlauvelt - it would also be useful for discovery if we update the README to add a comment to the SageMakerCreateTrainingJob
to include a comment with the JSONPath example.
resourceConfig: { | ||
instanceCount: 1, | ||
instanceType: ec2.InstanceType.of(ec2.InstanceClass.P3, ec2.InstanceSize.XLARGE2), | ||
instanceType: new ec2.InstanceType(sfn.JsonPath.stringAt('$.TrainingJob.InstanceType')), | ||
volumeSize: cdk.Size.gibibytes(50), | ||
volumeEncryptionKey: kmsKey, |
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 add a new test for exercising the added control flow rather than to modify an existing test.
we want this one to stay as it is and ensure that it passes doesn't regress.
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'm happy to add a separate test case if required, but I'm not sure it ads any coverage. Here are the reasons why I went this route instead:
- Stays consistent with CreateSageMakerEndpointConfig (added in this similar commit)
- Test case for the path where InstanceType is provided at build time is already covered here.
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 does add coverage because there are 2 scenarios that we want to test here wrt the generated Amazon States Language (ASL) definition:
- providing a literal string as an instance type - the
key
will beInstanceType
in the resource config - providing a dynamic reference as an instance type - the
key
will beInstanceType.$
in the resource config
The prior art here is less reusable because the classes that were initially introduced had an @experimental
annotation, but since those were dropped recently, we want to take some additional measures to ensure we're not regressing.
by switching the test over from literal to dynamic, we're still only capturing 1 out of the 2 scenarios so ideally we have tests that cover both. Let me know if you have any questions.
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.
discussed offline - both of these scenarios are covered in tests as other existing tests already cover the literal string use case.
Makes sense - I'll add that. |
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.
@JonBlauvelt thanks for contributing the 🐛 fix!! 🎉
@Mergifyio refresh |
Command
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
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.
Looks good! To further aid with discoverability, please modify the ResourceConfig docstring to add directions on how to pull it from the task input
aws-cdk/packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/base-types.ts
Lines 206 to 211 in e5c0d59
/** | |
* ML compute instance type. | |
* | |
* @default is the 'm4.xlarge' instance type. | |
*/ | |
readonly instanceType: ec2.InstanceType; |
oh and please add a summary of your changes in the PR description so it can be recorded in the merged commit |
Done. |
…eMakerCreateTrainingJob task, fixes #11928
Updated. |
Pull request has been modified.
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/base-types.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/base-types.ts
Outdated
Show resolved
Hide resolved
Pull request has been modified.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…b cannot be specified dynamically through JSONPath (aws#15215) SageMakerCreateTrainingJob accepts only a static `InstanceType`. Accept an `InstanceType` that contains a `JsonPath` so that the instance can be set dynamically at runtime. Closes aws#11928 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…b cannot be specified dynamically through JSONPath (aws#15215) SageMakerCreateTrainingJob accepts only a static `InstanceType`. Accept an `InstanceType` that contains a `JsonPath` so that the instance can be set dynamically at runtime. Closes aws#11928 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
SageMakerCreateTrainingJob accepts only a static
InstanceType
. Accept anInstanceType
that contains aJsonPath
so that the instance can be set dynamically at runtime.Closes #11928
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license