Skip to content

Commit

Permalink
fix(stepfunctions-tasks): instance type cannot be provided to SageMak…
Browse files Browse the repository at this point in the history
…erCreateTransformJob as input path (#15726)

as referred in #11605 in SageMakerCreateTransformJob has the same kind of issue.

similar solution can be found at #11749


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
syeehyn authored Jul 26, 2021
1 parent d9285cb commit 6f2384d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ export class SageMakerCreateTransformJob extends sfn.TaskStateBase {
return {
TransformResources: {
InstanceCount: resources.instanceCount,
InstanceType: 'ml.' + resources.instanceType,
InstanceType: sfn.JsonPath.isEncodedJsonPath(resources.instanceType.toString())
? resources.instanceType.toString() : `ml.${resources.instanceType}`,
...(resources.volumeEncryptionKey ? { VolumeKmsKeyId: resources.volumeEncryptionKey.keyArn } : {}),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,61 @@ test('pass param to transform job', () => {
},
});
});
test('create transform job with instance type supplied as JsonPath', () => {
// WHEN
const task = new SageMakerCreateTransformJob(stack, 'TransformTask', {
transformJobName: 'MyTransformJob',
modelName: 'MyModelName',
transformInput: {
transformDataSource: {
s3DataSource: {
s3Uri: 's3://inputbucket/prefix',
},
},
},
transformOutput: {
s3OutputPath: 's3://outputbucket/prefix',
},
transformResources: {
instanceCount: 1,
instanceType: new ec2.InstanceType(sfn.JsonPath.stringAt('$.InstanceType')),
},
});

// THEN
expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:::sagemaker:createTransformJob',
],
],
},
End: true,
Parameters: {
TransformJobName: 'MyTransformJob',
ModelName: 'MyModelName',
TransformInput: {
DataSource: {
S3DataSource: {
S3Uri: 's3://inputbucket/prefix',
S3DataType: 'S3Prefix',
},
},
},
TransformOutput: {
S3OutputPath: 's3://outputbucket/prefix',
},
TransformResources: {
'InstanceCount': 1,
'InstanceType.$': '$.InstanceType',
},
},
});
});

0 comments on commit 6f2384d

Please sign in to comment.