Skip to content

Commit 09c1e1e

Browse files
author
Tai An
committed
fix(profiling): call restore() in PipelineProfiler.run() after profiling
Store the restore callable from annotate_pipeline() and call it at the end of run() so class-level method patches are cleaned up.
1 parent 186d04e commit 09c1e1e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

examples/profiling/profiling_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ def setup_pipeline(self, annotate=True):
169169
pipe.set_progress_bar_config(disable=True)
170170

171171
if annotate:
172-
annotate_pipeline(pipe)
172+
self._restore_annotations = annotate_pipeline(pipe)
173+
else:
174+
self._restore_annotations = None
173175
return pipe
174176

175177
def run(self):
@@ -215,7 +217,9 @@ def run(self):
215217
)
216218
)
217219

218-
# Cleanup
220+
# Cleanup -- restore patched methods so class-level patches don't persist
221+
if self._restore_annotations is not None:
222+
self._restore_annotations()
219223
pipe.to("cpu")
220224
del pipe
221225
flush()

0 commit comments

Comments
 (0)