Skip to content

Commit 6b586aa

Browse files
authored
Format running tasks correctly. (#181)
1 parent 060f3c8 commit 6b586aa

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

docs/source/changes.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ 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.4 - 2021-xx-xx
10+
0.1.4 - 2022-01-04
1111
------------------
1212

1313
- :gh:`159` removes files for creating a conda package which is handled by conda-forge.
@@ -25,6 +25,7 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
2525
- :gh:`178` makes some stylistic changes like reducing tasks ids even more and dims the
2626
path part.
2727
- :gh:`180` fixes parsing relative paths from the configuration file.
28+
- :gh:`181` adds correct formatting of running tasks.
2829

2930

3031
0.1.3 - 2021-11-30

docs/source/tutorials/how_to_set_up_a_project.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ The configuration
3939

4040
The configuration resides in either a ``pytask.ini``, ``tox.ini``, or ``setup.cfg``
4141
file. The file is placed in the root folder of the project and contains a ``[pytask]``
42-
section which can be left empty.
42+
section which can be left empty. Here, we set ``paths`` such that it points to the
43+
project.
4344

4445
.. code-block:: ini
4546
4647
# Content of pytask.ini, tox.ini or setup.cfg.
4748
4849
[pytask]
50+
paths = ./src/my_project
4951
50-
The file in combination with the section will signal the root of the project to pytask.
51-
This has two benefits.
52+
The file in combination with an empty section will signal the root of the project to
53+
pytask. This has two benefits.
5254

5355
1. pytask needs to save some data across executions. It will store this information in
5456
a ``.pytask.sqlite3`` database in the root folder.

src/_pytask/live.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import Generator
55
from typing import List
66
from typing import Optional
7-
from typing import Set
87
from typing import Union
98

109
import attr
@@ -136,7 +135,7 @@ class LiveExecution:
136135
_n_entries_in_table = attr.ib(type=int)
137136
_verbose = attr.ib(type=int)
138137
_editor_url_scheme = attr.ib(type=str)
139-
_running_tasks = attr.ib(factory=set, type=Set[str])
138+
_running_tasks = attr.ib(factory=dict, type=Dict[str, MetaTask])
140139
_reports = attr.ib(factory=list, type=List[Dict[str, Any]])
141140

142141
@hookimpl(hookwrapper=True)
@@ -208,8 +207,13 @@ def _generate_table(self, reduce_table: bool, sort_table: bool) -> Optional[Tabl
208207
),
209208
Text(report["outcome"].symbol, style=report["outcome"].style),
210209
)
211-
for running_task in self._running_tasks:
212-
table.add_row(running_task, "running")
210+
for task in self._running_tasks.values():
211+
table.add_row(
212+
format_task_id(
213+
task, editor_url_scheme=self._editor_url_scheme, short_name=True
214+
),
215+
"running",
216+
)
213217
else:
214218
table = None
215219

@@ -224,12 +228,12 @@ def _update_table(
224228

225229
def update_running_tasks(self, new_running_task: MetaTask) -> None:
226230
"""Add a new running task."""
227-
self._running_tasks.add(new_running_task.short_name)
231+
self._running_tasks[new_running_task.name] = new_running_task
228232
self._update_table()
229233

230234
def update_reports(self, new_report: ExecutionReport) -> None:
231235
"""Update the status of a running task by adding its report."""
232-
self._running_tasks.remove(new_report.task.short_name)
236+
self._running_tasks.pop(new_report.task.name)
233237
self._reports.append(
234238
{
235239
"name": new_report.task.short_name,

0 commit comments

Comments
 (0)