Skip to content

Commit e6b5888

Browse files
committed
don't continue loops
Signed-off-by: Gary Miguel <[email protected]>
1 parent 14eb368 commit e6b5888

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

pkg/metricscollector/v1beta1/tfevent-metricscollector/tfevent_loader.py

+20-22
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,29 @@ def parse_summary(self, tfefile):
6565
tags = event_accumulator.Tags()
6666
for tag in tags[TENSORS]:
6767
for m in self.metric_names:
68-
if not _should_consider(tag, m, tfefile):
69-
continue
70-
for tensor in event_accumulator.Tensors(tag):
71-
ml = api_pb2.MetricLog(
72-
time_stamp=rfc3339.rfc3339(
73-
datetime.fromtimestamp(tensor.wall_time)
74-
),
75-
metric=api_pb2.Metric(
76-
name=m, value=str(tf.make_ndarray(tensor.tensor_proto))
77-
),
78-
)
79-
metric_logs.append(ml)
68+
if _should_consider(tag, m, tfefile):
69+
for tensor in event_accumulator.Tensors(tag):
70+
ml = api_pb2.MetricLog(
71+
time_stamp=rfc3339.rfc3339(
72+
datetime.fromtimestamp(tensor.wall_time)
73+
),
74+
metric=api_pb2.Metric(
75+
name=m, value=str(tf.make_ndarray(tensor.tensor_proto))
76+
),
77+
)
78+
metric_logs.append(ml)
8079
# support old-style tensorboard metrics too
8180
for tag in tags[SCALARS]:
8281
for m in self.metric_names:
83-
if not _should_consider(tag, m, tfefile):
84-
continue
85-
for scalar in event_accumulator.Scalars(tag):
86-
ml = api_pb2.MetricLog(
87-
time_stamp=rfc3339.rfc3339(
88-
datetime.fromtimestamp(scalar.wall_time)
89-
),
90-
metric=api_pb2.Metric(name=m, value=str(scalar.value)),
91-
)
92-
metric_logs.append(ml)
82+
if _should_consider(tag, m, tfefile):
83+
for scalar in event_accumulator.Scalars(tag):
84+
ml = api_pb2.MetricLog(
85+
time_stamp=rfc3339.rfc3339(
86+
datetime.fromtimestamp(scalar.wall_time)
87+
),
88+
metric=api_pb2.Metric(name=m, value=str(scalar.value)),
89+
)
90+
metric_logs.append(ml)
9391

9492
return metric_logs
9593

0 commit comments

Comments
 (0)