Skip to content

Commit 13aac48

Browse files
authored
Enhance live display by deactivating auto-refresh among other things. (#186)
1 parent 760eda6 commit 13aac48

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

docs/source/changes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
77
`Anaconda.org <https://anaconda.org/conda-forge/pytask>`_.
88

99

10+
0.1.5 - 2022-xx-xx
11+
------------------
12+
13+
- :gh:`186` enhance live displays by deactivating auto-refresh among other things.
14+
15+
1016
0.1.4 - 2022-01-04
1117
------------------
1218

src/_pytask/live.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,22 @@ class LiveManager:
9494
"""A class for live displays during a session.
9595
9696
This class allows to display live information during a session and handles the
97-
interaction with the :class:`_pytask.debugging.PytaskPDB` and
98-
:class:`_pytask.capture.CaptureManager`.
97+
interaction with the :class:`_pytask.debugging.PytaskPDB`.
98+
99+
The renderable is not updated automatically for two reasons.
100+
101+
1. Usually, the duration of tasks is highly heterogeneous and there are probably not
102+
many tasks which last much less than a second. Therefore, updating the renderable
103+
automatically by a fixed time interval seems unnecessary.
104+
105+
2. To update the renderable automatically a thread is started which pushes the
106+
updates. When a task is run simultaneously and capturing is activated, all
107+
updates will be captured and added to the stdout of the task instead of printed
108+
to the terminal.
99109
100110
"""
101111

102-
_live = Live(renderable=None, console=console, auto_refresh=True)
112+
_live = Live(renderable=None, console=console, auto_refresh=False)
103113

104114
def start(self) -> None:
105115
self._live.start()
@@ -121,6 +131,7 @@ def resume(self) -> None:
121131

122132
def update(self, *args: Any, **kwargs: Any) -> None:
123133
self._live.update(*args, **kwargs)
134+
self._live.refresh()
124135

125136
@property
126137
def is_started(self) -> None:
@@ -144,8 +155,8 @@ def pytask_execute_build(self) -> Generator[None, None, None]:
144155
end."""
145156
self._live_manager.start()
146157
yield
147-
self._update_table(reduce_table=False, sort_table=True)
148-
self._live_manager.stop(transient=False)
158+
self._live_manager.stop(transient=True)
159+
console.print(self._generate_table(reduce_table=False, sort_table=True))
149160

150161
@hookimpl(tryfirst=True)
151162
def pytask_execute_task_log_start(self, task: MetaTask) -> bool:
@@ -264,7 +275,6 @@ def pytask_collect_file_log(self, reports: List[CollectionReport]) -> None:
264275

265276
@hookimpl(hookwrapper=True)
266277
def pytask_collect_log(self) -> Generator[None, None, None]:
267-
self._live_manager.update(None)
268278
self._live_manager.stop(transient=True)
269279
yield
270280

0 commit comments

Comments
 (0)