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

Update the PTransform and associated APIs to be less class-based. #17699

Merged
merged 4 commits into from
May 19, 2022

Conversation

robertwb
Copy link
Contributor

This gets us closer to stabilizing the API.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

@robertwb robertwb force-pushed the javascript-no-classes branch from 5b6cc3b to c8e387f Compare May 17, 2022 22:58
@robertwb
Copy link
Contributor Author

robertwb commented May 17, 2022

R: @damccorm

This should be fairly straightforwards, mostly class -> function, capitalization, and deleting new.

@robertwb robertwb force-pushed the javascript-no-classes branch from c8e387f to b0dbc37 Compare May 17, 2022 23:36
Copy link
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

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

This mostly looks good to me - had a few questions/comments + the build is currently failing

sdks/typescript/README.md Outdated Show resolved Hide resolved
}
}

register(urn: string, constructorOrClass: Class<Coder<any>>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is called constructorOrClass, but it has to just be the class, right? Its actually just generally unclear to me why we need this function (vs directly calling registerClass) - are you intending to do some branching here depending on the input type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intent was to accept both here, but I wasn't able to figure out how to cleanly distinguish between the two. Dropping a TODO for now.

}

flatten.urn = "beam:transform:flatten:v1";
Copy link
Contributor

Choose a reason for hiding this comment

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

What are your thoughts on moving this (and other similar urns) into some constant urn file in this or a future PR? I saw this referenced in an earlier file and was confused since you don't see functions with fields assigned to them too often. I'm not a JS expert, but I haven't seen this pattern before (admittedly I also can't find any style guides that mention it positively or negatively)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These URNs are defined in the proto files, but I wasn't sure how to extract them out. This seemed the most natural place to stick it as a convention.

sdks/typescript/src/apache_beam/transforms/windowings.ts Outdated Show resolved Hide resolved
// TODO: (Typescript) Is it possible to type that this takes
// PCollection<{a: T, b: U, ...}> to {a: PCollection<T>, b: PCollection<U>, ...}
// Seems to requires a cast inside expandInternal. But at least the cast is contained there.
export class Split2<T extends { [key: string]: unknown }> extends PTransform<
Copy link
Contributor

Choose a reason for hiding this comment

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

Its not totally clear to me why we had this initially, or why we're now removing Spit - could you help me understand what the split vs split2 distinction was for and why its good to now coallesce the behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I consolidated them because having two primitives that do almost the same thing in slightly different was undesirable. The original Split can be easily implemented in terms of Split2 which is more flexible (and, IMHO, easier to understand).

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, SGTM

}

return withName("flatten", expandInternal);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're missing the withName import

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@robertwb
Copy link
Contributor Author

Thanks. Addressed your comments and fixed the build. PTAL.

Copy link
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@robertwb robertwb merged commit 6e5ca0c into apache:master May 19, 2022
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.

2 participants