diff --git a/CHANGES.md b/CHANGES.md index 92e67e5..3a0f3ec 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask-parallel) and - {pull}`62` deprecates Python 3.7. - {pull}`64` aligns pytask-parallel with pytask v0.4.0rc2. +- {pull}`66` deactivates parallelization for dry-runs. ## 0.3.1 - 2023-05-27 diff --git a/src/pytask_parallel/config.py b/src/pytask_parallel/config.py index 8258cb5..f87df89 100644 --- a/src/pytask_parallel/config.py +++ b/src/pytask_parallel/config.py @@ -34,5 +34,5 @@ def pytask_parse_config(config: dict[str, Any]) -> None: @hookimpl def pytask_post_parse(config: dict[str, Any]) -> None: """Disable parallelization if debugging is enabled.""" - if config["pdb"] or config["trace"]: + if config["pdb"] or config["trace"] or config["dry_run"]: config["n_workers"] = 1 diff --git a/tests/test_execute.py b/tests/test_execute.py index 88f88c2..f24e62b 100644 --- a/tests/test_execute.py +++ b/tests/test_execute.py @@ -256,3 +256,15 @@ def test_task_without_path_that_return(runner, tmp_path, parallel_backend): ) assert result.exit_code == ExitCode.OK assert tmp_path.joinpath("file.txt").exists() + + +@pytest.mark.end_to_end() +@pytest.mark.parametrize("flag", ["--pdb", "--trace", "--dry-run"]) +@pytest.mark.parametrize("parallel_backend", PARALLEL_BACKENDS) +def test_parallel_execution_is_deactivated(runner, tmp_path, flag, parallel_backend): + tmp_path.joinpath("task_example.py").write_text("def task_example(): pass") + result = runner.invoke( + cli, [tmp_path.as_posix(), "-n 2", "--parallel-backend", parallel_backend, flag] + ) + assert result.exit_code == ExitCode.OK + assert "Started 2 workers" not in result.output