[jira] [Work logged] (BEAM-4001) Futurize and fix python 2 compatibility for metrics subpackage
[ https://issues.apache.org/jira/browse/BEAM-4001?focusedWorklogId=103184&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-103184 ] ASF GitHub Bot logged work on BEAM-4001: Author: ASF GitHub Bot Created on: 18/May/18 00:16 Start Date: 18/May/18 00:16 Worklog Time Spent: 10m Work Description: aaltay closed pull request #5335: [BEAM-4001] Futurize metrics subpackage URL: https://github.com/apache/beam/pull/5335 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/sdks/python/apache_beam/metrics/__init__.py b/sdks/python/apache_beam/metrics/__init__.py index 8ce7bbb173f..e74168f09e4 100644 --- a/sdks/python/apache_beam/metrics/__init__.py +++ b/sdks/python/apache_beam/metrics/__init__.py @@ -14,5 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from __future__ import absolute_import + from apache_beam.metrics.metric import Metrics from apache_beam.metrics.metric import MetricsFilter diff --git a/sdks/python/apache_beam/metrics/cells.py b/sdks/python/apache_beam/metrics/cells.py index 302d79ab512..8f93d7fffe5 100644 --- a/sdks/python/apache_beam/metrics/cells.py +++ b/sdks/python/apache_beam/metrics/cells.py @@ -23,10 +23,13 @@ Cells depend on a 'dirty-bit' in the CellCommitState class that tracks whether a cell's updates have been committed. """ + +from __future__ import absolute_import from __future__ import division import threading import time +from builtins import object from google.protobuf import timestamp_pb2 @@ -245,6 +248,9 @@ def __eq__(self, other): else: return False + def __hash__(self): +return hash(self.data) + def __ne__(self, other): return not self.__eq__(other) @@ -292,6 +298,9 @@ def __eq__(self, other): else: return False + def __hash__(self): +return hash(self.data) + def __ne__(self, other): return not self.__eq__(other) @@ -326,6 +335,9 @@ def __init__(self, value, timestamp=None): def __eq__(self, other): return self.value == other.value and self.timestamp == other.timestamp + def __hash__(self): +return hash((self.value, self.timestamp)) + def __ne__(self, other): return not self.__eq__(other) @@ -386,6 +398,9 @@ def __eq__(self, other): self.min == other.min and self.max == other.max) + def __hash__(self): +return hash((self.sum, self.count, self.min, self.max)) + def __ne__(self, other): return not self.__eq__(other) diff --git a/sdks/python/apache_beam/metrics/cells_test.py b/sdks/python/apache_beam/metrics/cells_test.py index 14e7e537ea1..64b9df95bbf 100644 --- a/sdks/python/apache_beam/metrics/cells_test.py +++ b/sdks/python/apache_beam/metrics/cells_test.py @@ -15,8 +15,11 @@ # limitations under the License. # +from __future__ import absolute_import + import threading import unittest +from builtins import range from apache_beam.metrics.cells import CellCommitState from apache_beam.metrics.cells import CounterCell diff --git a/sdks/python/apache_beam/metrics/execution.py b/sdks/python/apache_beam/metrics/execution.py index cb0f07141a1..157fa0aaf5e 100644 --- a/sdks/python/apache_beam/metrics/execution.py +++ b/sdks/python/apache_beam/metrics/execution.py @@ -29,7 +29,11 @@ - MetricsContainer - Holds the metrics of a single step and a single unit-of-commit (bundle). """ + +from __future__ import absolute_import + import threading +from builtins import object from collections import defaultdict from apache_beam.metrics.cells import CounterCell @@ -59,6 +63,9 @@ def __eq__(self, other): return (self.step == other.step and self.metric == other.metric) + def __hash__(self): +return hash((self.step, self.metric)) + def __repr__(self): return 'MetricKey(step={}, metric={})'.format( self.step, self.metric) @@ -98,6 +105,9 @@ def __eq__(self, other): self.committed == other.committed and self.attempted == other.attempted) + def __hash__(self): +return hash((self.key, self.committed, self.attempted)) + def __repr__(self): return 'MetricResult(key={}, committed={}, attempted={})'.format( self.key, str(self.committed), str(self.attempted)) diff --git a/sdks/python/apache_beam/metrics/execution_test.py b/sdks/python/apache_beam/metrics/execution_test.py index 37d24f3407b..fbf5492f05d 100644 --- a/sdks/python/apache_beam/metrics/execution_test.py +++ b/sdks/python/apache_beam/metrics/execution_test.py @@ -15,7 +15,10 @@ # limitations under the License. # +from __future__ import absolute_import + import
[jira] [Work logged] (BEAM-4001) Futurize and fix python 2 compatibility for metrics subpackage
[ https://issues.apache.org/jira/browse/BEAM-4001?focusedWorklogId=103170&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-103170 ] ASF GitHub Bot logged work on BEAM-4001: Author: ASF GitHub Bot Created on: 17/May/18 23:29 Start Date: 17/May/18 23:29 Worklog Time Spent: 10m Work Description: tvalentyn commented on issue #5335: [BEAM-4001] Futurize metrics subpackage URL: https://github.com/apache/beam/pull/5335#issuecomment-390045147 Yes, I think we can merge this, thank you! This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 103170) Time Spent: 40m (was: 0.5h) > Futurize and fix python 2 compatibility for metrics subpackage > -- > > Key: BEAM-4001 > URL: https://issues.apache.org/jira/browse/BEAM-4001 > Project: Beam > Issue Type: Sub-task > Components: sdk-py-core >Reporter: Robbe >Assignee: Matthias Feys >Priority: Major > Time Spent: 40m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-4001) Futurize and fix python 2 compatibility for metrics subpackage
[ https://issues.apache.org/jira/browse/BEAM-4001?focusedWorklogId=103158&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-103158 ] ASF GitHub Bot logged work on BEAM-4001: Author: ASF GitHub Bot Created on: 17/May/18 23:01 Start Date: 17/May/18 23:01 Worklog Time Spent: 10m Work Description: pabloem commented on issue #5335: [BEAM-4001] Futurize metrics subpackage URL: https://github.com/apache/beam/pull/5335#issuecomment-390039885 Should this be merged? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 103158) Time Spent: 0.5h (was: 20m) > Futurize and fix python 2 compatibility for metrics subpackage > -- > > Key: BEAM-4001 > URL: https://issues.apache.org/jira/browse/BEAM-4001 > Project: Beam > Issue Type: Sub-task > Components: sdk-py-core >Reporter: Robbe >Assignee: Matthias Feys >Priority: Major > Time Spent: 0.5h > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-4001) Futurize and fix python 2 compatibility for metrics subpackage
[ https://issues.apache.org/jira/browse/BEAM-4001?focusedWorklogId=101178&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-101178 ] ASF GitHub Bot logged work on BEAM-4001: Author: ASF GitHub Bot Created on: 11/May/18 16:27 Start Date: 11/May/18 16:27 Worklog Time Spent: 10m Work Description: aaltay commented on issue #5335: [BEAM-4001] Futurize metrics subpackage URL: https://github.com/apache/beam/pull/5335#issuecomment-388414900 LGTM. Thank you! We can merge once @tvalentyn gets a chance to look at it. /cc @pabloem This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 101178) Time Spent: 20m (was: 10m) > Futurize and fix python 2 compatibility for metrics subpackage > -- > > Key: BEAM-4001 > URL: https://issues.apache.org/jira/browse/BEAM-4001 > Project: Beam > Issue Type: Sub-task > Components: sdk-py-core >Reporter: Robbe >Assignee: Matthias Feys >Priority: Major > Time Spent: 20m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Work logged] (BEAM-4001) Futurize and fix python 2 compatibility for metrics subpackage
[ https://issues.apache.org/jira/browse/BEAM-4001?focusedWorklogId=101091&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-101091 ] ASF GitHub Bot logged work on BEAM-4001: Author: ASF GitHub Bot Created on: 11/May/18 11:48 Start Date: 11/May/18 11:48 Worklog Time Spent: 10m Work Description: Fematich opened a new pull request #5335: [BEAM-4001] Futurize metrics subpackage URL: https://github.com/apache/beam/pull/5335 This pull request prepares the metrics subpackage for Python 3 support. This PR is part of a series in which all subpackages will be updated using the same approach. This approach has been documented [here](https://docs.google.com/document/d/1xDG0MWVlDKDPu_IW9gtMvxi2S9I0GB0VDTkPhjXT0nE/edit#)and the first pull request in the series (Futurize coders subpackage) demonstrating this approach can be found at #5053. R: @aaltay @tvalentyn This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 101091) Time Spent: 10m Remaining Estimate: 0h > Futurize and fix python 2 compatibility for metrics subpackage > -- > > Key: BEAM-4001 > URL: https://issues.apache.org/jira/browse/BEAM-4001 > Project: Beam > Issue Type: Sub-task > Components: sdk-py-core >Reporter: Robbe >Assignee: Matthias Feys >Priority: Major > Time Spent: 10m > Remaining Estimate: 0h > -- This message was sent by Atlassian JIRA (v7.6.3#76005)