From 1c07e38bae54652d4743a3de850fbfe2a4478854 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 15 Sep 2024 17:02:00 +0200 Subject: [PATCH 1/3] Unconfigure live manager at the end of the session. --- src/_pytask/live.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/_pytask/live.py b/src/_pytask/live.py index ab6db556a..d5a79a793 100644 --- a/src/_pytask/live.py +++ b/src/_pytask/live.py @@ -84,6 +84,13 @@ def pytask_execute(session: Session) -> Generator[None, None, None]: return (yield) +@hookimpl +def pytask_unconfigure(session: Session) -> None: + """Unconfigure the session.""" + live_manager = session.config["pm"].get_plugin("live_manager") + live_manager.stop() + + @define(eq=False) class LiveManager: """A class for live displays during a session. From 163b5adc8737519b495bdb818ad1b14c6941db7b Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 15 Sep 2024 19:57:49 +0200 Subject: [PATCH 2/3] Stop live display after exception in execution. --- docs/source/changes.md | 4 ++++ src/_pytask/live.py | 24 +++++++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/docs/source/changes.md b/docs/source/changes.md index a16f37f35..43bea4630 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -5,6 +5,10 @@ chronological order. Releases follow [semantic versioning](https://semver.org/) releases are available on [PyPI](https://pypi.org/project/pytask) and [Anaconda.org](https://anaconda.org/conda-forge/pytask). +## 0.5.2 - 2024-09-15 + +- \{pull}\`\` stops the live display when an exception happened during the execution. + ## 0.5.1 - 2024-07-20 - {pull}`616` and {pull}`632` redesign the guide on "Scaling Tasks". diff --git a/src/_pytask/live.py b/src/_pytask/live.py index d5a79a793..6ea7c308a 100644 --- a/src/_pytask/live.py +++ b/src/_pytask/live.py @@ -84,13 +84,6 @@ def pytask_execute(session: Session) -> Generator[None, None, None]: return (yield) -@hookimpl -def pytask_unconfigure(session: Session) -> None: - """Unconfigure the session.""" - live_manager = session.config["pm"].get_plugin("live_manager") - live_manager.stop() - - @define(eq=False) class LiveManager: """A class for live displays during a session. @@ -181,14 +174,15 @@ class LiveExecution: def pytask_execute_build(self) -> Generator[None, None, None]: """Wrap the execution with the live manager and yield a table at the end.""" self.live_manager.start() - result = yield - self.live_manager.stop(transient=True) - table = self._generate_table( - reduce_table=False, sort_table=self.sort_final_table, add_caption=False - ) - if table is not None: - console.print(table) - return result + try: + return (yield) + finally: + self.live_manager.stop(transient=True) + table = self._generate_table( + reduce_table=False, sort_table=self.sort_final_table, add_caption=False + ) + if table is not None: + console.print(table) @hookimpl(tryfirst=True) def pytask_execute_task_log_start(self, task: PTask) -> bool: From f4ac6c0105f54d90a2d95dd2726a2a7c8d209ae4 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 15 Sep 2024 19:58:27 +0200 Subject: [PATCH 3/3] Fix. --- docs/source/changes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/changes.md b/docs/source/changes.md index 43bea4630..342675960 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -7,7 +7,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and ## 0.5.2 - 2024-09-15 -- \{pull}\`\` stops the live display when an exception happened during the execution. +- {pull}`640` stops the live display when an exception happened during the execution. ## 0.5.1 - 2024-07-20