Skip to content

Commit

Permalink
[DOP-18570] Fix SparkMetricsListener.onExecutionEnd on Python 3.9 and…
Browse files Browse the repository at this point in the history
… below
  • Loading branch information
dolfinus committed Aug 28, 2024
1 parent c6b09be commit 3c4a1e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions onetl/_metrics/listener/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class SparkSQLMetricNames(str, Enum): # noqa: WPS338
def __str__(self):
return self.value

@classmethod
def values(cls):
return set(cls.__members__.values())


@dataclass
class SparkListenerExecution:
Expand Down
4 changes: 3 additions & 1 deletion onetl/_metrics/listener/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
SparkSQLMetricNames,
)

KNOWN_METRICS = SparkSQLMetricNames.values()


@dataclass
class SparkMetricsListener(BaseSparkListener):
Expand Down Expand Up @@ -81,7 +83,7 @@ def onExecutionEnd(self, event):
for i in range(metrics.size()):
metric = metrics.apply(i)
metric_name = metric.name()
if metric_name not in SparkSQLMetricNames:
if metric_name not in KNOWN_METRICS:
continue
metric_value = metric_values.get(metric.accumulatorId())
if not metric_value.isDefined():
Expand Down

0 comments on commit 3c4a1e0

Please sign in to comment.