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

[BEAM-9339] Declare capabilities for Go SDK. #10911

Merged
merged 2 commits into from
Feb 21, 2020

Conversation

robertwb
Copy link
Contributor


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.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- Build Status --- --- Build Status
Java Build Status Build Status Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
--- Build Status
Build Status
Build Status
Build Status
--- --- Build Status
XLang --- --- --- Build Status --- --- ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website
Non-portable Build Status Build Status
Build Status
Build Status Build Status
Portable --- Build Status --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

@robertwb
Copy link
Contributor Author

R: @lostluck

Copy link
Contributor

@lostluck lostluck left a comment

Choose a reason for hiding this comment

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

We may want to consider just moving the code in universal to graphx/translate.go since that's more central and defines the "default" go environment, so it's also in the pipeline proto for non universal runners (Dataflow).

However, this sets the bar so we know if that change accidentally breaks it later. Or I'm missing something since this is being reviewed on my phone .

sdks/go/pkg/beam/runners/universal/universal.go Outdated Show resolved Hide resolved
capabilities = append(capabilities, graphx.KnownStandardCoders()...)
return capabilities
}

Copy link
Contributor

Choose a reason for hiding this comment

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

You can return straight from the append and save a line.

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. I wasn't sure what the convention was--the semantics of append (may modify the first argument or return a new value) seemed odd to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough.
Technically append always returns a new "slice" but the backing array for the data may be reused. It's possible to have aliasing problems if done poorly, but that's not a risk here.
It mostly comes down to the difference between the used length, and the capacity of the slice. If there's enough capacity, it will simply mutate the backing slice.

To avoid the aliasing, as a rule, one should avoid using an slice one didn't allocate as the base for append.

lostluck
lostluck previously approved these changes Feb 20, 2020
@robertwb
Copy link
Contributor Author

I'll defer further refactoring, but could you clarify your comment about Dataflow? Are we not creating/setting an environment at all in that case?

@lostluck
Copy link
Contributor

Dataflow creates it's own environment and doesn't use the universal runner.

@robertwb
Copy link
Contributor Author

OK, we do need this for dataflow. I refactored the code to be shared in translate.go. PTAL.

@@ -50,6 +50,22 @@ const (
urnCoGBKList = "beam:go:coder:cogbklist:v1" // CoGBK representation. Not a coder.
)

func KnownStandardCoders() []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this lives in the same package as the caller, we can make the function un-exported (lowercase k for knownStandardCoders() instead).

It's reasonably to have this function live here, due to locality with the coder URNs

@@ -26,6 +27,7 @@ import (
"github.com/apache/beam/sdks/go/pkg/beam/core/util/protox"
"github.com/apache/beam/sdks/go/pkg/beam/internal/errors"
pb "github.com/apache/beam/sdks/go/pkg/beam/model/pipeline_v1"
"github.com/apache/beam/sdks/go/pkg/beam/options/jobopts"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like that we're importing this package here. jobopts creates flags, which could be unexpected or unnecessary for certain runners.

Could we instead just pass the environment urn in as a string? (the only thing we actually use from the package).

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, done.

@lostluck lostluck self-requested a review February 20, 2020 22:17
@lostluck lostluck dismissed their stale review February 20, 2020 22:17

Code changed.

Copy link
Contributor

@lostluck lostluck left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

@robertwb robertwb merged commit 6ab6b12 into apache:master Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants