You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "robertwb (via GitHub)" <gi...@apache.org> on 2023/09/20 00:06:42 UTC

[GitHub] [beam] robertwb opened a new pull request, #28546: Remove special PyMap, PyFlatMap, etc.

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

   Prefer to use generic MapToFields instead.
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] 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://github.com/apache/beam/blob/master/CONTRIBUTING.md#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 or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
   


-- 
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] codecov[bot] commented on pull request #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #28546:
URL: https://github.com/apache/beam/pull/28546#issuecomment-1726710876

   ## [Codecov](https://app.codecov.io/gh/apache/beam/pull/28546?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#28546](https://app.codecov.io/gh/apache/beam/pull/28546?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (b0d8013) into [master](https://app.codecov.io/gh/apache/beam/commit/220cae7a1e415d185bf4dc3f5975c01feb431fd0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (220cae7) will **increase** coverage by `0.00%`.
   > Report is 88 commits behind head on master.
   > The diff coverage is `80.68%`.
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #28546   +/-   ##
   =======================================
     Coverage   72.32%   72.32%           
   =======================================
     Files         683      683           
     Lines      100709   100799   +90     
   =======================================
   + Hits        72834    72907   +73     
   - Misses      26297    26314   +17     
     Partials     1578     1578           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/beam/pull/28546/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [python](https://app.codecov.io/gh/apache/beam/pull/28546/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `82.82% <80.68%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files Changed](https://app.codecov.io/gh/apache/beam/pull/28546?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [sdks/python/apache\_beam/yaml/yaml\_transform.py](https://app.codecov.io/gh/apache/beam/pull/28546?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0veWFtbC95YW1sX3RyYW5zZm9ybS5weQ==) | `89.80% <76.92%> (-0.56%)` | :arrow_down: |
   | [sdks/python/apache\_beam/yaml/yaml\_mapping.py](https://app.codecov.io/gh/apache/beam/pull/28546?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0veWFtbC95YW1sX21hcHBpbmcucHk=) | `82.14% <78.81%> (-4.03%)` | :arrow_down: |
   | [sdks/python/apache\_beam/transforms/core.py](https://app.codecov.io/gh/apache/beam/pull/28546?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vdHJhbnNmb3Jtcy9jb3JlLnB5) | `91.53% <100.00%> (-0.04%)` | :arrow_down: |
   | [sdks/python/apache\_beam/yaml/yaml\_provider.py](https://app.codecov.io/gh/apache/beam/pull/28546?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0veWFtbC95YW1sX3Byb3ZpZGVyLnB5) | `70.38% <100.00%> (+0.29%)` | :arrow_up: |
   
   ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/apache/beam/pull/28546/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
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] robertwb commented on a diff in pull request #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb commented on code in PR #28546:
URL: https://github.com/apache/beam/pull/28546#discussion_r1334848505


##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -508,19 +510,14 @@ def _parse_window_spec(spec):
       # TODO: Triggering, etc.
       return beam.WindowInto(window_fn)
 
+  def log_and_return(x):
+    logging.info(x)
+    return x
+
   return InlineProvider(
       dict({
           'Create': create,
-          'PyMap': lambda fn: beam.Map(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyMapTuple': lambda fn: beam.MapTuple(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFlatMap': lambda fn: beam.FlatMap(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFlatMapTuple': lambda fn: beam.FlatMapTuple(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFilter': lambda keep: beam.Filter(
-              python_callable.PythonCallableWithSource(keep)),
+          'LogForTesting': lambda: beam.Map(log_and_return),

Review Comment:
   Logging every element is certainly not to be encouraged for production pipelines...I might go so far as to consider it an anti-pattern. But I could see it being used to log bad elements or something similar. We can always add it later. 



-- 
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 #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28546:
URL: https://github.com/apache/beam/pull/28546#issuecomment-1726763457

   Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`


-- 
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] robertwb commented on pull request #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb commented on PR #28546:
URL: https://github.com/apache/beam/pull/28546#issuecomment-1726700329

   This depends on https://github.com/apache/beam/pull/28462


-- 
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 #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on code in PR #28546:
URL: https://github.com/apache/beam/pull/28546#discussion_r1332049852


##########
sdks/python/apache_beam/yaml/yaml_transform_unit_test.py:
##########
@@ -950,43 +948,6 @@ def test_ensure_errors_consumed_no_output_in_error_handling(self):
     with self.assertRaisesRegex(ValueError, r"Missing output.*"):
       ensure_errors_consumed(spec)
 
-  def test_expand_pipeline_with_string_spec(self):
-    with new_pipeline() as p:
-      spec = '''
-        pipeline:
-          type: chain
-          transforms:
-            - type: Create
-              config:
-                elements: [1,2,3]
-            - type: PyMap
-              config:
-                fn: 'lambda x: x*x'
-      '''
-      result = expand_pipeline(p, spec)
-
-      self.assertIsInstance(result, PCollection)
-      self.assertEqual(str(result), 'PCollection[Map(lambda x: x*x).None]')
-
-  def test_expand_pipeline_with_spec(self):
-    with new_pipeline() as p:
-      spec = '''
-        pipeline:
-          type: chain
-          transforms:
-            - type: Create
-              config:
-                elements: [1,2,3]
-            - type: PyMap

Review Comment:
   Is there a reason to cut these tests? Can we keep them with a non-Py Map?



##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -508,19 +510,14 @@ def _parse_window_spec(spec):
       # TODO: Triggering, etc.
       return beam.WindowInto(window_fn)
 
+  def log_and_return(x):
+    logging.info(x)
+    return x
+
   return InlineProvider(
       dict({
           'Create': create,
-          'PyMap': lambda fn: beam.Map(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyMapTuple': lambda fn: beam.MapTuple(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFlatMap': lambda fn: beam.FlatMap(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFlatMapTuple': lambda fn: beam.FlatMapTuple(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFilter': lambda keep: beam.Filter(
-              python_callable.PythonCallableWithSource(keep)),
+          'LogForTesting': lambda: beam.Map(log_and_return),

Review Comment:
   ```suggestion
             'Log': lambda: beam.Map(log_and_return),
   ```
   
   any reason to call it `ForTesting`? Seems universally useful



-- 
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] robertwb commented on a diff in pull request #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb commented on code in PR #28546:
URL: https://github.com/apache/beam/pull/28546#discussion_r1334847606


##########
sdks/python/apache_beam/yaml/yaml_transform_unit_test.py:
##########
@@ -950,43 +948,6 @@ def test_ensure_errors_consumed_no_output_in_error_handling(self):
     with self.assertRaisesRegex(ValueError, r"Missing output.*"):
       ensure_errors_consumed(spec)
 
-  def test_expand_pipeline_with_string_spec(self):
-    with new_pipeline() as p:
-      spec = '''
-        pipeline:
-          type: chain
-          transforms:
-            - type: Create
-              config:
-                elements: [1,2,3]
-            - type: PyMap
-              config:
-                fn: 'lambda x: x*x'
-      '''
-      result = expand_pipeline(p, spec)
-
-      self.assertIsInstance(result, PCollection)
-      self.assertEqual(str(result), 'PCollection[Map(lambda x: x*x).None]')
-
-  def test_expand_pipeline_with_spec(self):
-    with new_pipeline() as p:
-      spec = '''
-        pipeline:
-          type: chain
-          transforms:
-            - type: Create
-              config:
-                elements: [1,2,3]
-            - type: PyMap

Review Comment:
   These are more change-detector tests, they don't really test anything useful. 



-- 
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] robertwb commented on pull request #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb commented on PR #28546:
URL: https://github.com/apache/beam/pull/28546#issuecomment-1732081094

   Run Python_Runners PreCommit


-- 
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 #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28546:
URL: https://github.com/apache/beam/pull/28546#issuecomment-1728628536

   Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @tvalentyn for label python.
   
   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] robertwb merged pull request #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb merged PR #28546:
URL: https://github.com/apache/beam/pull/28546


-- 
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 #28546: Remove special PyMap, PyFlatMap, etc.

Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on code in PR #28546:
URL: https://github.com/apache/beam/pull/28546#discussion_r1334965139


##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -508,19 +510,14 @@ def _parse_window_spec(spec):
       # TODO: Triggering, etc.
       return beam.WindowInto(window_fn)
 
+  def log_and_return(x):
+    logging.info(x)
+    return x
+
   return InlineProvider(
       dict({
           'Create': create,
-          'PyMap': lambda fn: beam.Map(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyMapTuple': lambda fn: beam.MapTuple(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFlatMap': lambda fn: beam.FlatMap(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFlatMapTuple': lambda fn: beam.FlatMapTuple(
-              python_callable.PythonCallableWithSource(fn)),
-          'PyFilter': lambda keep: beam.Filter(
-              python_callable.PythonCallableWithSource(keep)),
+          'LogForTesting': lambda: beam.Map(log_and_return),

Review Comment:
   Agreed on all fronts, the log on a certain branch path does seem useful to me. I also kinda think that if you use something named "Log" you'll know what you're getting, and naming it "LogForTesting" doesn't really discourage use. I'm fine deferring this though



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