Skip to content

Commit c6f9bfc

Browse files
committed
Initial commit.
0 parents  commit c6f9bfc

12 files changed

+338
-0
lines changed

.github/workflows/main.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: main
2+
3+
# Automatically cancel a previous run.
4+
concurrency:
5+
group: ${{ github.head_ref || github.run_id }}
6+
cancel-in-progress: true
7+
8+
env:
9+
CONDA_EXE: mamba
10+
11+
on:
12+
push:
13+
branches:
14+
- main
15+
pull_request:
16+
branches:
17+
- '*'
18+
19+
jobs:
20+
21+
run-type-checking:
22+
23+
name: Run tests for type-checking
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version-file: .python-version
31+
allow-prereleases: true
32+
cache: pip
33+
- run: pip install tox-uv
34+
- run: tox -e typing

.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Files
2+
.coverage
3+
coverage.*
4+
5+
# Folders
6+
.idea
7+
.ipynb_checkpoints
8+
.tox
9+
.vscode
10+
_build
11+
__pycache__
12+
13+
*.egg-info
14+
15+
.pytask
16+
build
17+
dist
18+
src/project/_version.py
19+
.mypy_cache
20+
.pytest_cache
21+
.ruff_cache
22+
.venv
23+
bld

.pre-commit-config.yaml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: check-added-large-files
6+
args: ['--maxkb=25']
7+
- id: check-case-conflict
8+
- id: check-merge-conflict
9+
- id: check-vcs-permalinks
10+
- id: check-yaml
11+
- id: end-of-file-fixer
12+
- id: fix-byte-order-marker
13+
- id: mixed-line-ending
14+
- id: no-commit-to-branch
15+
args: [--branch, main]
16+
- repo: https://github.com/pre-commit/pygrep-hooks
17+
rev: v1.10.0
18+
hooks:
19+
- id: python-check-blanket-noqa
20+
- id: python-check-mock-methods
21+
- id: python-no-eval
22+
- id: python-no-log-warn
23+
- id: python-use-type-annotations
24+
- id: text-unicode-replacement-char
25+
- repo: https://github.com/astral-sh/ruff-pre-commit
26+
rev: v0.3.4
27+
hooks:
28+
- id: ruff
29+
- id: ruff-format
30+
- repo: https://github.com/dosisod/refurb
31+
rev: v2.0.0
32+
hooks:
33+
- id: refurb
34+
- repo: https://github.com/executablebooks/mdformat
35+
rev: 0.7.17
36+
hooks:
37+
- id: mdformat
38+
additional_dependencies: [
39+
mdformat-myst,
40+
mdformat-black,
41+
mdformat-pyproject,
42+
]
43+
files: (README\.md)
44+
# Conflicts with admonitions.
45+
# - repo: https://github.com/executablebooks/mdformat
46+
# rev: 0.7.17
47+
# hooks:
48+
# - id: mdformat
49+
# additional_dependencies: [
50+
# mdformat-gfm,
51+
# mdformat-black,
52+
# ]
53+
# args: [--wrap, "88"]
54+
- repo: https://github.com/codespell-project/codespell
55+
rev: v2.2.6
56+
hooks:
57+
- id: codespell
58+
# - repo: https://github.com/pre-commit/mirrors-mypy
59+
# rev: 'v1.9.0'
60+
# hooks:
61+
# - id: mypy
62+
# args: [
63+
# --no-strict-optional,
64+
# --ignore-missing-imports,
65+
# ]
66+
# additional_dependencies: [
67+
# attrs,
68+
# cloudpickle,
69+
# loky,
70+
# "git+https://github.com/pytask-dev/pytask.git@main",
71+
# rich,
72+
# types-click,
73+
# types-setuptools,
74+
# ]
75+
# pass_filenames: false
76+
- repo: meta
77+
hooks:
78+
- id: check-hooks-apply
79+
- id: check-useless-excludes
80+
# - id: identity # Prints all files passed to pre-commits. Debugging.

.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12.2

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# coiled-project
2+
3+
This project allows testing all possible interactions between pytask, pytask-parallel
4+
and coiled.

pyproject.toml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[project]
2+
name = "project"
3+
version = "0.1.0"
4+
description = "A project to test coiled."
5+
authors = [
6+
{ name = "Tobias Raabe", email = "[email protected]" }
7+
]
8+
dependencies = [
9+
"pytask>=0.4.5",
10+
"pytask-parallel[coiled]>=0.4.1",
11+
"s3fs>=2024.3.1",
12+
]
13+
readme = "README.md"
14+
requires-python = ">= 3.8"
15+
16+
[build-system]
17+
requires = ["hatchling"]
18+
build-backend = "hatchling.build"
19+
20+
[tool.mypy]
21+
files = ["src"]
22+
check_untyped_defs = true
23+
disallow_any_generics = true
24+
disallow_incomplete_defs = true
25+
disallow_untyped_defs = true
26+
no_implicit_optional = true
27+
warn_redundant_casts = true
28+
warn_unused_ignores = true
29+
ignore_missing_imports = true
30+
31+
[[tool.mypy.overrides]]
32+
module = "tests.*"
33+
disallow_untyped_defs = false
34+
ignore_errors = true
35+
36+
[tool.rye]
37+
managed = true
38+
dev-dependencies = []
39+
40+
[tool.hatch.metadata]
41+
allow-direct-references = true
42+
43+
[tool.ruff]
44+
target-version = "py38"
45+
fix = true
46+
unsafe-fixes = true
47+
48+
[tool.ruff.lint]
49+
extend-ignore = [
50+
"ANN101", # type annotating self
51+
"ANN102", # type annotating cls
52+
"ANN401", # flake8-annotate typing.Any
53+
"COM812", # Comply with ruff-format.
54+
"ISC001", # Comply with ruff-format.
55+
"D",
56+
]
57+
select = ["ALL"]
58+
59+
[tool.ruff.lint.per-file-ignores]
60+
"src/*" = ["S101"]
61+
"tests/*" = ["D", "ANN", "PLR2004", "S101"]
62+
63+
[tool.ruff.lint.isort]
64+
force-single-line = true
65+
66+
[tool.ruff.lint.pydocstyle]
67+
convention = "numpy"
68+
69+
[tool.pytask.ini_options]

src/project/__init__.py

Whitespace-only changes.

src/project/config.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
from typing import TYPE_CHECKING
5+
6+
import coiled
7+
from pytask import DataCatalog
8+
from pytask_parallel import ParallelBackend
9+
from pytask_parallel import registry
10+
11+
if TYPE_CHECKING:
12+
from concurrent.futures import Executor
13+
14+
SRC = Path(__file__).parent
15+
BLD = SRC.parent.parent / "bld"
16+
17+
18+
def _build_client(n_workers: int) -> Executor:
19+
return (
20+
coiled.Cluster(n_workers=n_workers, name="coiled-project")
21+
.get_client()
22+
.get_executor()
23+
)
24+
25+
26+
registry.register_parallel_backend(ParallelBackend.CUSTOM, _build_client, remote=True)
27+
28+
29+
data_catalog = DataCatalog()

src/project/task_data_catalog.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from typing import cast
2+
3+
from pytask import PickleNode
4+
from pytask import Product
5+
from typing_extensions import Annotated
6+
7+
from project.config import BLD
8+
from project.config import data_catalog
9+
10+
11+
def task_create_data_catalog_node(
12+
node: Annotated[PickleNode, Product] = cast(PickleNode, data_catalog["first"]), # noqa: B008
13+
) -> None:
14+
node.save("Hello,")
15+
16+
17+
def task_use_data_catalog_return(
18+
text: Annotated[str, data_catalog["first"]],
19+
) -> Annotated[str, data_catalog["second"]]:
20+
return text + " World!"
21+
22+
23+
def task_data_catalog_check(
24+
text: Annotated[str, data_catalog["second"]],
25+
) -> Annotated[str, BLD / "data_catalog" / "output.txt"]:
26+
assert text == "Hello, World!"
27+
return text

src/project/task_local_path.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from pathlib import Path
2+
3+
from pytask import Product
4+
from typing_extensions import Annotated
5+
6+
from project.config import BLD
7+
8+
9+
def task_create_local_path_node(
10+
path: Annotated[Path, Product] = BLD / "local_path" / "first.txt",
11+
) -> None:
12+
path.write_text("Hello,")
13+
14+
15+
def task_use_local_path_return(
16+
path: Annotated[Path, BLD / "local_path" / "first.txt"],
17+
) -> Annotated[str, BLD / "local_path" / "second.txt"]:
18+
return path.read_text() + " World!"
19+
20+
21+
def task_local_file_check(path: Path = BLD / "local_path" / "second.txt") -> None:
22+
assert path.read_text() == "Hello, World!"

src/project/task_python_nodes.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pytask import Product
2+
from pytask import PythonNode
3+
from typing_extensions import Annotated
4+
5+
from project.config import BLD
6+
7+
first_part = PythonNode()
8+
9+
10+
def task_first(node: Annotated[PythonNode, first_part, Product]) -> None:
11+
node.save("Hello ")
12+
13+
14+
full_text = PythonNode()
15+
16+
17+
def task_second(first_part: Annotated[str, first_part]) -> Annotated[str, full_text]:
18+
return first_part + "World!"
19+
20+
21+
def task_third(
22+
full_text: Annotated[str, full_text],
23+
) -> Annotated[str, BLD / "python_nodes" / "output.txt"]:
24+
assert full_text == "Hello World!"
25+
return full_text

tox.ini

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[tox]
2+
requires = tox>=4
3+
envlist = test
4+
5+
[testenv]
6+
package = editable
7+
8+
[testenv:typing]
9+
deps =
10+
mypy
11+
git+https://github.com/pytask-dev/pytask.git@main
12+
git+https://github.com/pytask-dev/pytask-parallel.git@main
13+
extras =
14+
dask
15+
coiled
16+
commands = mypy
17+
18+
[testenv:test]
19+
extras = test
20+
deps =
21+
git+https://github.com/pytask-dev/pytask.git@main
22+
git+https://github.com/pytask-dev/pytask-parallel.git@main
23+
commands =
24+
pytest {posargs}

0 commit comments

Comments
 (0)