You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/01 15:19:57 UTC

[GitHub] [beam] damccorm opened a new pull request, #17799: [BEAM-14347] Update docs to prefer generic registration functions

damccorm opened a new pull request, #17799:
URL: https://github.com/apache/beam/pull/17799

   Now that we've proven out the effectiveness of the generic registration functions in https://github.com/apache/beam/pull/17613 and it's been released with 2.40, we should update the docs to recommend that approach.
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) 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](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](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](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lostluck commented on a diff in pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
lostluck commented on code in PR #17799:
URL: https://github.com/apache/beam/pull/17799#discussion_r910170827


##########
sdks/go/examples/snippets/04transforms.go:
##########
@@ -80,7 +86,7 @@ func splitStringPair(e stringPair) (string, string) {
 func init() {
 	// Register element types and DoFns.
 	beam.RegisterType(reflect.TypeOf((*stringPair)(nil)).Elem())

Review Comment:
   I think we can avoid the manual register here since the register package is handling it, right?
   
   With the register package, the older RegisterType call basically becomes for handling special  situations when the type doesn't explicitly show up in a DoFn parameter or return.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #17799:
URL: https://github.com/apache/beam/pull/17799#issuecomment-1143747100

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
damccorm commented on PR #17799:
URL: https://github.com/apache/beam/pull/17799#issuecomment-1156536424

   R: @lostluck 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lostluck commented on a diff in pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
lostluck commented on code in PR #17799:
URL: https://github.com/apache/beam/pull/17799#discussion_r900391294


##########
website/www/site/content/en/documentation/programming-guide.md:
##########
@@ -1964,6 +2016,9 @@ multiple output PCollections.
 Call emitter functions as needed to produce 0 or more elements for its matching
 `PCollection`. The same value can be emitted with multiple emitters.
 As normal, do not mutate values after emitting them from any emitter.
+
+All emitters should be registered using a generic `register.DoFnXxY[...]`

Review Comment:
   `register.EmitterX`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
damccorm commented on PR #17799:
URL: https://github.com/apache/beam/pull/17799#issuecomment-1159123488

   Thanks for the feedback, should be fixed. I think I wrote these before I introduced register.FunctionXxY, and forgot about that class of updates - thanks for calling it out!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #17799:
URL: https://github.com/apache/beam/pull/17799#issuecomment-1143747094

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on a diff in pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
damccorm commented on code in PR #17799:
URL: https://github.com/apache/beam/pull/17799#discussion_r900403273


##########
sdks/go/examples/snippets/04transforms.go:
##########
@@ -203,6 +209,8 @@ func formatCoGBKResults(key string, emailIter, phoneIter func(*string) bool) str
 
 func init() {
 	beam.RegisterFunction(formatCoGBKResults)

Review Comment:
   Good call - I forgot to make these changes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on a diff in pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
damccorm commented on code in PR #17799:
URL: https://github.com/apache/beam/pull/17799#discussion_r910195507


##########
sdks/go/examples/snippets/04transforms.go:
##########
@@ -80,7 +86,7 @@ func splitStringPair(e stringPair) (string, string) {
 func init() {
 	// Register element types and DoFns.
 	beam.RegisterType(reflect.TypeOf((*stringPair)(nil)).Elem())

Review Comment:
   Yep, good call - fixed!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] lostluck commented on a diff in pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
lostluck commented on code in PR #17799:
URL: https://github.com/apache/beam/pull/17799#discussion_r898265444


##########
sdks/go/examples/snippets/04transforms.go:
##########
@@ -203,6 +209,8 @@ func formatCoGBKResults(key string, emailIter, phoneIter func(*string) bool) str
 
 func init() {
 	beam.RegisterFunction(formatCoGBKResults)

Review Comment:
   register.Function3x1(formatCoGBKResults) ?
   
   Similar elsewhere in the change.



##########
website/www/site/content/en/documentation/programming-guide.md:
##########
@@ -862,7 +885,11 @@ Simple DoFns can also be written as functions.
 func ComputeWordLengthFn(word string, emit func(int)) { ... }
 
 func init() {
-	beam.RegisterFunction(ComputeWordLengthFn)
+  // 2 inputs and 0 outputs => DoFn2x0
+  // 1 input => Emitter1
+  // Input/output types are included in order in the brackets
+  register.DoFn2x0[string, func(int)](&ComputeWordLengthFn{})

Review Comment:
   This would need to use register.Function2x0 IIRC, and can then avoid specifying the type parameters since they're inferable.



##########
website/www/site/content/en/documentation/programming-guide.md:
##########
@@ -1710,9 +1757,10 @@ a remote worker in your processing cluster.
 as `DoFn`, `CombineFn`, and `WindowFn`, already implement `Serializable`;
 however, your subclass must not add any non-serializable members.</span>
 <span class="language-go">Funcs are serializable as long as
-they are registered with `beam.RegisterFunction`, and are not
-closures. Structural `DoFn`s will have all exported fields serialized.
-Unexported fields are unable to be serialized, and will be silently ignored.</span>
+they are registered with `beam.RegisterFunction` (for simple functions) or

Review Comment:
   We should recommend the `register.FunctionXxY` registrations here instead.
   
   We should mark the old registration methods as deprecated in 2.41.0, and link to the advice here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #17799:
URL: https://github.com/apache/beam/pull/17799#issuecomment-1152322123

   Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @youngoli for label go.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review comments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm merged pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
damccorm merged PR #17799:
URL: https://github.com/apache/beam/pull/17799


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #17799: [BEAM-14347] Update docs to prefer generic registration functions

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #17799:
URL: https://github.com/apache/beam/pull/17799#issuecomment-1156689398

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org