[
https://issues.apache.org/jira/browse/BEAM-10209?focusedWorklogId=443940&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-443940
]
ASF GitHub Bot logged work on BEAM-10209:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Jun/20 19:47
Start Date: 10/Jun/20 19:47
Worklog Time Spent: 10m
Work Description: InigoSJ commented on a change in pull request #11943:
URL: https://github.com/apache/beam/pull/11943#discussion_r438368619
##########
File path: sdks/python/apache_beam/transforms/combiners.py
##########
@@ -66,8 +66,21 @@ class Mean(object):
"""Combiners for computing arithmetic means of elements."""
class Globally(ptransform.PTransform):
"""combiners.Mean.Globally computes the arithmetic mean of the elements."""
+ def __init__(self, has_defaults=True, *args, **kwargs):
+ super(Mean.Globally, self).__init__()
+ self.has_defaults = has_defaults
+ self.args = args
+ self.kwargs = kwargs
+
def expand(self, pcoll):
- return pcoll | core.CombineGlobally(MeanCombineFn())
+ if self.has_defaults:
+ return pcoll | core.CombineGlobally(MeanCombineFn())
+ else:
+ return pcoll | core.CombineGlobally(MeanCombineFn()).without_defaults()
+
+ def without_defaults(self):
+ self.has_defaults = False
Review comment:
I'm not sure if I understand it correctly, but I made a modification to
return
```
return self | core.CombineGlobally(MeanCombineFn()).without_defaults()
```
I personally think it's less intuitive, but you know more :D.
I also tried directly returning without modifying `self.has_defaults`, but
it executes the first sequence of the Reduce fine, but the second returns an
error saying that I need the `without_defaults()`.
If you have suggestions, I'm all ears.
Thanks again
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 443940)
Time Spent: 1h 20m (was: 1h 10m)
> Add without_defaults to Mean
> -----------------------------
>
> Key: BEAM-10209
> URL: https://issues.apache.org/jira/browse/BEAM-10209
> Project: Beam
> Issue Type: Improvement
> Components: sdk-py-core
> Affects Versions: 2.21.0
> Reporter: Inigo San Jose Visiers
> Priority: P2
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> When using Windows and a Global Combiner with need to use
> `without_defaults()`, this is not possible when using the built-in combiner
> `Mean`, and the workaround is to do
> `CombineGlobally(MeanCombineFn()).without_defaults()`.
> Adding the option to use .without_defaults() directly would help both the
> code readability and ease of use.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)