Skip to content

Enhance live display by deactivating auto-refresh among other things. #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
`Anaconda.org <https://anaconda.org/conda-forge/pytask>`_.


0.1.5 - 2022-xx-xx
------------------

- :gh:`186` enhance live displays by deactivating auto-refresh among other things.


0.1.4 - 2022-01-04
------------------

Expand Down
22 changes: 16 additions & 6 deletions src/_pytask/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand Down