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

fix(stepfunctions-tasks): instance type for SageMakerCreateTrainingJob cannot be specified dynamically through JSONPath #15215

Merged
merged 4 commits into from Jun 22, 2021

Conversation

JonBlauvelt
Copy link
Contributor

@JonBlauvelt JonBlauvelt commented Jun 20, 2021

SageMakerCreateTrainingJob accepts only a static InstanceType. Accept an InstanceType that contains a JsonPath 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

@gitpod-io
Copy link

gitpod-io bot commented Jun 20, 2021

Copy link
Contributor

@shivlaks shivlaks left a 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.

Comment on lines 180 to 184
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,
Copy link
Contributor

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.

Copy link
Contributor Author

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:

Copy link
Contributor

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:

  1. providing a literal string as an instance type - the key will be InstanceType in the resource config
  2. providing a dynamic reference as an instance type - the key will be InstanceType.$ 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.

Copy link
Contributor

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.

@shivlaks shivlaks changed the title fix(stepfunctions-tasks): Accept ec2.InstanceType of JsonPath for Sag… fix(stepfunctions-tasks): instance type for SageMakerCreateTrainingJob cannot be specified dynamically through JSONPath Jun 20, 2021
@JonBlauvelt
Copy link
Contributor Author

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.

Makes sense - I'll add that.

@mergify mergify bot dismissed shivlaks’s stale review June 21, 2021 16:11

Pull request has been modified.

shivlaks
shivlaks previously approved these changes Jun 22, 2021
Copy link
Contributor

@shivlaks shivlaks left a 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!! 🎉

@mergify mergify bot dismissed shivlaks’s stale review June 22, 2021 16:16

Pull request has been modified.

shivlaks
shivlaks previously approved these changes Jun 22, 2021
@shivlaks
Copy link
Contributor

@Mergifyio refresh

@BenChaimberg BenChaimberg self-requested a review June 22, 2021 17:02
@mergify
Copy link
Contributor

mergify bot commented Jun 22, 2021

Command refresh: success

Pull request refreshed

@mergify
Copy link
Contributor

mergify bot commented Jun 22, 2021

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).

Copy link
Contributor

@BenChaimberg BenChaimberg left a 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

/**
* ML compute instance type.
*
* @default is the 'm4.xlarge' instance type.
*/
readonly instanceType: ec2.InstanceType;

@BenChaimberg
Copy link
Contributor

oh and please add a summary of your changes in the PR description so it can be recorded in the merged commit

@JonBlauvelt
Copy link
Contributor Author

oh and please add a summary of your changes in the PR description so it can be recorded in the merged commit

Done.

@JonBlauvelt
Copy link
Contributor Author

Looks good! To further aid with discoverability, please modify the ResourceConfig docstring to add directions on how to pull it from the task input

/**
* ML compute instance type.
*
* @default is the 'm4.xlarge' instance type.
*/
readonly instanceType: ec2.InstanceType;

Updated.

@mergify mergify bot dismissed stale reviews from shivlaks and BenChaimberg June 22, 2021 18:34

Pull request has been modified.

BenChaimberg
BenChaimberg previously approved these changes Jun 22, 2021
@mergify mergify bot dismissed BenChaimberg’s stale review June 22, 2021 19:08

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Jun 22, 2021

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 896b929
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 9280d95 into aws:master Jun 22, 2021
@mergify
Copy link
Contributor

mergify bot commented Jun 22, 2021

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).

matthewsvu pushed a commit to matthewsvu/aws-cdk that referenced this pull request Jun 22, 2021
…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*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
…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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants