[ 
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 unittest
+from builtins import range
 
 from apache_beam.metrics.cells import CellCommitState
 from apache_beam.metrics.execution import MetricsContainer
diff --git a/sdks/python/apache_beam/metrics/metric.py 
b/sdks/python/apache_beam/metrics/metric.py
index 8b6c50f9e9f..3ff132bee4a 100644
--- a/sdks/python/apache_beam/metrics/metric.py
+++ b/sdks/python/apache_beam/metrics/metric.py
@@ -24,7 +24,10 @@
 - Metrics - This class lets pipeline and transform writers create and access
     metric objects such as counters, distributions, etc.
 """
+from __future__ import absolute_import
+
 import inspect
+from builtins import object
 
 from apache_beam.metrics.execution import MetricsEnvironment
 from apache_beam.metrics.metricbase import Counter
diff --git a/sdks/python/apache_beam/metrics/metric_test.py 
b/sdks/python/apache_beam/metrics/metric_test.py
index 84f6ae91048..0cd492f77b4 100644
--- a/sdks/python/apache_beam/metrics/metric_test.py
+++ b/sdks/python/apache_beam/metrics/metric_test.py
@@ -15,7 +15,10 @@
 # limitations under the License.
 #
 
+from __future__ import absolute_import
+
 import unittest
+from builtins import object
 
 from apache_beam.metrics.cells import DistributionData
 from apache_beam.metrics.execution import MetricKey
diff --git a/sdks/python/apache_beam/metrics/metricbase.py 
b/sdks/python/apache_beam/metrics/metricbase.py
index 2ef9fe6d535..2453f41c954 100644
--- a/sdks/python/apache_beam/metrics/metricbase.py
+++ b/sdks/python/apache_beam/metrics/metricbase.py
@@ -32,6 +32,10 @@
 - MetricName - Namespace and name used to refer to a Metric.
 """
 
+from __future__ import absolute_import
+
+from builtins import object
+
 from apache_beam.portability.api import beam_fn_api_pb2
 
 __all__ = ['Metric', 'Counter', 'Distribution', 'Gauge', 'MetricName']
diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini
index caa899de2db..61dc12c3017 100644
--- a/sdks/python/tox.ini
+++ b/sdks/python/tox.ini
@@ -99,6 +99,7 @@ deps =
   flake8==3.5.0
 modules =
   apache_beam/coders
+  apache_beam/metrics
 commands =
   python --version
   pip --version


 

----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 103184)
    Time Spent: 50m  (was: 40m)

> 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: 50m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to