Skip to content

Deactivate parallelization for dry-runs. #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/pytask_parallel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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