Skip to content

Commit 2781f71

Browse files
authored
Enable --max-failures. (#9)
1 parent d535f56 commit 2781f71

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

.conda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ requirements:
2121
run:
2222
- python >=3.6
2323
- cloudpickle
24-
- pytask >=0.0.6
24+
- pytask >=0.0.11
2525

2626
test:
2727
requires:

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ all releases are available on `Anaconda.org
1111
------------------
1212

1313
- :gh:`5` fixes the CI and other smaller issues.
14+
- :gh:`9` enables --max-failures. Closes :gh:`7`.
1415

1516

1617
0.0.4 - 2020-10-30

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- conda-verify
1313

1414
# Package dependencies
15-
- pytask >= 0.0.6
15+
- pytask >= 0.0.11
1616
- cloudpickle
1717
- loky
1818

src/pytask_parallel/execute.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def pytask_execute_build(session):
4949
5050
"""
5151
if session.config["n_workers"] > 1:
52-
reports = []
52+
reports = session.execution_reports
5353
running_tasks = {}
5454

5555
parallel_backend = PARALLEL_BACKENDS[session.config["parallel_backend"]]
@@ -123,9 +123,12 @@ def pytask_execute_build(session):
123123
)
124124
reports.append(report)
125125

126-
time.sleep(session.config["delay"])
126+
if session.should_stop:
127+
break
128+
else:
129+
time.sleep(session.config["delay"])
127130

128-
return reports
131+
return True
129132

130133

131134
class ProcessesNameSpace:

tests/test_execute.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,28 @@ def task_2(produces):
163163
)
164164

165165
assert 3 < session.execution_end - session.execution_start < 10
166+
167+
168+
@pytest.mark.end_to_end
169+
@pytest.mark.parametrize("parallel_backend", PARALLEL_BACKENDS)
170+
def test_stop_execution_when_max_failures_is_reached(tmp_path, parallel_backend):
171+
source = """
172+
import time
173+
174+
def task_3(): raise NotImplmentedError
175+
def task_2(): time.sleep(2); raise NotImplementedError
176+
def task_1(): pass
177+
"""
178+
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
179+
180+
session = main(
181+
{
182+
"paths": tmp_path,
183+
"n_workers": 2,
184+
"parallel_backend": parallel_backend,
185+
"max_failures": 1,
186+
}
187+
)
188+
189+
assert len(session.tasks) == 3
190+
assert len(session.execution_reports) == 2

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ basepython = python
1010
conda_deps =
1111
cloudpickle
1212
loky
13-
pytask >=0.0.6
13+
pytask >=0.0.11
1414
pytest
1515
pytest-cov
1616
pytest-xdist

0 commit comments

Comments
 (0)