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/09/06 23:11:24 UTC

[GitHub] [beam] pcoet opened a new pull request, #23057: clean up comments and register functional DoFn in wordcount.go

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

   **Please** add a meaningful description for your change here
   
   Updated wordcount.go example:
   
   * Edited comments for readability.
   * Called out types of DoFns: structural and functional.
   * Formatted comments to fit on 80-char lines (because it's prettier).
   * Registered `formatFn`.
   
   I tested the code in a different environment using the local runner, then copied it back into this file.
   
   @damccorm
   @lostluck
   @jrmccluskey 
   
   ------------------------
   
   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`).
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] 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/get-started-contributing/#make-the-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)
   [![Go tests](https://github.com/apache/beam/workflows/Go%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+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] pcoet commented on a diff in pull request #23057: clean up comments and register functional DoFn in wordcount.go

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


##########
sdks/go/examples/wordcount/wordcount.go:
##########
@@ -95,10 +95,12 @@ var (
 
 // Concept #3: You can make your pipeline assembly code less verbose by
 // defining your DoFns statically out-of-line. A DoFn can be defined as a Go
-// function and is conventionally suffixed "Fn". The argument and return types
-// dictate the pipeline shape when used in a ParDo. For example,
+// function and is conventionally suffixed "Fn". Using named function
+// transforms allows for easy reuse, modular testing, and an improved monitoring
+// experience. The argument and return types of a function dictate the pipeline
+// shape when used in a ParDo. For example,
 //
-//	formatFn: string x int -> string
+//	func formatFn(w string, c int) string

Review Comment:
   Okay, I think it's equivalent now...



-- 
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 #23057: clean up comments and register functional DoFn in wordcount.go

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


##########
sdks/go/examples/wordcount/wordcount.go:
##########
@@ -95,10 +95,12 @@ var (
 
 // Concept #3: You can make your pipeline assembly code less verbose by
 // defining your DoFns statically out-of-line. A DoFn can be defined as a Go
-// function and is conventionally suffixed "Fn". The argument and return types
-// dictate the pipeline shape when used in a ParDo. For example,
+// function and is conventionally suffixed "Fn". Using named function
+// transforms allows for easy reuse, modular testing, and an improved monitoring
+// experience. The argument and return types of a function dictate the pipeline
+// shape when used in a ParDo. For example,
 //
-//	formatFn: string x int -> string
+//	func formatFn(w string, c int) string

Review Comment:
   We should make extractFn match below (sorry I didn't call that out initially)



-- 
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 #23057: clean up comments and register functional DoFn in wordcount.go

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


-- 
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] pcoet commented on a diff in pull request #23057: clean up comments and register functional DoFn in wordcount.go

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


##########
sdks/go/examples/wordcount/wordcount.go:
##########
@@ -93,39 +93,47 @@ var (
 	output = flag.String("output", "", "Output file (required).")
 )
 
-// Concept #3: You can make your pipeline assembly code less verbose and by
+// Concept #3: You can make your pipeline assembly code less verbose by
 // defining your DoFns statically out-of-line. A DoFn can be defined as a Go
 // function and is conventionally suffixed "Fn". The argument and return types
-// dictate the pipeline shape when used in a ParDo: for example,
+// dictate the pipeline shape when used in a ParDo. For example,
 //
-//      formatFn: string x int -> string
+//	formatFn: string x int -> string
 //
-// indicate that it operates on a PCollection of type KV<string,int>, representing
-// key value pairs of strings and ints, and outputs a PCollection of type string.
-// Beam typechecks the pipeline before running it.
+// indicates that the function operates on a PCollection of type KV<string,int>,
+// representing key value pairs of strings and ints, and outputs a PCollection
+// of type string. Beam typechecks the pipeline before running it.
 //
-// DoFns that potentially output zero or multiple elements can also be Go functions,
-// but have a different signature. For example,
+// DoFns that potentially output zero or multiple elements can also be Go
+// functions, but have a different signature. For example,
 //
-//       extractFn : string x func(string) -> ()
+//	extractFn : string x func(string) -> ()
 //
-// uses an "emit" function argument instead of string return type to allow it to
-// output any number of elements. It operates on a PCollection of type string and
-// returns a PCollection of type string. Also, using named function transforms allows
-// for easy reuse, modular testing, and an improved monitoring experience.
+// uses an "emit" function argument instead of a string return type to allow it
+// to output any number of elements. It operates on a PCollection of type string
+// and returns a PCollection of type string. Also, using named function
+// transforms allows for easy reuse, modular testing, and an improved monitoring
+// experience.

Review Comment:
   Yes, agreed. Done.



-- 
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 #23057: clean up comments and register functional DoFn in wordcount.go

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

   Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @jrmccluskey 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 commented on a diff in pull request #23057: clean up comments and register functional DoFn in wordcount.go

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


##########
sdks/go/examples/wordcount/wordcount.go:
##########
@@ -93,39 +93,47 @@ var (
 	output = flag.String("output", "", "Output file (required).")
 )
 
-// Concept #3: You can make your pipeline assembly code less verbose and by
+// Concept #3: You can make your pipeline assembly code less verbose by
 // defining your DoFns statically out-of-line. A DoFn can be defined as a Go
 // function and is conventionally suffixed "Fn". The argument and return types
-// dictate the pipeline shape when used in a ParDo: for example,
+// dictate the pipeline shape when used in a ParDo. For example,
 //
-//      formatFn: string x int -> string
+//	formatFn: string x int -> string

Review Comment:
   ```suggestion
   //	func formatFn(w string, c int) string
   ```
   
   Optional: if the current notation is causing confusion, we could consider something like this (here and below)



##########
sdks/go/examples/wordcount/wordcount.go:
##########
@@ -137,7 +145,8 @@ var (
 	lineLen         = beam.NewDistribution("extract", "lineLenDistro")
 )
 
-// extractFn is a DoFn that emits the words in a given line and keeps a count for small words.
+// extractFn is a structural DoFn that emits the words in a given line and keeps
+// a count for small words.

Review Comment:
   ```suggestion
   // a count for small words. Its ProcessElement function will be invoked on each
   // element in the input PCollection.
   ```
   
   Optional: This might be helpful context if people aren't familiar with Beam. Not sure if I complied w/ the 80 char limit



##########
sdks/go/examples/wordcount/wordcount.go:
##########
@@ -93,39 +93,47 @@ var (
 	output = flag.String("output", "", "Output file (required).")
 )
 
-// Concept #3: You can make your pipeline assembly code less verbose and by
+// Concept #3: You can make your pipeline assembly code less verbose by
 // defining your DoFns statically out-of-line. A DoFn can be defined as a Go
 // function and is conventionally suffixed "Fn". The argument and return types
-// dictate the pipeline shape when used in a ParDo: for example,
+// dictate the pipeline shape when used in a ParDo. For example,
 //
-//      formatFn: string x int -> string
+//	formatFn: string x int -> string
 //
-// indicate that it operates on a PCollection of type KV<string,int>, representing
-// key value pairs of strings and ints, and outputs a PCollection of type string.
-// Beam typechecks the pipeline before running it.
+// indicates that the function operates on a PCollection of type KV<string,int>,
+// representing key value pairs of strings and ints, and outputs a PCollection
+// of type string. Beam typechecks the pipeline before running it.
 //
-// DoFns that potentially output zero or multiple elements can also be Go functions,
-// but have a different signature. For example,
+// DoFns that potentially output zero or multiple elements can also be Go
+// functions, but have a different signature. For example,
 //
-//       extractFn : string x func(string) -> ()
+//	extractFn : string x func(string) -> ()
 //
-// uses an "emit" function argument instead of string return type to allow it to
-// output any number of elements. It operates on a PCollection of type string and
-// returns a PCollection of type string. Also, using named function transforms allows
-// for easy reuse, modular testing, and an improved monitoring experience.
+// uses an "emit" function argument instead of a string return type to allow it
+// to output any number of elements. It operates on a PCollection of type string
+// and returns a PCollection of type string. Also, using named function
+// transforms allows for easy reuse, modular testing, and an improved monitoring
+// experience.

Review Comment:
   Optional:
   
   > Also, using named function transforms allows for easy reuse, modular testing, and an improved monitoring experience.
   
   Not introduced by you, but this feels like an awkward add-on that doesn't really flow here IMO. Maybe it would be more appropriate above after: `A DoFn can be defined as a Go function and is conventionally suffixed "Fn".`?



-- 
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