@@ -81,10 +81,10 @@ def pytask_post_parse(config: dict[str, Any]) -> None:
81
81
82
82
if config ["verbose" ] >= 1 :
83
83
live_execution = LiveExecution (
84
- live_manager ,
85
- config ["n_entries_in_table" ],
86
- config ["verbose" ],
87
- config ["editor_url_scheme" ],
84
+ live_manager = live_manager ,
85
+ n_entries_in_table = config ["n_entries_in_table" ],
86
+ verbose = config ["verbose" ],
87
+ editor_url_scheme = config ["editor_url_scheme" ],
88
88
)
89
89
config ["pm" ].register (live_execution , "live_execution" )
90
90
@@ -95,7 +95,7 @@ def pytask_post_parse(config: dict[str, Any]) -> None:
95
95
@hookimpl (tryfirst = True )
96
96
def pytask_execute_build (session : Session ) -> None :
97
97
live_execution = session .config ["pm" ].get_plugin ("live_execution" )
98
- live_execution ._n_tasks = len (session .tasks )
98
+ live_execution .n_tasks = len (session .tasks )
99
99
100
100
101
101
@attr .s (eq = False )
@@ -147,25 +147,25 @@ def is_started(self) -> None:
147
147
return self ._live .is_started
148
148
149
149
150
- @attr .s (eq = False )
150
+ @attr .s (eq = False , kw_only = True )
151
151
class LiveExecution :
152
152
"""A class for managing the table displaying task progress during the execution."""
153
153
154
- _live_manager = attr .ib (type = LiveManager )
155
- _n_entries_in_table = attr .ib (type = int )
156
- _verbose = attr .ib (type = int )
157
- _editor_url_scheme = attr .ib (type = str )
158
- _running_tasks = attr .ib (factory = dict , type = Dict [ str , Task ])
154
+ live_manager = attr .ib (type = LiveManager )
155
+ n_entries_in_table = attr .ib (type = int )
156
+ verbose = attr .ib (type = int )
157
+ editor_url_scheme = attr .ib (type = str )
158
+ n_tasks = attr .ib (default = "x" , type = Union [ int , str ])
159
159
_reports = attr .ib (factory = list , type = List [Dict [str , Any ]])
160
- _n_tasks = attr .ib (default = "x" , type = Union [ int , str ])
160
+ _running_tasks = attr .ib (factory = dict , type = Dict [ str , Task ])
161
161
162
162
@hookimpl (hookwrapper = True )
163
163
def pytask_execute_build (self ) -> Generator [None , None , None ]:
164
164
"""Wrap the execution with the live manager and yield a complete table at the
165
165
end."""
166
- self ._live_manager .start ()
166
+ self .live_manager .start ()
167
167
yield
168
- self ._live_manager .stop (transient = True )
168
+ self .live_manager .stop (transient = True )
169
169
table = self ._generate_table (
170
170
reduce_table = False , sort_table = True , add_caption = False
171
171
)
@@ -195,9 +195,9 @@ def _generate_table(
195
195
if more entries are requested, the list is filled up with completed tasks.
196
196
197
197
"""
198
- n_reports_to_display = self ._n_entries_in_table - len (self ._running_tasks )
198
+ n_reports_to_display = self .n_entries_in_table - len (self ._running_tasks )
199
199
200
- if self ._verbose < 2 :
200
+ if self .verbose < 2 :
201
201
reports = [
202
202
report
203
203
for report in self ._reports
@@ -227,7 +227,7 @@ def _generate_table(
227
227
if add_caption :
228
228
caption_kwargs = {
229
229
"caption" : Text (
230
- f"Completed: { len (self ._reports )} /{ self ._n_tasks } " ,
230
+ f"Completed: { len (self ._reports )} /{ self .n_tasks } " ,
231
231
style = Style (dim = True , italic = False ),
232
232
),
233
233
"caption_justify" : "right" ,
@@ -243,15 +243,15 @@ def _generate_table(
243
243
table .add_row (
244
244
format_task_id (
245
245
report ["task" ],
246
- editor_url_scheme = self ._editor_url_scheme ,
246
+ editor_url_scheme = self .editor_url_scheme ,
247
247
short_name = True ,
248
248
),
249
249
Text (report ["outcome" ].symbol , style = report ["outcome" ].style ),
250
250
)
251
251
for task in self ._running_tasks .values ():
252
252
table .add_row (
253
253
format_task_id (
254
- task , editor_url_scheme = self ._editor_url_scheme , short_name = True
254
+ task , editor_url_scheme = self .editor_url_scheme , short_name = True
255
255
),
256
256
"running" ,
257
257
)
@@ -272,7 +272,7 @@ def _update_table(
272
272
table = self ._generate_table (
273
273
reduce_table = reduce_table , sort_table = sort_table , add_caption = add_caption
274
274
)
275
- self ._live_manager .update (table )
275
+ self .live_manager .update (table )
276
276
277
277
def update_running_tasks (self , new_running_task : Task ) -> None :
278
278
"""Add a new running task."""
0 commit comments