-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BEAM-3612] Add a shim generator tool #7000
Conversation
R: @aaltay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks good, added a few comments.
@@ -57,6 +57,13 @@ func Generate(w io.Writer, filename, pkg string, ids []string, fset *token.FileS | |||
|
|||
e.Print("*/\n") | |||
data := e.Generate(filename) | |||
if err := write(w, []byte(license)); err != nil { | |||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do generated files need to have a Apache license?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle: probably not.
In practice: the RAT check will likely complain if we don't, when trying to check in the files.
Note: We need to check in the files, since the design of go generate
requires it be invoked manually, and the results are intended to be checked in.
Go says: go generate
is for library authors, not library users.
Similarly, the protos are generated code, but we need to check in their results. (They don't have the license though, but they may pre-date the RAT check).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. But this is strange for the end users of the tool. They do not necessarily need to want to use a this license.
Perhaps a TODO for the future to see if we can resolve this with the RAT tool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given it's an Apache tool generating the code, it's not a huge stretch that it should include the Apache license.
And a user that takes particular umbrage can always use the starcgenx package to write their own tooling to generate the code.
I would happily accept a patch (or spend the 2 minutes necessary to write the code) to flag the license inclusion lines, if a user requested it. I'd rather not speculate on possible usecases, and generalizing/flagging before there's a concrete need.
Thanks for the review! With this in, I'll be able to write a bunch of relatively rote CLs to add the shims to the provided transforms. They will largely be similar to #7002 (minus the diffbase of this PR) Edit: I needed to modify that PR anyway, since of course all the numeric types will lead to collisions if I do individual generations. Makes sense, the "simplest" example one per package, rather than dealing with individual package files. |
@aaltay If it LGTYou Please merge. Thanks! |
@aaltay Ping :) |
Adds a type assertion shim generation tool, akin to specialize.
In particular it takes in a list of identifiers and go files from a single package and generates specialized type assertion shims for the given identifiers, using static analysis on the package code to
A subsequent PR will do the work of adding the appropriate // go:generate tags to relevant beam provided DoFns to improve the performance of these.
A user could use the tool themselves with build tools like https://bazel.build or gradle with an appropriate invocation file, and avoid committing the generated files to their own repos, but have them when building with the tool. This doesn't help users who
go get
the beam packages though so we're best checking these into the beam repo.Follow this checklist to help us incorporate your contribution quickly and easily:
[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.It will help us expedite review of your Pull Request if you tag someone (e.g.
@username
) to look at it.Post-Commit Tests Status (on master branch)