pipefunc 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pipefunc-0.0.0/.devcontainer/Dockerfile +18 -0
- pipefunc-0.0.0/.devcontainer/devcontainer.json +43 -0
- pipefunc-0.0.0/.gitattributes +2 -0
- pipefunc-0.0.0/.github/doc-string-check.py +284 -0
- pipefunc-0.0.0/.github/generate-release-notes.py +399 -0
- pipefunc-0.0.0/.github/pr-title-checker-config.json +26 -0
- pipefunc-0.0.0/.github/release-drafter.yml +57 -0
- pipefunc-0.0.0/.github/renovate.json +35 -0
- pipefunc-0.0.0/.github/update-environment.py +144 -0
- pipefunc-0.0.0/.github/workflows/codeql.yml +41 -0
- pipefunc-0.0.0/.github/workflows/codspeed.yml +46 -0
- pipefunc-0.0.0/.github/workflows/doc-string-check.yml +33 -0
- pipefunc-0.0.0/.github/workflows/pr-title-checker.yml +53 -0
- pipefunc-0.0.0/.github/workflows/pytest-micromamba.yml +48 -0
- pipefunc-0.0.0/.github/workflows/pytest-uv.yml +49 -0
- pipefunc-0.0.0/.github/workflows/pythonpublish.yml +22 -0
- pipefunc-0.0.0/.github/workflows/release-drafter.yaml +16 -0
- pipefunc-0.0.0/.github/workflows/toc.yaml +12 -0
- pipefunc-0.0.0/.github/workflows/update-environment.yaml +46 -0
- pipefunc-0.0.0/.gitignore +121 -0
- pipefunc-0.0.0/.pre-commit-config.yaml +31 -0
- pipefunc-0.0.0/.readthedocs.yml +16 -0
- pipefunc-0.0.0/.vscode/launch.json +14 -0
- pipefunc-0.0.0/.vscode/settings.json +7 -0
- pipefunc-0.0.0/AUTHORS.md +3 -0
- pipefunc-0.0.0/CHANGELOG.md +2521 -0
- pipefunc-0.0.0/LICENSE +7 -0
- pipefunc-0.0.0/MANIFEST.in +3 -0
- pipefunc-0.0.0/PKG-INFO +355 -0
- pipefunc-0.0.0/README.md +175 -0
- pipefunc-0.0.0/docs/.gitignore +1 -0
- pipefunc-0.0.0/docs/Makefile +20 -0
- pipefunc-0.0.0/docs/environment-sphinx.yml +57 -0
- pipefunc-0.0.0/docs/source/_static/custom.css +15 -0
- pipefunc-0.0.0/docs/source/changelog.md +1 -0
- pipefunc-0.0.0/docs/source/concepts/adaptive-integration.md +241 -0
- pipefunc-0.0.0/docs/source/concepts/caching.md +302 -0
- pipefunc-0.0.0/docs/source/concepts/cli.md +265 -0
- pipefunc-0.0.0/docs/source/concepts/error-handling.md +87 -0
- pipefunc-0.0.0/docs/source/concepts/execution-and-parallelism.md +168 -0
- pipefunc-0.0.0/docs/source/concepts/function-io.md +532 -0
- pipefunc-0.0.0/docs/source/concepts/index.md +59 -0
- pipefunc-0.0.0/docs/source/concepts/mapspec.md +448 -0
- pipefunc-0.0.0/docs/source/concepts/overhead-and-efficiency.md +76 -0
- pipefunc-0.0.0/docs/source/concepts/parameter-scopes.md +158 -0
- pipefunc-0.0.0/docs/source/concepts/parameter-sweeps.md +55 -0
- pipefunc-0.0.0/docs/source/concepts/resource-management.md +156 -0
- pipefunc-0.0.0/docs/source/concepts/simplifying-pipelines.md +92 -0
- pipefunc-0.0.0/docs/source/concepts/slurm.md +373 -0
- pipefunc-0.0.0/docs/source/concepts/testing.md +61 -0
- pipefunc-0.0.0/docs/source/concepts/type-checking.md +110 -0
- pipefunc-0.0.0/docs/source/concepts/variants.md +152 -0
- pipefunc-0.0.0/docs/source/conf.py +295 -0
- pipefunc-0.0.0/docs/source/examples/basic-usage.md +76 -0
- pipefunc-0.0.0/docs/source/examples/image-processing.md +112 -0
- pipefunc-0.0.0/docs/source/examples/index.md +41 -0
- pipefunc-0.0.0/docs/source/examples/nlp-text-summarization.md +129 -0
- pipefunc-0.0.0/docs/source/examples/physics-simulation.md +278 -0
- pipefunc-0.0.0/docs/source/examples/sensor-data-processing.md +186 -0
- pipefunc-0.0.0/docs/source/examples/weather-simulation.md +86 -0
- pipefunc-0.0.0/docs/source/faq.md +197 -0
- pipefunc-0.0.0/docs/source/index.md +33 -0
- pipefunc-0.0.0/docs/source/reference/index.md +28 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.cache.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.helpers.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.lazy.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.map.adaptive.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.map.adaptive_scheduler.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.map.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.map.xarray.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.resources.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.sweep.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.testing.md +8 -0
- pipefunc-0.0.0/docs/source/reference/pipefunc.typing.md +8 -0
- pipefunc-0.0.0/environment.yml +50 -0
- pipefunc-0.0.0/example.ipynb +1529 -0
- pipefunc-0.0.0/get-notebooks.py +205 -0
- pipefunc-0.0.0/pipefunc/__init__.py +22 -0
- pipefunc-0.0.0/pipefunc/_adaptive.py +109 -0
- pipefunc-0.0.0/pipefunc/_pipefunc.py +1651 -0
- pipefunc-0.0.0/pipefunc/_pipeline/__init__.py +0 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_autodoc.py +297 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_base.py +2593 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_cache.py +132 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_cli.py +310 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_mapspec.py +121 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_pydantic.py +144 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_simplify.py +250 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_types.py +5 -0
- pipefunc-0.0.0/pipefunc/_pipeline/_validation.py +135 -0
- pipefunc-0.0.0/pipefunc/_plotting.py +948 -0
- pipefunc-0.0.0/pipefunc/_plotting_utils.py +222 -0
- pipefunc-0.0.0/pipefunc/_profile.py +183 -0
- pipefunc-0.0.0/pipefunc/_utils.py +455 -0
- pipefunc-0.0.0/pipefunc/_variant_pipeline.py +637 -0
- pipefunc-0.0.0/pipefunc/_version.py +17 -0
- pipefunc-0.0.0/pipefunc/_widgets/__init__.py +3 -0
- pipefunc-0.0.0/pipefunc/_widgets/progress.py +349 -0
- pipefunc-0.0.0/pipefunc/cache.py +857 -0
- pipefunc-0.0.0/pipefunc/exceptions.py +5 -0
- pipefunc-0.0.0/pipefunc/helpers.py +121 -0
- pipefunc-0.0.0/pipefunc/lazy.py +117 -0
- pipefunc-0.0.0/pipefunc/map/LICENSE +25 -0
- pipefunc-0.0.0/pipefunc/map/__init__.py +35 -0
- pipefunc-0.0.0/pipefunc/map/_adaptive_scheduler_slurm_executor.py +263 -0
- pipefunc-0.0.0/pipefunc/map/_load.py +56 -0
- pipefunc-0.0.0/pipefunc/map/_mapspec.py +537 -0
- pipefunc-0.0.0/pipefunc/map/_prepare.py +252 -0
- pipefunc-0.0.0/pipefunc/map/_progress.py +89 -0
- pipefunc-0.0.0/pipefunc/map/_result.py +96 -0
- pipefunc-0.0.0/pipefunc/map/_run.py +1371 -0
- pipefunc-0.0.0/pipefunc/map/_run_eager.py +500 -0
- pipefunc-0.0.0/pipefunc/map/_run_eager_async.py +290 -0
- pipefunc-0.0.0/pipefunc/map/_run_info.py +402 -0
- pipefunc-0.0.0/pipefunc/map/_shapes.py +94 -0
- pipefunc-0.0.0/pipefunc/map/_storage_array/__init__.py +1 -0
- pipefunc-0.0.0/pipefunc/map/_storage_array/_base.py +240 -0
- pipefunc-0.0.0/pipefunc/map/_storage_array/_dict.py +288 -0
- pipefunc-0.0.0/pipefunc/map/_storage_array/_file.py +296 -0
- pipefunc-0.0.0/pipefunc/map/_storage_array/_zarr.py +441 -0
- pipefunc-0.0.0/pipefunc/map/_types.py +5 -0
- pipefunc-0.0.0/pipefunc/map/adaptive.py +654 -0
- pipefunc-0.0.0/pipefunc/map/adaptive_scheduler.py +294 -0
- pipefunc-0.0.0/pipefunc/map/xarray.py +190 -0
- pipefunc-0.0.0/pipefunc/py.typed +0 -0
- pipefunc-0.0.0/pipefunc/resources.py +347 -0
- pipefunc-0.0.0/pipefunc/sweep.py +526 -0
- pipefunc-0.0.0/pipefunc/testing.py +70 -0
- pipefunc-0.0.0/pipefunc/typing.py +356 -0
- pipefunc-0.0.0/pyproject.toml +204 -0
- pipefunc-0.0.0/tests/__init__.py +1 -0
- pipefunc-0.0.0/tests/conftest.py +24 -0
- pipefunc-0.0.0/tests/helpers.py +9 -0
- pipefunc-0.0.0/tests/map/__init__.py +1 -0
- pipefunc-0.0.0/tests/map/storage/__init__.py +1 -0
- pipefunc-0.0.0/tests/map/storage/test_all_storage.py +649 -0
- pipefunc-0.0.0/tests/map/storage/test_file.py +225 -0
- pipefunc-0.0.0/tests/map/storage/test_zarr.py +285 -0
- pipefunc-0.0.0/tests/map/test_adaptive.py +528 -0
- pipefunc-0.0.0/tests/map/test_adaptive_scheduler.py +528 -0
- pipefunc-0.0.0/tests/map/test_adaptive_slurm_executor.py +337 -0
- pipefunc-0.0.0/tests/map/test_eager_scheduler.py +636 -0
- pipefunc-0.0.0/tests/map/test_fixed_indices.py +125 -0
- pipefunc-0.0.0/tests/map/test_map.py +1952 -0
- pipefunc-0.0.0/tests/map/test_map_chunking.py +125 -0
- pipefunc-0.0.0/tests/map/test_mapspec.py +516 -0
- pipefunc-0.0.0/tests/map/test_result.py +25 -0
- pipefunc-0.0.0/tests/map/test_run_dynamic_internal_shape.py +655 -0
- pipefunc-0.0.0/tests/map/test_sweeps.py +46 -0
- pipefunc-0.0.0/tests/map/test_xarray.py +230 -0
- pipefunc-0.0.0/tests/test_adaptive_run.py +97 -0
- pipefunc-0.0.0/tests/test_autodoc.py +617 -0
- pipefunc-0.0.0/tests/test_benchmark.py +124 -0
- pipefunc-0.0.0/tests/test_cache.py +549 -0
- pipefunc-0.0.0/tests/test_cache_memoize.py +291 -0
- pipefunc-0.0.0/tests/test_cache_to_hashable.py +180 -0
- pipefunc-0.0.0/tests/test_cli.py +236 -0
- pipefunc-0.0.0/tests/test_helpers.py +129 -0
- pipefunc-0.0.0/tests/test_lazy.py +169 -0
- pipefunc-0.0.0/tests/test_nested_pipefunc.py +818 -0
- pipefunc-0.0.0/tests/test_perf.py +50 -0
- pipefunc-0.0.0/tests/test_pipefunc.py +685 -0
- pipefunc-0.0.0/tests/test_pipefunc_annotations.py +120 -0
- pipefunc-0.0.0/tests/test_pipeline.py +1213 -0
- pipefunc-0.0.0/tests/test_pipeline_annotations.py +47 -0
- pipefunc-0.0.0/tests/test_pipeline_cache.py +290 -0
- pipefunc-0.0.0/tests/test_pipeline_lazy.py +107 -0
- pipefunc-0.0.0/tests/test_pipeline_mapspec.py +427 -0
- pipefunc-0.0.0/tests/test_pipeline_post_execution_hook.py +50 -0
- pipefunc-0.0.0/tests/test_pipeline_resources.py +194 -0
- pipefunc-0.0.0/tests/test_pipeline_update.py +283 -0
- pipefunc-0.0.0/tests/test_plotting.py +427 -0
- pipefunc-0.0.0/tests/test_plotting_utils.py +91 -0
- pipefunc-0.0.0/tests/test_pydantic.py +267 -0
- pipefunc-0.0.0/tests/test_resources.py +236 -0
- pipefunc-0.0.0/tests/test_simplify.py +208 -0
- pipefunc-0.0.0/tests/test_sweep.py +479 -0
- pipefunc-0.0.0/tests/test_testing.py +56 -0
- pipefunc-0.0.0/tests/test_typing.py +669 -0
- pipefunc-0.0.0/tests/test_typing_future_annotations.py +20 -0
- pipefunc-0.0.0/tests/test_utils.py +350 -0
- pipefunc-0.0.0/tests/test_variant_pipeline.py +736 -0
- pipefunc-0.0.0/tests/test_variant_pipeline_widgets.py +180 -0
- pipefunc-0.0.0/tests/test_widgets_tracker.py +145 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
ARG UV_VERSION=0.6.2
|
|
2
|
+
ARG DEBIAN_VERSION=bookworm
|
|
3
|
+
|
|
4
|
+
FROM ghcr.io/astral-sh/uv:$UV_VERSION AS uv
|
|
5
|
+
|
|
6
|
+
FROM mcr.microsoft.com/vscode/devcontainers/base:$DEBIAN_VERSION
|
|
7
|
+
LABEL maintainer="Bas Nijholt <bas@nijho.lt>"
|
|
8
|
+
|
|
9
|
+
# hadolint ignore=DL3008
|
|
10
|
+
RUN apt-get update \
|
|
11
|
+
&& apt-get install -y --no-install-recommends \
|
|
12
|
+
graphviz \
|
|
13
|
+
# To remove the image size, it is recommended refresh the package cache as follows
|
|
14
|
+
&& apt-get clean \
|
|
15
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
16
|
+
|
|
17
|
+
COPY --from=uv --chown=vscode: /uv /uvx /bin/
|
|
18
|
+
RUN echo "source /home/vscode/.venv/bin/activate" >> /home/vscode/.bashrc
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uv",
|
|
3
|
+
"build": {
|
|
4
|
+
"context": "..",
|
|
5
|
+
"dockerfile": "Dockerfile",
|
|
6
|
+
"args": {
|
|
7
|
+
"UV_VERSION": "0.6.2",
|
|
8
|
+
"DEBIAN_VERSION": "bookworm"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"features": {
|
|
12
|
+
"ghcr.io/dhoeric/features/hadolint:1": {}
|
|
13
|
+
},
|
|
14
|
+
"customizations": {
|
|
15
|
+
"vscode": {
|
|
16
|
+
"extensions": [
|
|
17
|
+
"charliermarsh.ruff",
|
|
18
|
+
"exiasr.hadolint",
|
|
19
|
+
"kevinrose.vsc-python-indent",
|
|
20
|
+
"mosapride.zenkaku",
|
|
21
|
+
"ms-azuretools.vscode-docker",
|
|
22
|
+
"ms-python.python",
|
|
23
|
+
"ms-toolsai.jupyter",
|
|
24
|
+
"njpwerner.autodocstring",
|
|
25
|
+
"redhat.vscode-yaml",
|
|
26
|
+
"shardulm94.trailing-spaces",
|
|
27
|
+
"tamasfe.even-better-toml"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"settings": {
|
|
31
|
+
"python.defaultInterpreterPath": "/home/vscode/.venv/bin/python"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"containerEnv": {
|
|
35
|
+
"DISPLAY": "dummy",
|
|
36
|
+
"PYTHONUNBUFFERED": "True",
|
|
37
|
+
"UV_LINK_MODE": "copy",
|
|
38
|
+
"UV_PROJECT_ENVIRONMENT": "/home/vscode/.venv"
|
|
39
|
+
},
|
|
40
|
+
"postCreateCommand": "uv venv && . /home/vscode/.venv/bin/activate && uv pip install -e '.[dev]'",
|
|
41
|
+
"postStartCommand": "uv run pre-commit install",
|
|
42
|
+
"remoteUser": "vscode"
|
|
43
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""Check for discrepancies in parameter descriptions between functions."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import inspect
|
|
7
|
+
from typing import TYPE_CHECKING, Any
|
|
8
|
+
|
|
9
|
+
import pipefunc._pipeline
|
|
10
|
+
import pipefunc._pipeline._autodoc
|
|
11
|
+
import pipefunc._pipeline._cli
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from collections.abc import Callable
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def extract_param_descriptions(func: Callable[..., Any]) -> dict[str, str]:
|
|
18
|
+
"""Extract parameter descriptions from a function's docstring.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
func
|
|
23
|
+
The function to extract parameter descriptions from.
|
|
24
|
+
|
|
25
|
+
Returns
|
|
26
|
+
-------
|
|
27
|
+
A dictionary where keys are parameter names and values are their descriptions.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
doc = inspect.getdoc(func)
|
|
31
|
+
|
|
32
|
+
if not doc:
|
|
33
|
+
return {}
|
|
34
|
+
|
|
35
|
+
param_dict = {}
|
|
36
|
+
in_params_section = False
|
|
37
|
+
current_param = None
|
|
38
|
+
current_description: list[str] = []
|
|
39
|
+
|
|
40
|
+
for line in doc.split("\n"):
|
|
41
|
+
stripped_line = line.strip()
|
|
42
|
+
if stripped_line == "Parameters":
|
|
43
|
+
in_params_section = True
|
|
44
|
+
elif in_params_section and (
|
|
45
|
+
stripped_line in ("See Also", "Returns", "Raises", "Notes", "Examples")
|
|
46
|
+
):
|
|
47
|
+
break
|
|
48
|
+
elif in_params_section:
|
|
49
|
+
if stripped_line.startswith("---"):
|
|
50
|
+
continue
|
|
51
|
+
if stripped_line == "":
|
|
52
|
+
# Empty line inside of a parameter description, e.g., for lists
|
|
53
|
+
continue
|
|
54
|
+
if not line.startswith(" "): # Parameter names are not indented
|
|
55
|
+
if current_param:
|
|
56
|
+
param_dict[current_param] = " ".join(current_description).strip()
|
|
57
|
+
current_param = stripped_line
|
|
58
|
+
current_description = []
|
|
59
|
+
elif current_param is not None:
|
|
60
|
+
current_description.append(stripped_line)
|
|
61
|
+
|
|
62
|
+
if current_param:
|
|
63
|
+
param_dict[current_param] = " ".join(current_description).strip()
|
|
64
|
+
|
|
65
|
+
return param_dict
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ParameterDiscrepancyError(Exception):
|
|
69
|
+
"""Exception raised for discrepancies in parameter descriptions."""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class MissingParameterError(Exception):
|
|
73
|
+
"""Exception raised for parameters missing in one of the functions."""
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_module() -> None:
|
|
77
|
+
"""Tests whether this module works as intended."""
|
|
78
|
+
|
|
79
|
+
def starts_ends_with(s: str, start: str, end: str) -> bool:
|
|
80
|
+
return s.startswith(start) and s.endswith(end)
|
|
81
|
+
|
|
82
|
+
p = extract_param_descriptions(extract_param_descriptions)
|
|
83
|
+
assert p.keys() == {"func"}
|
|
84
|
+
assert starts_ends_with(p["func"], "The function", "descriptions from.")
|
|
85
|
+
p = extract_param_descriptions(compare_param_descriptions)
|
|
86
|
+
assert p.keys() == {"func1", "func2", "allow_missing", "allow_discrepancy"}
|
|
87
|
+
assert p["func1"] == "The first function to compare."
|
|
88
|
+
assert p["func2"] == "The second function to compare."
|
|
89
|
+
assert starts_ends_with(p["allow_missing"], "If True, allow any", "missing parameters.")
|
|
90
|
+
assert starts_ends_with(p["allow_discrepancy"], "If True, allow any", "discrepancies.")
|
|
91
|
+
|
|
92
|
+
def func_with_spacing() -> None:
|
|
93
|
+
"""Example
|
|
94
|
+
|
|
95
|
+
Parameters
|
|
96
|
+
----------
|
|
97
|
+
param1
|
|
98
|
+
The first parameter.
|
|
99
|
+
|
|
100
|
+
- First line
|
|
101
|
+
- Second line
|
|
102
|
+
|
|
103
|
+
Yo end of list.
|
|
104
|
+
param2
|
|
105
|
+
The second parameter.
|
|
106
|
+
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
p = extract_param_descriptions(func_with_spacing)
|
|
110
|
+
assert p.keys() == {"param1", "param2"}
|
|
111
|
+
assert starts_ends_with(p["param1"], "The first parameter.", "Yo end of list.")
|
|
112
|
+
assert p["param2"] == "The second parameter."
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def compare_param_descriptions(
|
|
116
|
+
func1: Callable,
|
|
117
|
+
func2: Callable,
|
|
118
|
+
*,
|
|
119
|
+
allow_missing: list[str] | bool = False,
|
|
120
|
+
allow_discrepancy: list[str] | bool = False,
|
|
121
|
+
) -> None:
|
|
122
|
+
"""Compare parameter descriptions between two functions.
|
|
123
|
+
|
|
124
|
+
Parameters
|
|
125
|
+
----------
|
|
126
|
+
func1
|
|
127
|
+
The first function to compare.
|
|
128
|
+
func2
|
|
129
|
+
The second function to compare.
|
|
130
|
+
allow_missing
|
|
131
|
+
If True, allow any missing parameters. If a list, allow missing parameters
|
|
132
|
+
specified in the list. If False, raise exceptions for all missing parameters.
|
|
133
|
+
allow_discrepancy
|
|
134
|
+
If True, allow any discrepancies in parameter descriptions. If a list, allow
|
|
135
|
+
discrepancies for parameters specified in the list. If False, raise exceptions
|
|
136
|
+
for all discrepancies.
|
|
137
|
+
|
|
138
|
+
Raises
|
|
139
|
+
------
|
|
140
|
+
ExceptionGroup
|
|
141
|
+
An exception group containing all discrepancies and missing parameters.
|
|
142
|
+
|
|
143
|
+
"""
|
|
144
|
+
params1 = extract_param_descriptions(func1)
|
|
145
|
+
params2 = extract_param_descriptions(func2)
|
|
146
|
+
|
|
147
|
+
all_params = set(params1.keys()) | set(params2.keys())
|
|
148
|
+
exceptions: list[Exception] = []
|
|
149
|
+
|
|
150
|
+
for param in all_params:
|
|
151
|
+
if param in params1 and param in params2:
|
|
152
|
+
if params1[param] != params2[param] and not (
|
|
153
|
+
allow_discrepancy is True
|
|
154
|
+
or (isinstance(allow_discrepancy, list) and param in allow_discrepancy)
|
|
155
|
+
):
|
|
156
|
+
exceptions.append(
|
|
157
|
+
ParameterDiscrepancyError(
|
|
158
|
+
f"Discrepancy in parameter '{param}':\n"
|
|
159
|
+
f" {func1.__name__}: {params1[param]}\n"
|
|
160
|
+
f" {func2.__name__}: {params2[param]}",
|
|
161
|
+
),
|
|
162
|
+
)
|
|
163
|
+
elif param in params1:
|
|
164
|
+
if not (
|
|
165
|
+
allow_missing is True
|
|
166
|
+
or (isinstance(allow_missing, list) and param in allow_missing)
|
|
167
|
+
):
|
|
168
|
+
exceptions.append(
|
|
169
|
+
MissingParameterError(
|
|
170
|
+
f"Parameter '{param}' is in {func1.__name__} but not in {func2.__name__}",
|
|
171
|
+
),
|
|
172
|
+
)
|
|
173
|
+
elif not (
|
|
174
|
+
allow_missing is True or (isinstance(allow_missing, list) and param in allow_missing)
|
|
175
|
+
):
|
|
176
|
+
exceptions.append(
|
|
177
|
+
MissingParameterError(
|
|
178
|
+
f"Parameter '{param}' is in {func2.__name__} but not in {func1.__name__}",
|
|
179
|
+
),
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
if exceptions:
|
|
183
|
+
msg = "Parameter description discrepancies"
|
|
184
|
+
raise ExceptionGroup(msg, exceptions) # type: ignore[name-defined] # noqa: F821
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
if __name__ == "__main__":
|
|
188
|
+
test_module()
|
|
189
|
+
|
|
190
|
+
import pipefunc
|
|
191
|
+
import pipefunc._plotting
|
|
192
|
+
from pipefunc.map import run_map, run_map_async
|
|
193
|
+
from pipefunc.map._run_eager import run_map_eager
|
|
194
|
+
from pipefunc.map._run_eager_async import run_map_eager_async
|
|
195
|
+
|
|
196
|
+
# @pipefunc and PipeFunc
|
|
197
|
+
compare_param_descriptions(
|
|
198
|
+
pipefunc.PipeFunc,
|
|
199
|
+
pipefunc.pipefunc,
|
|
200
|
+
# In PipeFunc "wrapped function" and in @pipefunc "decorated function"
|
|
201
|
+
allow_discrepancy=["output_name", "profile", "cache"],
|
|
202
|
+
allow_missing=["func"],
|
|
203
|
+
)
|
|
204
|
+
compare_param_descriptions(
|
|
205
|
+
pipefunc.PipeFunc.update_bound,
|
|
206
|
+
pipefunc.NestedPipeFunc.update_bound,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
# map and map_async
|
|
210
|
+
compare_param_descriptions(
|
|
211
|
+
pipefunc.Pipeline.map,
|
|
212
|
+
run_map,
|
|
213
|
+
allow_missing=["pipeline", "scheduling_strategy"],
|
|
214
|
+
)
|
|
215
|
+
compare_param_descriptions(
|
|
216
|
+
run_map_eager,
|
|
217
|
+
run_map,
|
|
218
|
+
)
|
|
219
|
+
compare_param_descriptions(
|
|
220
|
+
run_map_eager_async,
|
|
221
|
+
run_map_async,
|
|
222
|
+
)
|
|
223
|
+
compare_param_descriptions(
|
|
224
|
+
pipefunc.Pipeline.map_async,
|
|
225
|
+
run_map_async,
|
|
226
|
+
allow_missing=["parallel", "pipeline", "scheduling_strategy"],
|
|
227
|
+
allow_discrepancy=["show_progress"],
|
|
228
|
+
)
|
|
229
|
+
compare_param_descriptions(
|
|
230
|
+
pipefunc.Pipeline.map,
|
|
231
|
+
pipefunc.Pipeline.map_async,
|
|
232
|
+
allow_missing=["parallel"],
|
|
233
|
+
allow_discrepancy=["show_progress", "executor"],
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
# plotting
|
|
237
|
+
compare_param_descriptions(
|
|
238
|
+
pipefunc._plotting.visualize_graphviz,
|
|
239
|
+
pipefunc.Pipeline.visualize_graphviz,
|
|
240
|
+
allow_missing=["defaults", "graph"],
|
|
241
|
+
)
|
|
242
|
+
compare_param_descriptions(
|
|
243
|
+
pipefunc._plotting.visualize_graphviz_widget,
|
|
244
|
+
pipefunc.Pipeline.visualize_graphviz_widget,
|
|
245
|
+
allow_missing=["defaults", "graph"],
|
|
246
|
+
)
|
|
247
|
+
compare_param_descriptions(
|
|
248
|
+
pipefunc._plotting.visualize_holoviews,
|
|
249
|
+
pipefunc.Pipeline.visualize_holoviews,
|
|
250
|
+
allow_missing=["graph"],
|
|
251
|
+
)
|
|
252
|
+
compare_param_descriptions(
|
|
253
|
+
pipefunc._plotting.visualize_matplotlib,
|
|
254
|
+
pipefunc.Pipeline.visualize_matplotlib,
|
|
255
|
+
allow_missing=[
|
|
256
|
+
"output_name",
|
|
257
|
+
"color_combinable",
|
|
258
|
+
"conservatively_combine",
|
|
259
|
+
"graph",
|
|
260
|
+
"func_node_colors",
|
|
261
|
+
],
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
# Pipeline and VariantsPipeline
|
|
265
|
+
compare_param_descriptions(
|
|
266
|
+
pipefunc.Pipeline,
|
|
267
|
+
pipefunc.VariantPipeline,
|
|
268
|
+
allow_missing=["default_variant"],
|
|
269
|
+
allow_discrepancy=["functions"],
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
# print_documentation and format_pipeline_docs
|
|
273
|
+
compare_param_descriptions(
|
|
274
|
+
pipefunc.Pipeline.print_documentation,
|
|
275
|
+
pipefunc._pipeline._autodoc.format_pipeline_docs,
|
|
276
|
+
allow_missing=["doc", "print_table"],
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
# CLI
|
|
280
|
+
compare_param_descriptions(
|
|
281
|
+
pipefunc.Pipeline.cli,
|
|
282
|
+
pipefunc._pipeline._cli.cli,
|
|
283
|
+
allow_missing=["pipeline"],
|
|
284
|
+
)
|