From d4ff0bd23dcf9f8bf2ed907ca73fbdc2be19d4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20BREDIN?= Date: Thu, 16 Feb 2023 21:17:08 +0100 Subject: [PATCH] feat: add option to make progress hook transient (#1264) --- pyannote/audio/pipelines/utils/hook.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyannote/audio/pipelines/utils/hook.py b/pyannote/audio/pipelines/utils/hook.py index 443ef9ac..cb150ea4 100644 --- a/pyannote/audio/pipelines/utils/hook.py +++ b/pyannote/audio/pipelines/utils/hook.py @@ -51,6 +51,11 @@ def logging_hook( class ProgressHook: """Hook to show progress of each internal step + Parameters + ---------- + transient: bool, optional + Clear the progress on exit. Defaults to False. + Example ------- pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization") @@ -58,6 +63,10 @@ class ProgressHook: output = pipeline(file, hook=hook) """ + def __init__(self, transient: bool = False): + super().__init__() + self.transient = transient + def __enter__(self): self.progress = Progress( @@ -65,6 +74,7 @@ class ProgressHook: BarColumn(), TaskProgressColumn(), TimeRemainingColumn(elapsed_when_finished=True), + transient=self.transient, ) self.progress.start() return self