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

fix(stepfunctions): map state validation fix #4382

Merged
merged 10 commits into from
Oct 21, 2019

Conversation

apalumbo
Copy link
Contributor

@apalumbo apalumbo commented Oct 5, 2019

Closes #4137, #4417

  • Fixed validation for map state
  • Also added validation for maxConcurremcy

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@apalumbo apalumbo requested a review from eladb as a code owner October 5, 2019 07:36
@mergify
Copy link
Contributor

mergify bot commented Oct 5, 2019

Thanks so much for taking the time to contribute to the AWS CDK ❤️

We will shortly assign someone to review this pull request and help get it
merged. In the meantime, please take a minute to make sure you follow this
checklist
:

  • PR title type(scope): text
    • type: fix, feat, refactor go into CHANGELOG, chore is hidden
    • scope: name of module without aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
    • text: use all lower-case, do not end with a period, do not include issue refs
  • PR Description
    • Rationale: describe rationale of change and approach taken
    • Issues: indicate issues fixed via: fixes #xxx or closes #xxx
    • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Testing
    • Unit test added. Prefer to add a new test rather than modify existing tests
    • CLI or init templates change? Re-run/add CLI integration tests
  • Documentation
    • README: update module README to describe new features
    • API docs: public APIs must be documented. Copy from official AWS docs when possible
    • Design: for significant features, follow design process

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@rhboyd
Copy link
Contributor

rhboyd commented Oct 5, 2019

Why is maxConcurrency mandatory? It should be optional with a default to like 10 or 100 if the user doesn’t supply it.

@apalumbo
Copy link
Contributor Author

apalumbo commented Oct 5, 2019

It is not mandatory, is number | undefined , in this way you have to provide a number or not set a value. null is not permitted , in this way the check if the value is set is easier

@apalumbo apalumbo force-pushed the stepFunctionsMapImplementationFix branch from be89962 to 3eaf502 Compare October 5, 2019 16:28
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@apalumbo
Copy link
Contributor Author

apalumbo commented Oct 6, 2019

@rhboyd The default value for maxConcurrency (if not provided is 0 from the step functions)

You can configure an upper bound on how many concurrent sub-workflows Map executes by adding the MaxConcurrency field. The default value is 0, which places no limit on parallelism and iterations are invoked as concurrently as possible. A MaxConcurrency value of 1 has the effect to invoke the Iterator one element at a time, in the order of their appearance in the input state, and will not start an iteration until the previous iteration has completed execution.

https://aws.amazon.com/blogs/aws/new-step-functions-support-for-dynamic-parallelism/

@rhboyd
Copy link
Contributor

rhboyd commented Oct 6, 2019

Awesome. Thanks for clarifying it. I was trying to read the PR on mobile and I confused myself. +1

@rhboyd
Copy link
Contributor

rhboyd commented Oct 6, 2019

Also, tagging @rix0rrr since he shepherded the original release into production.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@NGL321 NGL321 assigned rix0rrr and unassigned eladb Oct 8, 2019
@yyolk
Copy link

yyolk commented Oct 8, 2019

I tried sync'ing a graph using this branch (only updating node-aws-cdk with npm link), I ended up getting an error about Iterator not being filled, copying this branch's test I also tried something like the following:

m = sfn.Map(
    self,
    logical_name,
    input_path=input_path,
    output_path=output_path,
    max_concurrency=10,
    **kwargs,
)
m.iterator(sfn.Pass(self, "Pass in Map"))

This error'd for the same reason. I figure this is likely because I didn't also upgrade the python packages I import (cdk is only at runtime).

I'm going through that now, running the pack.sh script after installing maven, python-site-packages, and dotnet. I'm also about to rap up for the day, so I'm hoping this gets merged and published before then ;)

@@ -150,10 +150,30 @@ export class Map extends State implements INextable {
* Validate this state
*/
protected validate(): string[] {
if (!!this.iterator) {
return ['Map state must have a non-empty iterator'];
const validateMaxConcurrency = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this needs to be an inner function? I'd rather you extract the logic to test that a number is a positive integer to a function isPositiveInteger() and call that inline in this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok i will move the function outside Map and export it for the test, I will add tests for the function (the samecases I added) but I would like to leave the tests on synth to take care about regressions

@apalumbo apalumbo requested a review from rix0rrr October 10, 2019 18:58
@apalumbo
Copy link
Contributor Author

@rix0rrr It should be ok now

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@apalumbo
Copy link
Contributor Author

apalumbo commented Oct 14, 2019

@rix0rrr Do you think that, is the review it's ok, there is any chance that this will go in the next release? We are waiting for this to complete a feature in one of our projects and it would be great

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Oct 21, 2019

Thank you for contributing! Your pull request is now being automatically merged.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit bbe0380 into aws:master Oct 21, 2019
@sarveshbhagat
Copy link

I tried sync'ing a graph using this branch (only updating node-aws-cdk with npm link), I ended up getting an error about Iterator not being filled, copying this branch's test I also tried something like the following:

m = sfn.Map(
    self,
    logical_name,
    input_path=input_path,
    output_path=output_path,
    max_concurrency=10,
    **kwargs,
)
m.iterator(sfn.Pass(self, "Pass in Map"))

This error'd for the same reason. I figure this is likely because I didn't also upgrade the python packages I import (cdk is only at runtime).

I'm going through that now, running the pack.sh script after installing maven, python-site-packages, and dotnet. I'm also about to rap up for the day, so I'm hoping this gets merged and published before then ;)

Is this working for you?

@Stvad
Copy link

Stvad commented Nov 9, 2019

Should iterator be added to MapProps ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Dynamic StepFunction Dynamic Batching with Map and Iterator
9 participants