Skip to content

[pre-commit.ci] pre-commit autoupdate #111

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
Sep 15, 2024
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
hooks:
- id: sort-all
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
rev: v0.6.4
hooks:
- id: ruff
- id: ruff-format
Expand Down Expand Up @@ -61,7 +61,7 @@ repos:
args: [--wrap, "88"]
files: (README\.md)
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
- repo: meta
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@


# Linkcode, based on numpy doc/source/conf.py
def linkcode_resolve(domain: str, info: dict[str, str]) -> str: # noqa: C901, PLR0912
def linkcode_resolve(domain: str, info: dict[str, str]) -> str: # noqa: C901
"""Determine the URL corresponding to Python object."""
if domain != "py":
return None
Expand Down
1 change: 1 addition & 0 deletions docs_src/custom_executors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from concurrent.futures import Executor

from my_project.executor import CustomExecutor

from pytask_parallel import ParallelBackend
from pytask_parallel import WorkerType
from pytask_parallel import registry
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def invoke(self, *args, **kwargs):
return super().invoke(*args, **kwargs)


@pytest.fixture()
@pytest.fixture
def runner():
return CustomCliRunner()

Expand Down
7 changes: 4 additions & 3 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
import pytest
from pytask import ExitCode
from pytask import cli

from pytask_parallel import ParallelBackend
from pytask_parallel import registry


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_error_requesting_custom_backend_without_registration(runner, tmp_path):
tmp_path.joinpath("task_example.py").write_text("def task_example(): pass")
result = runner.invoke(cli, [tmp_path.as_posix(), "--parallel-backend", "custom"])
assert result.exit_code == ExitCode.FAILED
assert "No registered parallel backend found" in result.output


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_error_while_instantiating_custom_backend(runner, tmp_path):
hook_source = """
from pytask_parallel import ParallelBackend, registry
Expand All @@ -34,7 +35,7 @@ def task_example(): pass
assert "Could not instantiate parallel backend 'custom'." in result.output


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_register_custom_backend(runner, tmp_path):
source = """
from loky import get_reusable_executor
Expand Down
3 changes: 2 additions & 1 deletion tests/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import pytest
from pytask import ExitCode
from pytask import cli

from pytask_parallel import ParallelBackend


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize(
"parallel_backend",
[
Expand Down
5 changes: 3 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import pytest
from pytask import ExitCode
from pytask import build

from pytask_parallel import ParallelBackend


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize(
("pdb", "n_workers", "expected"),
[
Expand All @@ -25,7 +26,7 @@ def test_interplay_between_debugging_and_parallel(tmp_path, pdb, n_workers, expe
assert session.config["n_workers"] == expected


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize(
("configuration_option", "value", "exit_code"),
[
Expand Down
30 changes: 15 additions & 15 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from pytask import ExitCode
from pytask import build
from pytask import cli

from pytask_parallel import ParallelBackend
from pytask_parallel.execute import _Sleeper

from tests.conftest import restore_sys_path_and_module_after_test_execution

_IMPLEMENTED_BACKENDS = [
Expand All @@ -25,7 +25,7 @@
]


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_parallel_execution(tmp_path, parallel_backend):
source = """
Expand All @@ -47,7 +47,7 @@ def task_2(path: Annotated[Path, Product] = Path("out_2.txt")):
assert tmp_path.joinpath("out_2.txt").exists()


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_parallel_execution_w_cli(runner, tmp_path, parallel_backend):
source = """
Expand Down Expand Up @@ -77,7 +77,7 @@ def task_2(path: Annotated[Path, Product] = Path("out_2.txt")):
assert tmp_path.joinpath("out_2.txt").exists()


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_stop_execution_when_max_failures_is_reached(tmp_path, parallel_backend):
source = """
Expand Down Expand Up @@ -105,7 +105,7 @@ def task_3(): time.sleep(3)
assert len(session.execution_reports) == 2


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_task_priorities(tmp_path, parallel_backend):
source = """
Expand Down Expand Up @@ -146,7 +146,7 @@ def task_5():
assert last_task_name.endswith(("task_2", "task_5"))


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
@pytest.mark.parametrize("show_locals", [True, False])
def test_rendering_of_tracebacks_with_rich(
Expand All @@ -172,7 +172,7 @@ def task_raising_error():
assert ("[0, 1, 2, 3, 4]" in result.output) is show_locals


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize(
"parallel_backend",
# Capturing warnings is not thread-safe.
Expand Down Expand Up @@ -207,7 +207,7 @@ def task_example(produces):
assert "task_example.py::task_example[1]" in warnings_block


@pytest.mark.unit()
@pytest.mark.unit
def test_sleeper():
sleeper = _Sleeper(timings=[1, 2, 3], timing_idx=0)

Expand All @@ -229,7 +229,7 @@ def test_sleeper():
assert 1 <= end - start <= 2


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_task_that_return(runner, tmp_path, parallel_backend):
source = """
Expand All @@ -249,7 +249,7 @@ def task_example() -> Annotated[str, Path("file.txt")]:
)


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_task_without_path_that_return(runner, tmp_path, parallel_backend):
source = """
Expand All @@ -270,7 +270,7 @@ def test_task_without_path_that_return(runner, tmp_path, parallel_backend):
)


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("flag", ["--pdb", "--trace", "--dry-run"])
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_parallel_execution_is_deactivated(runner, tmp_path, flag, parallel_backend):
Expand All @@ -283,7 +283,7 @@ def test_parallel_execution_is_deactivated(runner, tmp_path, flag, parallel_back
assert "Started 2 workers" not in result.output


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("code", ["breakpoint()", "import pdb; pdb.set_trace()"])
@pytest.mark.parametrize(
"parallel_backend",
Expand All @@ -298,7 +298,7 @@ def test_raise_error_on_breakpoint(runner, tmp_path, code, parallel_backend):
assert "You cannot use 'breakpoint()'" in result.output


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_task_partialed(runner, tmp_path, parallel_backend):
source = """
Expand All @@ -321,7 +321,7 @@ def create_text(text):
assert tmp_path.joinpath("file.txt").exists()


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_execute_tasks_and_pass_values_by_python_node_return(
runner, tmp_path, parallel_backend
Expand Down Expand Up @@ -349,7 +349,7 @@ def task_create_file(
assert tmp_path.joinpath("file.txt").read_text() == "This is the text."


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
@pytest.mark.parametrize("parallel_backend", _IMPLEMENTED_BACKENDS)
def test_execute_tasks_and_pass_values_by_python_node_product(
runner, tmp_path, parallel_backend
Expand Down
7 changes: 4 additions & 3 deletions tests/test_jupyter/test_functional_interface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"source": [
"from pathlib import Path\n",
"\n",
"from typing_extensions import Annotated\n",
"\n",
"import pytask\n",
"from pytask import ExitCode, PathNode, PythonNode"
"from pytask import ExitCode\n",
"from pytask import PathNode\n",
"from pytask import PythonNode\n",
"from typing_extensions import Annotated"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"source": [
"from pathlib import Path\n",
"\n",
"from typing_extensions import Annotated\n",
"\n",
"import pytask\n",
"from pytask import ExitCode, PathNode, PythonNode"
"from pytask import ExitCode\n",
"from pytask import PathNode\n",
"from pytask import PythonNode\n",
"from typing_extensions import Annotated"
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def custom_builder(n_workers):
tmp_path.joinpath("config.py").write_text(textwrap.dedent(source))


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_python_node(runner, tmp_path):
source = """
from pathlib import Path
Expand Down Expand Up @@ -65,7 +65,7 @@ def task_third(
assert tmp_path.joinpath("output.txt").read_text() == "Hello World!"


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_local_path_as_input(runner, tmp_path):
source = """
from pathlib import Path
Expand All @@ -92,7 +92,7 @@ def task_example(path: Path = Path("in.txt")) -> Annotated[str, Path("output.txt
assert tmp_path.joinpath("output.txt").read_text() == "Hello World!"


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_local_path_as_product(runner, tmp_path):
source = """
from pytask import Product
Expand All @@ -119,7 +119,7 @@ def task_example(path: Annotated[Path, Product] = Path("output.txt")):
assert tmp_path.joinpath("output.txt").read_text() == "Hello World!"


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_local_path_as_return(runner, tmp_path):
source = """
from pathlib import Path
Expand All @@ -145,7 +145,7 @@ def task_example() -> Annotated[str, Path("output.txt")]:
assert tmp_path.joinpath("output.txt").read_text() == "Hello World!"


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_pickle_node_with_local_path_as_input(runner, tmp_path):
source = """
from pytask import PickleNode
Expand Down Expand Up @@ -175,7 +175,7 @@ def task_example(
assert tmp_path.joinpath("output.txt").read_text() == "Hello World!"


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_pickle_node_with_local_path_as_product(runner, tmp_path):
source = """
from pytask import PickleNode, Product
Expand Down Expand Up @@ -204,7 +204,7 @@ def task_example(
assert pickle.loads(tmp_path.joinpath("data.pkl").read_bytes()) == "Hello World!" # noqa: S301


@pytest.mark.end_to_end()
@pytest.mark.end_to_end
def test_pickle_node_with_local_path_as_return(runner, tmp_path):
source = """
from pytask import PickleNode
Expand Down
Loading