Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdks/python/apache_beam/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions sdks/python/apache_beam/metrics/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/metrics/cells_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions sdks/python/apache_beam/metrics/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/metrics/execution_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/metrics/metric_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions sdks/python/apache_beam/metrics/metricbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
1 change: 1 addition & 0 deletions sdks/python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ deps =
flake8==3.5.0
modules =
apache_beam/coders
apache_beam/metrics
commands =
python --version
pip --version
Expand Down