Skip to content

Commit

Permalink
Add feedback from @nmussy
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed Jul 1, 2024
1 parent ed0dc07 commit ee3e753
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 35 deletions.
35 changes: 12 additions & 23 deletions packages/@aws-cdk/aws-pipes-targets-alpha/lib/sagemaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,12 @@ export interface SageMakerTargetParameters {
/**
* List of parameter names and values for SageMaker Model Building Pipeline execution.
*
* The Name/Value pairs are passed to start execution of the pipeline.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetsagemakerpipelineparameters.html#cfn-pipes-pipe-pipetargetsagemakerpipelineparameters-pipelineparameterlist
* @default - none
*/
readonly pipelineParameterList?: SageMakerPipelineParameter[];
}

/**
* The name/value pair of a parameter to start execution of a SageMaker Model Building Pipeline.
*
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-kinesisfirehose-deliverystream-processorparameter.html
*/
export interface SageMakerPipelineParameter {
/**
* Name of parameter to start execution of a SageMaker Model Building Pipeline.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-sagemakerpipelineparameter.html#cfn-pipes-pipe-sagemakerpipelineparameter-name
*/
readonly name: string;

/**
* Value of parameter to start execution of a SageMaker Model Building Pipeline.
*
* @ see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-sagemakerpipelineparameter.html#cfn-pipes-pipe-sagemakerpipelineparameter-value
*/
readonly value: string;
readonly pipelineParameterList?: Record<string, string>;
}

/**
Expand All @@ -50,12 +31,14 @@ export interface SageMakerPipelineParameter {
export class SageMakerTarget implements ITarget {
private pipeline: IPipeline;
private sagemakerParameters?: SageMakerTargetParameters;
private pipelineParameterList?: Record<string, string>;
public readonly targetArn: string;

constructor(pipeline: IPipeline, parameters?: SageMakerTargetParameters) {
this.pipeline = pipeline;
this.targetArn = pipeline.pipelineArn;
this.sagemakerParameters = parameters;
this.pipelineParameterList = this.sagemakerParameters?.pipelineParameterList;
}

grantPush(grantee: IRole): void {
Expand All @@ -72,7 +55,13 @@ export class SageMakerTarget implements ITarget {
return {
targetParameters: {
inputTemplate: this.sagemakerParameters.inputTransformation?.bind(pipe).inputTemplate,
sageMakerPipelineParameters: this.sagemakerParameters,
sageMakerPipelineParameters: {
pipelineParameterList: this.pipelineParameterList ?
Object.entries(this.pipelineParameterList).map(([key, value]) => ({
name: key,
value: value,
})) : undefined,
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,9 @@ const targetPipeline = new FakePipeline(stack, 'Pipeline', {
new Pipe(stack, 'Pipe', {
source: new TestSource(sourceQueue),
target: new SageMakerTarget(targetPipeline, {
pipelineParameterList: [
{
name: 'foor',
value: 'bar',
},
],
pipelineParameterList: {
foor: 'bar',
},
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ describe('SageMaker', () => {
it('should have target parameters', () => {
// ARRANGE
const target = new SageMakerTarget(pipeline, {
pipelineParameterList: [
{
name: 'foo',
value: 'bar',
},
],
pipelineParameterList: {
foo: 'bar',
},
});

new Pipe(stack, 'MyPipe', {
Expand Down

0 comments on commit ee3e753

Please sign in to comment.