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

sagemaker: The YAML template for the PipelineDefinitionBody property is in Upper Camel Case (Pascal Case) while the template generated by the CDK has this property in Camel Case #25774

Closed
JawadAr opened this issue May 29, 2023 · 5 comments
Labels
@aws-cdk/aws-sagemaker Related to AWS SageMaker bug This issue is a bug. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@JawadAr
Copy link

JawadAr commented May 29, 2023

Describe the bug

The YAML template for the AWS::SageMaker::Pipeline resource in the docs is as follows:

Type: AWS::SageMaker::Pipeline
Properties: 
  ParallelismConfiguration: 
    ParallelismConfiguration
  PipelineDefinition: 
    PipelineDefinition
  PipelineDescription: String
  PipelineDisplayName: String
  PipelineName: String
  RoleArn: String
  Tags: 
    - Tag

The PipelineDefinition property is further defined as follows:

  PipelineDefinitionBody: String
  PipelineDefinitionS3Location: 
    S3Location

Which means that a valid template could be:

Type: AWS::SageMaker::Pipeline
Properties: 
  PipelineDefinition: 
      PipelineDefinitionBody: String
  PipelineDescription: String
  PipelineDisplayName: String
  PipelineName: String
  RoleArn: String
  Tags: 
    - Tag

Notice that the property PipelineDefinitionBody is in Pascal Case. But what the CDK generates is:

Type: AWS::SageMaker::Pipeline
Properties: 
  PipelineDefinition: 
      pipelineDefinitionBody: String
  PipelineDescription: String
  PipelineDisplayName: String
  PipelineName: String
  RoleArn: String
  Tags: 
    - Tag

Notice that the property pipelineDefinitionBody is in Camel Case. Which is causing the following error in CloudFormation:

Properties validation failed for resource SampleCfnPipeline with message: #/PipelineDefinition: #: only 1 subschema matches out of 2 #/PipelineDefinition: #: 0 subschemas matched instead of one #/PipelineDefinition: required key [PipelineDefinitionBody] not found #/PipelineDefinition: extraneous key [pipelineDefinitionBody] is not permitted #/PipelineDefinition: required key [PipelineDefinitionS3Location] not found #/PipelineDefinition: extraneous key [pipelineDefinitionBody] is not permitted

The Python stack code for creating the template is as follows:

class MySageMakerStack(Stack):

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)
        
        pipeline_def = sagemaker.CfnPipeline.PipelineDefinitionProperty(
            pipeline_definition_body = "String"
        )

        cfn_pipeline = sagemaker.CfnPipeline(self, "SampleCfnPipeline",
            pipeline_definition=pipeline_def,
            pipeline_name="String",
            role_arn="String",
            pipeline_description="String",
            pipeline_display_name="String"
        )

Any generic code would reproduce the error.

Python CDK version: 2.81.0
CDK ToolKit version: 2.81.0
Machine: Macbook Pro 2020, 13-inch
OS: Ventura 13.0.1
IDE: VSCode

Expected Behavior

I expected the CDK to generate a valid template for the AWS::SageMaker::Pipeline resource. Which is as follows:

Type: AWS::SageMaker::Pipeline
Properties: 
  PipelineDefinition: 
      PipelineDefinitionBody: String
  PipelineDescription: String
  PipelineDisplayName: String
  PipelineName: String
  RoleArn: String
  Tags: 
    - Tag

Notice that the property PipelineDefinitionBody is in Pascal Case.

Current Behavior

What the CDK currently generates is:

Type: AWS::SageMaker::Pipeline
Properties: 
  PipelineDefinition: 
      pipelineDefinitionBody: String
  PipelineDescription: String
  PipelineDisplayName: String
  PipelineName: String
  RoleArn: String
  Tags: 
    - Tag

Notice that the property pipelineDefinitionBody is in Camel Case.

Reproduction Steps

Use the following stack in python CDK:

class MySageMakerStack(Stack):

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)
        
        pipeline_def = sagemaker.CfnPipeline.PipelineDefinitionProperty(
            pipeline_definition_body = "String"
        )

        cfn_pipeline = sagemaker.CfnPipeline(self, "SampleCfnPipeline",
            pipeline_definition=pipeline_def,
            pipeline_name="String",
            role_arn="String",
            pipeline_description="String",
            pipeline_display_name="String"
        )

Possible Solution

Possibly a typo error in converting from code to YAML.

Additional Information/Context

Python CDK version: 2.81.0
CDK ToolKit version: 2.81.0
Machine: Macbook Pro 2020, 13-inch
OS: Ventura 13.0.1
IDE: VSCode

CDK CLI Version

2.81.0

Framework Version

2.81.0

Node.js Version

18.16.0

OS

Ventura 13.0.1

Language

Python

Language Version

3.9.7

Other information

No response

@JawadAr JawadAr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 29, 2023
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label May 29, 2023
@pahud pahud self-assigned this May 30, 2023
@pahud pahud added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label May 30, 2023
@pahud pahud changed the title CfnPipeline.PipelineDefinitionProperty.PipelineDefinitionBody: The YAML template for the PipelineDefinitionBody property is in Upper Camel Case (Pascal Case) while the template generated by the CDK has this property in Camel Case sagemaker: The YAML template for the PipelineDefinitionBody property is in Upper Camel Case (Pascal Case) while the template generated by the CDK has this property in Camel Case May 30, 2023
@pahud pahud added @aws-cdk/aws-sagemaker Related to AWS SageMaker and removed package/tools Related to AWS CDK Tools or CLI labels May 30, 2023
@pahud
Copy link
Contributor

pahud commented May 30, 2023

Yes I can reproduce it in python but not in TypeScript. This seems to be a bug.

I'll discuss this with the team.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. investigating This issue is being investigated and/or work is in progress to resolve the issue. labels May 30, 2023
@pahud pahud removed their assignment May 30, 2023
@pahud
Copy link
Contributor

pahud commented May 30, 2023

Hi @JawadAr

This is a cfnspec patch issue and we are tracking at #21767

At this moment, you will need to write your CDK in python like this:

sagemaker.CfnPipeline(self, "IssueTriagePyPipeline",
                              pipeline_name="IssueTriagePyPipeline",
                              role_arn="0000000000000000000000000:role/service-role/AmazonSageMaker-ExecutionRole-20210802T151519",
                              pipeline_definition={
                                  "PipelineDefinitionBody": "foo"
                              }
        )

And you should get the synthed resource like

Resources:
  IssueTriagePyPipeline:
    Type: AWS::SageMaker::Pipeline
    Properties:
      PipelineDefinition:
        PipelineDefinitionBody: foo
      PipelineName: IssueTriagePyPipeline
      RoleArn: 0000000000000000000000000:role/service-role/AmazonSageMaker-ExecutionRole-20210802T151519

Let me know if it works for you.

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 30, 2023
@JawadAr
Copy link
Author

JawadAr commented May 30, 2023

Hi @pahud
Yes, I figured this out today. This works, but the best practice is to provide a subclass from that L1 construct, which I am sure will be patched up soon. Thanks! 😊

@pahud
Copy link
Contributor

pahud commented May 30, 2023

closing this issue in favor of the tracking issue at #21767

@pahud pahud closed this as completed May 30, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-sagemaker Related to AWS SageMaker bug This issue is a bug. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants