Skip to content

Commit 531acec

Browse files
committed
Push.
1 parent 17c5e77 commit 531acec

File tree

6 files changed

+36
-37
lines changed

6 files changed

+36
-37
lines changed

.github/workflows/continuous-integration-workflow.yml renamed to .github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Continuous Integration Workflow
1+
name: main
22

33
# Automatically cancel a previous run.
44
concurrency:
@@ -41,7 +41,7 @@ jobs:
4141

4242
- name: Run unit tests and doctests.
4343
shell: bash -l {0}
44-
run: tox -e pytest -- -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto
44+
run: tox -e pytest -- tests -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto
4545

4646
- name: Upload coverage report for unit tests and doctests.
4747
if: runner.os == 'Linux' && matrix.python-version == '3.9'
@@ -50,7 +50,7 @@ jobs:
5050

5151
- name: Run integration tests.
5252
shell: bash -l {0}
53-
run: tox -e pytest -- -m integration --cov=./ --cov-report=xml -n auto
53+
run: tox -e pytest -- tests -m integration --cov=./ --cov-report=xml -n auto
5454

5555
- name: Upload coverage reports of integration tests.
5656
if: runner.os == 'Linux' && matrix.python-version == '3.9'
@@ -59,7 +59,7 @@ jobs:
5959

6060
- name: Run end-to-end tests.
6161
shell: bash -l {0}
62-
run: tox -e pytest -- -m end_to_end --cov=./ --cov-report=xml -n auto
62+
run: tox -e pytest -- tests -m end_to_end --cov=./ --cov-report=xml -n auto
6363

6464
- name: Upload coverage reports of end-to-end tests.
6565
if: runner.os == 'Linux' && matrix.python-version == '3.9'

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ files, you can parallelize via threads.
5858
$ pytask --parallel-backend threads
5959
```
6060

61-
You can also set the options in one of the configuration files (`pytask.ini`, `tox.ini`,
62-
or `setup.cfg`).
61+
You can also set the options in a `pyproject.toml`.
6362

6463
```toml
6564
# This is the default configuration. Note that, parallelization is turned off.

src/pytask_parallel/config.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@ def _get_first_non_none_value(
6060
This function allows to prioritize information from many configurations by changing
6161
the order of the inputs while also providing a default.
6262
63-
Examples
64-
--------
65-
>>> _get_first_non_none_value({"a": None}, {"a": 1}, key="a")
66-
1
67-
>>> _get_first_non_none_value({"a": None}, {"a": None}, key="a", default="default")
68-
'default'
69-
>>> _get_first_non_none_value({}, {}, key="a", default="default")
70-
'default'
71-
>>> _get_first_non_none_value({"a": None}, {"a": "b"}, key="a")
72-
'b'
73-
7463
"""
7564
callback = (lambda x: x) if callback is None else callback # noqa: E731
7665
processed_values = (callback(config.get(key)) for config in configs)

src/pytask_parallel/execute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
@hookimpl
2121
def pytask_post_parse(config):
2222
"""Register the parallel backend."""
23-
if config["parallel_backend"] in ["loky", "processes"]:
23+
if config["parallel_backend"] in ("loky", "processes"):
2424
config["pm"].register(ProcessesNameSpace)
25-
elif config["parallel_backend"] in ["threads"]:
25+
elif config["parallel_backend"] in ("threads",):
2626
config["pm"].register(DefaultBackendNameSpace)
2727

2828

tests/test_config.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def test_interplay_between_debugging_and_parallel(tmp_path, pdb, n_workers, expe
2626

2727

2828
@pytest.mark.end_to_end
29-
@pytest.mark.parametrize("config_file", ["pytask.ini", "tox.ini", "setup.cfg"])
29+
@pytest.mark.parametrize(
30+
"config_file", ["pytask.ini", "tox.ini", "setup.cfg", "pyproject.toml"]
31+
)
3032
@pytest.mark.parametrize(
3133
"configuration_option, value, exit_code",
3234
[
@@ -43,15 +45,26 @@ def test_interplay_between_debugging_and_parallel(tmp_path, pdb, n_workers, expe
4345
],
4446
)
4547
def test_reading_values_from_config_file(
46-
tmp_path, config_file, configuration_option, value, exit_code
48+
tmp_path, capsys, config_file, configuration_option, value, exit_code
4749
):
48-
config = f"""
49-
[pytask]
50-
{configuration_option} = {value}
51-
"""
50+
if config_file == "pyproject.toml":
51+
config = f"""
52+
[tool.pytask.ini_options]
53+
{configuration_option} = {value!r}
54+
"""
55+
else:
56+
config = f"""
57+
[pytask]
58+
{configuration_option} = {value}
59+
"""
5260
tmp_path.joinpath(config_file).write_text(textwrap.dedent(config))
5361

5462
session = main({"paths": tmp_path})
63+
captured = capsys.readouterr()
64+
if config_file == "pyproject.toml":
65+
assert "WARNING" not in captured.out
66+
else:
67+
assert "WARNING" in captured.out
5568

5669
assert session.exit_code == exit_code
5770
if value == "auto":

tests/test_execute.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,13 @@ def task_2(produces):
171171
@pytest.mark.parametrize("parallel_backend", PARALLEL_BACKENDS)
172172
def test_stop_execution_when_max_failures_is_reached(tmp_path, parallel_backend):
173173
source = """
174-
import time
175174
import pytask
176175
177-
def task_1(): time.sleep(1)
178-
def task_2(): time.sleep(2); raise NotImplementedError
176+
def task_1(): pass
177+
def task_2(): pass; raise NotImplementedError
179178
180179
@pytask.mark.try_last
181-
def task_3():
182-
time.sleep(3)
180+
def task_3(): ...
183181
"""
184182
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
185183

@@ -192,7 +190,7 @@ def task_3():
192190
}
193191
)
194192

195-
assert session.exit_code == ExitCode.OK
193+
assert session.exit_code == ExitCode.FAILED
196194
assert len(session.tasks) == 3
197195
assert len(session.execution_reports) == 2
198196

@@ -206,25 +204,25 @@ def test_task_priorities(tmp_path, parallel_backend):
206204
207205
@pytask.mark.try_first
208206
def task_0():
209-
time.sleep(1)
207+
time.sleep(0.1)
210208
211209
def task_1():
212-
time.sleep(1)
210+
time.sleep(0.1)
213211
214212
@pytask.mark.try_last
215213
def task_2():
216-
time.sleep(1)
214+
time.sleep(0.1)
217215
218216
@pytask.mark.try_first
219217
def task_3():
220-
time.sleep(1)
218+
time.sleep(0.1)
221219
222220
def task_4():
223-
time.sleep(1)
221+
time.sleep(0.1)
224222
225223
@pytask.mark.try_last
226224
def task_5():
227-
time.sleep(1)
225+
time.sleep(0.1)
228226
"""
229227
tmp_path.joinpath("task_dummy.py").write_text(textwrap.dedent(source))
230228

0 commit comments

Comments
 (0)