diff --git a/docs/source/changes.rst b/docs/source/changes.rst index ba4187eb..e1f5223a 100644 --- a/docs/source/changes.rst +++ b/docs/source/changes.rst @@ -7,6 +7,12 @@ all releases are available on `PyPI `_ and `Anaconda.org `_. +0.1.5 - 2022-xx-xx +------------------ + +- :gh:`186` enhance live displays by deactivating auto-refresh among other things. + + 0.1.4 - 2022-01-04 ------------------ diff --git a/src/_pytask/live.py b/src/_pytask/live.py index 3fa99943..a47400fa 100644 --- a/src/_pytask/live.py +++ b/src/_pytask/live.py @@ -94,12 +94,22 @@ class LiveManager: """A class for live displays during a session. This class allows to display live information during a session and handles the - interaction with the :class:`_pytask.debugging.PytaskPDB` and - :class:`_pytask.capture.CaptureManager`. + interaction with the :class:`_pytask.debugging.PytaskPDB`. + + The renderable is not updated automatically for two reasons. + + 1. Usually, the duration of tasks is highly heterogeneous and there are probably not + many tasks which last much less than a second. Therefore, updating the renderable + automatically by a fixed time interval seems unnecessary. + + 2. To update the renderable automatically a thread is started which pushes the + updates. When a task is run simultaneously and capturing is activated, all + updates will be captured and added to the stdout of the task instead of printed + to the terminal. """ - _live = Live(renderable=None, console=console, auto_refresh=True) + _live = Live(renderable=None, console=console, auto_refresh=False) def start(self) -> None: self._live.start() @@ -121,6 +131,7 @@ def resume(self) -> None: def update(self, *args: Any, **kwargs: Any) -> None: self._live.update(*args, **kwargs) + self._live.refresh() @property def is_started(self) -> None: @@ -144,8 +155,8 @@ def pytask_execute_build(self) -> Generator[None, None, None]: end.""" self._live_manager.start() yield - self._update_table(reduce_table=False, sort_table=True) - self._live_manager.stop(transient=False) + self._live_manager.stop(transient=True) + console.print(self._generate_table(reduce_table=False, sort_table=True)) @hookimpl(tryfirst=True) def pytask_execute_task_log_start(self, task: MetaTask) -> bool: @@ -264,7 +275,6 @@ def pytask_collect_file_log(self, reports: List[CollectionReport]) -> None: @hookimpl(hookwrapper=True) def pytask_collect_log(self) -> Generator[None, None, None]: - self._live_manager.update(None) self._live_manager.stop(transient=True) yield