combycode-dpe 2.0.4__tar.gz → 2.1.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.
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/PKG-INFO +2 -2
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/pyproject.toml +5 -1
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/src/dpe/_paths.py +22 -2
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/tests/test_paths.py +36 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/.gitignore +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/README.md +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/src/dpe/__init__.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/src/dpe/_accumulators.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/src/dpe/_cache.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/src/dpe/_context.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/src/dpe/_envelope.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/src/dpe/_runtime.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/template/meta.json +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/template/pyproject.toml +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/template/spec.yaml +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/template/src/__PKG__/__init__.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/template/src/__PKG__/main.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/template/tests/test_basic.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/tests/test_accumulators.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/tests/test_cache.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/tests/test_integration.py +0 -0
- {combycode_dpe-2.0.4 → combycode_dpe-2.1.0}/tests/test_stderr_events_conformance.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: combycode-dpe
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: DPE framework for building streaming pipeline tools in Python
|
|
5
5
|
Project-URL: Homepage, https://github.com/combycode/dpe
|
|
6
6
|
Project-URL: Repository, https://github.com/combycode/dpe
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "combycode-dpe"
|
|
7
|
-
version = "2.0
|
|
7
|
+
version = "2.1.0"
|
|
8
8
|
description = "DPE framework for building streaming pipeline tools in Python"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "AGPL-3.0-or-later"
|
|
@@ -54,3 +54,7 @@ no_implicit_optional = true
|
|
|
54
54
|
warn_redundant_casts = true
|
|
55
55
|
warn_unused_ignores = true
|
|
56
56
|
check_untyped_defs = false
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
# Import the checkout's own src/ even when another copy of `dpe` is installed.
|
|
60
|
+
pythonpath = ["src"]
|
|
@@ -5,6 +5,8 @@ Input side (runtime, before processor): $token/subpath -> absolute path
|
|
|
5
5
|
Output side (context.output / context.meta): absolute path -> $token/subpath
|
|
6
6
|
|
|
7
7
|
Both sides are a no-op when the DPE_* env vars are not set.
|
|
8
|
+
``DPE_PATH_TOKENS=off`` (also ``0`` / ``false`` / ``no``) turns the output side off; the
|
|
9
|
+
runner sets it from the variant's / stage's ``path_tokens``. Input resolution stays on.
|
|
8
10
|
"""
|
|
9
11
|
|
|
10
12
|
import os
|
|
@@ -20,10 +22,18 @@ _TOKEN_MAP = [
|
|
|
20
22
|
]
|
|
21
23
|
|
|
22
24
|
|
|
25
|
+
def tokens_enabled_from_env() -> bool:
|
|
26
|
+
"""True unless ``DPE_PATH_TOKENS`` is ``off``, ``0``, ``false`` or ``no`` (any case)."""
|
|
27
|
+
v = os.environ.get("DPE_PATH_TOKENS")
|
|
28
|
+
if v is None:
|
|
29
|
+
return True
|
|
30
|
+
return v.strip().lower() not in ("off", "0", "false", "no")
|
|
31
|
+
|
|
32
|
+
|
|
23
33
|
class EnvPaths:
|
|
24
34
|
"""Resolved env prefix map. Build once at tool startup."""
|
|
25
35
|
|
|
26
|
-
__slots__ = ("_entries",)
|
|
36
|
+
__slots__ = ("_entries", "_no_tokenize")
|
|
27
37
|
|
|
28
38
|
def __init__(self, pairs: list[tuple[str, str]] | None = None):
|
|
29
39
|
"""
|
|
@@ -47,6 +57,16 @@ class EnvPaths:
|
|
|
47
57
|
self._entries: list[tuple[str, str]] = sorted(
|
|
48
58
|
raw, key=lambda e: len(e[1]), reverse=True
|
|
49
59
|
)
|
|
60
|
+
self._no_tokenize = (not tokens_enabled_from_env()) if pairs is None else False
|
|
61
|
+
|
|
62
|
+
def with_tokenize(self, on: bool) -> "EnvPaths":
|
|
63
|
+
"""Turn the output side (absolute path -> ``$token``) on or off."""
|
|
64
|
+
self._no_tokenize = not on
|
|
65
|
+
return self
|
|
66
|
+
|
|
67
|
+
def tokenize_enabled(self) -> bool:
|
|
68
|
+
"""Whether :meth:`tokenize_value` rewrites anything."""
|
|
69
|
+
return not self._no_tokenize
|
|
50
70
|
|
|
51
71
|
@classmethod
|
|
52
72
|
def from_env(cls) -> "EnvPaths":
|
|
@@ -69,7 +89,7 @@ class EnvPaths:
|
|
|
69
89
|
|
|
70
90
|
def tokenize_value(self, v: Any) -> Any:
|
|
71
91
|
"""Walk v, tokenizing absolute paths back to $token[/subpath] form."""
|
|
72
|
-
if self.is_empty():
|
|
92
|
+
if self.is_empty() or self._no_tokenize:
|
|
73
93
|
return v
|
|
74
94
|
return self._walk(v, self._tokenize_str)
|
|
75
95
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Tests for EnvPaths -- $token resolve/tokenize round-trip."""
|
|
2
2
|
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
3
5
|
from dpe._paths import EnvPaths
|
|
4
6
|
|
|
5
7
|
|
|
@@ -129,3 +131,37 @@ class TestNamedFactories:
|
|
|
129
131
|
monkeypatch.setenv("DPE_INPUT", "/ignored")
|
|
130
132
|
p = EnvPaths.from_pairs([("input", "/explicit")])
|
|
131
133
|
assert p.resolve_value("$input/file") == "/explicit/file"
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# ─── DPE_PATH_TOKENS switch ───────────────────────────────────────────────
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def test_path_tokens_default_on(monkeypatch):
|
|
141
|
+
monkeypatch.setenv("DPE_STORAGE", "/abs/storage")
|
|
142
|
+
monkeypatch.delenv("DPE_PATH_TOKENS", raising=False)
|
|
143
|
+
p = EnvPaths.from_env()
|
|
144
|
+
assert p.tokenize_enabled()
|
|
145
|
+
assert p.tokenize_value({"f": "/abs/storage/x.json"}) == {"f": "$storage/x.json"}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@pytest.mark.parametrize("val", ["off", "OFF", " 0 ", "false", "No"])
|
|
149
|
+
def test_path_tokens_off_keeps_absolute_but_resolves(monkeypatch, val):
|
|
150
|
+
monkeypatch.setenv("DPE_STORAGE", "/abs/storage")
|
|
151
|
+
monkeypatch.setenv("DPE_PATH_TOKENS", val)
|
|
152
|
+
p = EnvPaths.from_env()
|
|
153
|
+
assert not p.tokenize_enabled()
|
|
154
|
+
assert p.tokenize_value({"f": "/abs/storage/x.json"}) == {"f": "/abs/storage/x.json"}
|
|
155
|
+
assert p.resolve_value("$storage/x.json") == "/abs/storage/x.json"
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@pytest.mark.parametrize("val", ["on", "1", "true", "yes", ""])
|
|
159
|
+
def test_path_tokens_other_values_keep_it_on(monkeypatch, val):
|
|
160
|
+
monkeypatch.setenv("DPE_STORAGE", "/abs/storage")
|
|
161
|
+
monkeypatch.setenv("DPE_PATH_TOKENS", val)
|
|
162
|
+
assert EnvPaths.from_env().tokenize_enabled()
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_with_tokenize_on_explicit_pairs():
|
|
166
|
+
p = EnvPaths.from_pairs([("storage", "/abs/storage")]).with_tokenize(False)
|
|
167
|
+
assert p.tokenize_value("/abs/storage/a") == "/abs/storage/a"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|