Skip to content

Commit d15d7bb

Browse files
authored
Deactivate parallelization for dry-runs. (#66)
1 parent c3e5721 commit d15d7bb

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask-parallel) and
99

1010
- {pull}`62` deprecates Python 3.7.
1111
- {pull}`64` aligns pytask-parallel with pytask v0.4.0rc2.
12+
- {pull}`66` deactivates parallelization for dry-runs.
1213

1314
## 0.3.1 - 2023-05-27
1415

src/pytask_parallel/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ def pytask_parse_config(config: dict[str, Any]) -> None:
3434
@hookimpl
3535
def pytask_post_parse(config: dict[str, Any]) -> None:
3636
"""Disable parallelization if debugging is enabled."""
37-
if config["pdb"] or config["trace"]:
37+
if config["pdb"] or config["trace"] or config["dry_run"]:
3838
config["n_workers"] = 1

tests/test_execute.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,15 @@ def test_task_without_path_that_return(runner, tmp_path, parallel_backend):
256256
)
257257
assert result.exit_code == ExitCode.OK
258258
assert tmp_path.joinpath("file.txt").exists()
259+
260+
261+
@pytest.mark.end_to_end()
262+
@pytest.mark.parametrize("flag", ["--pdb", "--trace", "--dry-run"])
263+
@pytest.mark.parametrize("parallel_backend", PARALLEL_BACKENDS)
264+
def test_parallel_execution_is_deactivated(runner, tmp_path, flag, parallel_backend):
265+
tmp_path.joinpath("task_example.py").write_text("def task_example(): pass")
266+
result = runner.invoke(
267+
cli, [tmp_path.as_posix(), "-n 2", "--parallel-backend", parallel_backend, flag]
268+
)
269+
assert result.exit_code == ExitCode.OK
270+
assert "Started 2 workers" not in result.output

0 commit comments

Comments
 (0)