Skip to content

aws-stepfunctions-tasks: SageMakerCreateTrainingJob does not correctly support empty inputDataConfig #31132

@Stoggles

Description

@Stoggles

Describe the bug

inputDataconfig is incorrectly marked as a required field on SageMakerCreateTrainingJobProps. Forcing this value to undefined throws a Cannot read properties of undefined error.

An empty list is not accepted by SageMaker:

"1 validation errors detected: Value '[]' at 'inputDataConfig' failed to satisfy constraint: Member must have length greater than or equal to 1 (Service: AmazonSageMaker; Status Code: 400; Error Code: ValidationException; Request ID: 20b3ebdb-d89d-4dbe-882b-377d50058e93; Proxy: null)"

Relevant SageMakerCreateTrainingJob docs: https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html#sagemaker-CreateTrainingJob-request-InputDataConfig

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

A valid SageMakerCreateTrainingJob step function task can be created when inputDataConfig is undefined.

Current Behavior

SageMakerCreateTrainingJob throws an error when inputDataConfig is undefined.

Argument of type '{ trainingJobName: string; algorithmSpecification: { trainingImage: aws_stepfunctions_tasks.DockerImage; trainingInputMode: aws_stepfunctions_tasks.InputMode.FILE; }; outputDataConfig: { ...; }; resourceConfig: { ...; }; stoppingCondition: { ...; }; hyperparameters: {}; }' is not assignable to parameter of type 'SageMakerCreateTrainingJobProps'.
  Property 'inputDataConfig' is missing in type '{ trainingJobName: string; algorithmSpecification: { trainingImage: aws_stepfunctions_tasks.DockerImage; trainingInputMode: aws_stepfunctions_tasks.InputMode.FILE; }; outputDataConfig: { ...; }; resourceConfig: { ...; }; stoppingCondition: { ...; }; hyperparameters: {}; }' but required in type 'SageMakerCreateTrainingJobProps'.ts(2345)

Reproduction Steps

import { Duration, Size } from 'aws-cdk-lib';
import { InstanceType } from 'aws-cdk-lib/aws-ec2';
import { JsonPath } from 'aws-cdk-lib/aws-stepfunctions';
import { DockerImage, InputMode, S3Location, SageMakerCreateTrainingJob } from 'aws-cdk-lib/aws-stepfunctions-tasks';
import { Construct } from 'constructs';

class Workflow extends Construct {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    const sageMakerInvocation = new SageMakerCreateTrainingJob(this, 'Start SageMaker', {
      trainingJobName: JsonPath.stringAt('$.JobName'),
      algorithmSpecification: {
        trainingImage: DockerImage.fromJsonExpression('$.DockerImagePath'),
        trainingInputMode: InputMode.FILE,
      },
      // inputDataConfig: [],
      outputDataConfig: {
        s3OutputLocation: S3Location.fromJsonExpression('$.S3OutputPath'),
      },
      resourceConfig: {
        instanceCount: 1,
        instanceType: new InstanceType(JsonPath.stringAt('$.InstanceType')),
        volumeSize: Size.gibibytes(JsonPath.numberAt('$.InstanceVolumeSize')),
      },
      stoppingCondition: {
        maxRuntime: Duration.seconds(JsonPath.numberAt('$.MaximumJobDuration')),
      },
    });
  }
}

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.151.0 (build b8289e2)

Framework Version

No response

Node.js Version

Node.js v20.12.2

OS

macOS 14.6.1

Language

TypeScript

Language Version

5.5.4

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions