damccorm commented on code in PR #41275:
URL: https://github.com/apache/beam/pull/41275#discussion_r4560981951
##########
sdks/python/apache_beam/metrics/execution.py:
##########
@@ -257,32 +257,50 @@ def __init__(self, step_name):
self.lock = threading.Lock()
self.metrics = {} # type: Dict[_TypedMetricName, MetricCell]
+ def _get_typed_metric_name(self, cell_type, metric_name):
+ if not isinstance(metric_name, str):
+ try:
+ cache = metric_name._typed_metric_names
+ except AttributeError:
+ cache = metric_name._typed_metric_names = {}
Review Comment:
Great catch! Fixed in d29f41424ed: updated `_TypedMetricName.__reduce__` and
`__init__` to pass `fast_name` directly so unpickling / `pickler` / `deepcopy`
of a `MetricName` cycle does not invoke `metric_name.fast_name()` before
`metric_name.__dict__` is restored, and added
`TestMetricsContainer.test_pickle_and_deepcopy_metric_name_after_caching`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]