-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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): add support for ModelClientConfig to SageMakerCreateTransformJob #11892
feat(stepfunctions-tasks): add support for ModelClientConfig to SageMakerCreateTransformJob #11892
Conversation
/** | ||
* Configures the timeout and maximum number of retries for processing a transform job invocation. | ||
* | ||
* @default |
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.
No default value is specified on the API page or the description page for the ModelClientConfig.
I have observed that the default value for InvocationsMaxRetries
is 3 in practice, and InvocationsTimeoutInSeconds
is less than 1200 (not sure about the exact value), but could be wrong.
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.
rather than Config, we use the suffix Options
to specify a bag of properties within the CDK.
perhaps this property type should be called ModelClientOptions
and the property modelClientOptions
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'd say that's the value we should document as the default text - if it's not documented we should deploy it and find out :)
@shivlaks : The tests are succeeding now and this PR is ready for review. Looking forward to your recommendations on making this better. |
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/create-transform-job.ts
Show resolved
Hide resolved
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
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/base-types.ts
Outdated
Show resolved
Hide resolved
/** | ||
* Configures the timeout and maximum number of retries for processing a transform job invocation. | ||
* | ||
* @default |
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.
rather than Config, we use the suffix Options
to specify a bag of properties within the CDK.
perhaps this property type should be called ModelClientOptions
and the property modelClientOptions
/** | ||
* Configures the timeout and maximum number of retries for processing a transform job invocation. | ||
* | ||
* @default |
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'd say that's the value we should document as the default text - if it's not documented we should deploy it and find out :)
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/create-transform-job.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/create-transform-job.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/test/sagemaker/create-transform-job.test.ts
Outdated
Show resolved
Hide resolved
* | ||
* @default | ||
*/ | ||
readonly modelClientConfig?: ModelClientConfig; |
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.
is it possible to specify this property through state input? (i.e. a string that says $.field
- if so we might need an enum like class here. if not, you can disregard this comment.
Thanks for your feedback, @shivlaks! Will update the PR shortly with your recommendations. |
281fa26
to
1244b37
Compare
Pull request has been modified.
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.
@setu4993 thanks for the fast turnaround!! - couple of small suggestions.
take a look and let me know if you have any questions. we should be able to get this one merged soon :)
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/base-types.ts
Outdated
Show resolved
Hide resolved
private renderModelClientOptions(config: ModelClientOptions): { [key: string]: any } { | ||
return { | ||
ModelClientConfig: { | ||
InvocationsMaxRetries: config.invocationsMaxRetries ?? 0, |
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 don't think we should explicitly set retries to zero. it feels like a bad default, we should let the service defaults take over (which I think is 3?)
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.
0 is actually the default for retries. Typically, after the first try fails, the job fails. I just ran into it today and so had a chance to confirm it :).
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.
How do you recommend we let the service defaults take over? The reason I added those was to avoid the case when one of invocationsMaxRetries
or invocationsTimeout
was set, but not both. That is the only case when it would get to this function. Maybe simply replace this with: InvocationsMaxRetries: config.invocationsMaxRetries?
would do it?
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.
Updated these to InvocationsMaxRetries: config.invocationsMaxRetries?
and similar for the timeout. So, CDK doesn't set the default values but lets the service-level defaults take over.
Had to revert this because it was failing builds.
Would appreciate any recommendation you have on what to do here given 0 is the default at the service-level.
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.
would it make sense to set it after some basic validation? - i.e. it exists, and is greater than 0
? - otherwise, I think it should be fine if the service defaults are 0. wdyt?
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.
Agree, it should also be < 3, so I can add validations for both > 0 and < 3 to it later today.
return { | ||
ModelClientConfig: { | ||
InvocationsMaxRetries: config.invocationsMaxRetries ?? 0, | ||
InvocationsTimeoutInSeconds: config.invocationsTimeout?.toSeconds() ?? 300, |
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.
similar comment here, rather than explicitly setting one, we should fall back to the service defaults? If it's 300, we're only documenting that behaviour but not explicitly setting it
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.
Makes sense. I was trying to avoid the corner case when only 1 of them is defined. I can update these values based on what I've observed from practice.
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.
is 3 the limit on retries? I was just thinking the > 0 part for validation
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.
Yes, 3 is the limit on the number of retries.
Valid Range: Minimum value of 0. Maximum value of 3.
Pull request has been modified.
@shivlaks : Updated the defaults based on what I observed over a couple batch transform jobs I had a chance to run today. The defaults appear to be 0 retries with 60 second timeout (same as for a SageMaker endpoint). Docs from the endpoint page:
|
const retries = config.invocationsMaxRetries; | ||
if (retries? (retries < 0 || retries > 3): false) { | ||
throw new RangeError(`invocationsMaxRetries should be between 0 and 3, not ${retries}.`); | ||
} | ||
const timeout = config.invocationsTimeout?.toSeconds(); | ||
if (timeout? (timeout < 1 || timeout > 3600): false) { | ||
throw new RangeError(`invocationsTimeout should be between 1 and 3600 seconds, not ${timeout}.`); | ||
} |
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.
Added validation for both the properties based on what is documented on the API page.
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.
almost there! one last thing regarding tokens.
check out my comment and let me know if you have any questions there.
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/create-transform-job.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/sagemaker/create-transform-job.ts
Outdated
Show resolved
Hide resolved
@@ -173,6 +181,23 @@ export class SageMakerCreateTransformJob extends sfn.TaskStateBase { | |||
}; | |||
} | |||
|
|||
private renderModelClientOptions(config: ModelClientOptions): { [key: string]: any } { | |||
const retries = config.invocationsMaxRetries; | |||
if (retries? (retries < 0 || retries > 3): false) { |
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.
these values may be represented as tokens (i.e. if they're passed in as parameters to the stack). we can only validate if they're not tokens, so we would want to add a check that !Token.isUnResolved(retries)
before proceeding with the check
checkout Token.isUnresolved
in the repo for a few examples.
Same comment applies to the timeout.
Co-authored-by: Shiv Lakshminarayan <shivlaks@amazon.com>
Pull request has been modified.
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.
@setu4993 thanks for contributing!!
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). |
Thanks for your support on this, @shivlaks! |
…akerCreateTransformJob (aws#11892) Noticed support for [ModelClientConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTransformJob.html#sagemaker-CreateTransformJob-request-ModelClientConfig) was missing from this particular type of job, so attempted to add it. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Noticed support for ModelClientConfig was missing from this particular type of job, so attempted to add it.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license