File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ all releases are available on `Anaconda.org
11
11
------------------
12
12
13
13
- :gh: `5 ` fixes the CI and other smaller issues.
14
+ - :gh: `8 ` aligns pytask-parallel with task priorities in pytask v0.0.11.
14
15
- :gh: `9 ` enables --max-failures. Closes :gh: `7 `.
15
16
16
17
Original file line number Diff line number Diff line change @@ -118,6 +118,8 @@ def pytask_execute_build(session):
118
118
119
119
120
120
class ProcessesNameSpace :
121
+ """The name space for hooks related to processes."""
122
+
121
123
@hookimpl (tryfirst = True )
122
124
def pytask_execute_task (session , task ): # noqa: N805
123
125
"""Execute a task.
@@ -142,6 +144,8 @@ def unserialize_and_execute_task(bytes_):
142
144
143
145
144
146
class DefaultBackendNameSpace :
147
+ """The name space for hooks related to threads."""
148
+
145
149
@hookimpl (tryfirst = True )
146
150
def pytask_execute_task (session , task ): # noqa: N805
147
151
"""Execute a task.
Original file line number Diff line number Diff line change 2
2
import textwrap
3
3
from time import time
4
4
5
+ import attr
5
6
import pytest
6
7
from pytask import cli
7
8
from pytask import main
10
11
from pytask_parallel .execute import ProcessesNameSpace
11
12
12
13
14
+ @attr .s
13
15
class DummyTask :
14
- def __init__ (self , function ):
15
- self .function = function
16
+ function = attr .ib ()
16
17
17
18
def execute (self ):
18
19
self .function ()
@@ -188,3 +189,38 @@ def task_1(): pass
188
189
189
190
assert len (session .tasks ) == 3
190
191
assert len (session .execution_reports ) == 2
192
+
193
+
194
+ @pytest .mark .end_to_end
195
+ @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
196
+ def test_task_priorities (tmp_path , parallel_backend ):
197
+ source = """
198
+ import pytask
199
+ import time
200
+
201
+ @pytask.mark.try_first
202
+ def task_0():
203
+ time.sleep(1)
204
+
205
+ def task_1():
206
+ time.sleep(1)
207
+
208
+ @pytask.mark.try_last
209
+ def task_2():
210
+ time.sleep(1)
211
+
212
+ def task_3():
213
+ time.sleep(1)
214
+
215
+ def task_4():
216
+ time.sleep(1)
217
+ """
218
+ tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (source ))
219
+
220
+ session = main (
221
+ {"paths" : tmp_path , "parallel_backend" : parallel_backend , "n_workers" : 2 }
222
+ )
223
+
224
+ assert session .exit_code == 0
225
+ assert session .execution_reports [0 ].task .name .endswith ("task_0" )
226
+ assert session .execution_reports [- 1 ].task .name .endswith ("task_2" )
You can’t perform that action at this time.
0 commit comments