77from pytask import ExitCode
88from pytask import build
99from pytask import cli
10- from pytask_parallel .backends import PARALLEL_BACKENDS
1110from pytask_parallel .backends import ParallelBackend
1211from pytask_parallel .execute import _Sleeper
1312
@@ -19,18 +18,18 @@ class Session:
1918
2019
2120@pytest .mark .end_to_end ()
22- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
21+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
2322def test_parallel_execution (tmp_path , parallel_backend ):
2423 source = """
25- import pytask
24+ from pytask import Product
25+ from pathlib import Path
26+ from typing_extensions import Annotated
2627
27- @pytask.mark.produces("out_1.txt")
28- def task_1(produces):
29- produces.write_text("1")
28+ def task_1(path: Annotated[Path, Product] = Path("out_1.txt")):
29+ path.write_text("1")
3030
31- @pytask.mark.produces("out_2.txt")
32- def task_2(produces):
33- produces.write_text("2")
31+ def task_2(path: Annotated[Path, Product] = Path("out_2.txt")):
32+ path.write_text("2")
3433 """
3534 tmp_path .joinpath ("task_example.py" ).write_text (textwrap .dedent (source ))
3635 session = build (paths = tmp_path , n_workers = 2 , parallel_backend = parallel_backend )
@@ -41,18 +40,18 @@ def task_2(produces):
4140
4241
4342@pytest .mark .end_to_end ()
44- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
43+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
4544def test_parallel_execution_w_cli (runner , tmp_path , parallel_backend ):
4645 source = """
47- import pytask
46+ from pytask import Product
47+ from pathlib import Path
48+ from typing_extensions import Annotated
4849
49- @pytask.mark.produces("out_1.txt")
50- def task_1(produces):
51- produces.write_text("1")
50+ def task_1(path: Annotated[Path, Product] = Path("out_1.txt")):
51+ path.write_text("1")
5252
53- @pytask.mark.produces("out_2.txt")
54- def task_2(produces):
55- produces.write_text("2")
53+ def task_2(path: Annotated[Path, Product] = Path("out_2.txt")):
54+ path.write_text("2")
5655 """
5756 tmp_path .joinpath ("task_example.py" ).write_text (textwrap .dedent (source ))
5857 result = runner .invoke (
@@ -71,7 +70,7 @@ def task_2(produces):
7170
7271
7372@pytest .mark .end_to_end ()
74- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
73+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
7574def test_stop_execution_when_max_failures_is_reached (tmp_path , parallel_backend ):
7675 source = """
7776 import time
@@ -99,7 +98,7 @@ def task_3(): time.sleep(3)
9998
10099
101100@pytest .mark .end_to_end ()
102- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
101+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
103102def test_task_priorities (tmp_path , parallel_backend ):
104103 source = """
105104 import pytask
@@ -140,7 +139,7 @@ def task_5():
140139
141140
142141@pytest .mark .end_to_end ()
143- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
142+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
144143@pytest .mark .parametrize ("show_locals" , [True , False ])
145144def test_rendering_of_tracebacks_with_rich (
146145 runner , tmp_path , parallel_backend , show_locals
@@ -173,12 +172,12 @@ def task_raising_error():
173172)
174173def test_collect_warnings_from_parallelized_tasks (runner , tmp_path , parallel_backend ):
175174 source = """
176- import pytask
175+ from pytask import task
177176 import warnings
178177
179178 for i in range(2):
180179
181- @pytask.mark. task(id=str(i), kwargs={"produces": f"{i}.txt"})
180+ @task(id=str(i), kwargs={"produces": f"{i}.txt"})
182181 def task_example(produces):
183182 warnings.warn("This is a warning.")
184183 produces.touch()
@@ -222,7 +221,7 @@ def test_sleeper():
222221
223222
224223@pytest .mark .end_to_end ()
225- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
224+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
226225def test_task_that_return (runner , tmp_path , parallel_backend ):
227226 source = """
228227 from pathlib import Path
@@ -242,7 +241,7 @@ def task_example() -> Annotated[str, Path("file.txt")]:
242241
243242
244243@pytest .mark .end_to_end ()
245- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
244+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
246245def test_task_without_path_that_return (runner , tmp_path , parallel_backend ):
247246 source = """
248247 from pathlib import Path
@@ -264,7 +263,7 @@ def test_task_without_path_that_return(runner, tmp_path, parallel_backend):
264263
265264@pytest .mark .end_to_end ()
266265@pytest .mark .parametrize ("flag" , ["--pdb" , "--trace" , "--dry-run" ])
267- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
266+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
268267def test_parallel_execution_is_deactivated (runner , tmp_path , flag , parallel_backend ):
269268 tmp_path .joinpath ("task_example.py" ).write_text ("def task_example(): pass" )
270269 result = runner .invoke (
@@ -278,7 +277,7 @@ def test_parallel_execution_is_deactivated(runner, tmp_path, flag, parallel_back
278277@pytest .mark .end_to_end ()
279278@pytest .mark .parametrize ("code" , ["breakpoint()" , "import pdb; pdb.set_trace()" ])
280279@pytest .mark .parametrize (
281- "parallel_backend" , [i for i in PARALLEL_BACKENDS if i != ParallelBackend .THREADS ]
280+ "parallel_backend" , [i for i in ParallelBackend if i != ParallelBackend .THREADS ]
282281)
283282def test_raise_error_on_breakpoint (runner , tmp_path , code , parallel_backend ):
284283 tmp_path .joinpath ("task_example.py" ).write_text (f"def task_example(): { code } " )
@@ -290,7 +289,7 @@ def test_raise_error_on_breakpoint(runner, tmp_path, code, parallel_backend):
290289
291290
292291@pytest .mark .end_to_end ()
293- @pytest .mark .parametrize ("parallel_backend" , PARALLEL_BACKENDS )
292+ @pytest .mark .parametrize ("parallel_backend" , ParallelBackend )
294293def test_task_partialed (runner , tmp_path , parallel_backend ):
295294 source = """
296295 from pathlib import Path
0 commit comments