interlace-py 0.2.0__py3-none-any.whl
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.
- interlace/__init__.py +13 -0
- interlace/_validation.py +69 -0
- interlace/adapters/__init__.py +5 -0
- interlace/adapters/memory.py +791 -0
- interlace/engine/__init__.py +21 -0
- interlace/engine/core.py +239 -0
- interlace/engine/errors.py +147 -0
- interlace/engine/events.py +370 -0
- interlace/engine/execution.py +957 -0
- interlace/engine/execution_resources.py +168 -0
- interlace/engine/executor.py +1103 -0
- interlace/engine/extension.py +611 -0
- interlace/engine/graph.py +889 -0
- interlace/engine/hooks.py +133 -0
- interlace/engine/observation.py +118 -0
- interlace/engine/options.py +32 -0
- interlace/engine/points.py +35 -0
- interlace/engine/policies.py +179 -0
- interlace/engine/runner.py +193 -0
- interlace/engine/slots.py +451 -0
- interlace/nodes/__init__.py +5 -0
- interlace/nodes/keyed_join.py +142 -0
- interlace/plugins/__init__.py +50 -0
- interlace/plugins/background.py +115 -0
- interlace/plugins/host.py +874 -0
- interlace/plugins/points.py +92 -0
- interlace/plugins/settings.py +213 -0
- interlace/py.typed +1 -0
- interlace/runtime/__init__.py +14 -0
- interlace/runtime/_utils.py +132 -0
- interlace/runtime/direct.py +61 -0
- interlace/runtime/facade.py +680 -0
- interlace/runtime/history.py +148 -0
- interlace/runtime/plugin.py +305 -0
- interlace/runtime/router.py +447 -0
- interlace/runtime/worker.py +980 -0
- interlace/service/__init__.py +7 -0
- interlace/service/catalog.py +217 -0
- interlace/service/diagnostics.py +428 -0
- interlace/service/errors.py +31 -0
- interlace/service/http.py +689 -0
- interlace/service/models.py +135 -0
- interlace/service/service.py +1069 -0
- interlace/service/store.py +832 -0
- interlace/spi/__init__.py +57 -0
- interlace/spi/roles.py +298 -0
- interlace/spi/runtime.py +369 -0
- interlace_py-0.2.0.dist-info/METADATA +170 -0
- interlace_py-0.2.0.dist-info/RECORD +51 -0
- interlace_py-0.2.0.dist-info/WHEEL +4 -0
- interlace_py-0.2.0.dist-info/licenses/LICENSE +21 -0
interlace/__init__.py
ADDED
interlace/_validation.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""跨包共享的参数校验辅助函数,不属于公共 API。"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def require_non_empty_string(value: object, label: str) -> str:
|
|
9
|
+
"""校验一个值是非空字符串。
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
value: 待校验的值,不能是空串或全空白。
|
|
13
|
+
label: 校验失败时用于指明字段的说明名称。
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
通过校验的原始字符串。
|
|
17
|
+
|
|
18
|
+
Raises:
|
|
19
|
+
TypeError: value 不是字符串。
|
|
20
|
+
ValueError: value 为空串或全空白。
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
if not isinstance(value, str):
|
|
24
|
+
raise TypeError(f"{label} must be a string")
|
|
25
|
+
if not value.strip():
|
|
26
|
+
raise ValueError(f"{label} must not be empty")
|
|
27
|
+
return value
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def require_namespaced(value: object, label: str) -> str:
|
|
31
|
+
"""校验带 ``/`` 命名空间且不含空白的标识,例如 ``"acme/name"``。
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
value: 待校验的值。
|
|
35
|
+
label: 校验失败时用于指明字段的说明名称。
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
通过校验的原始字符串。
|
|
39
|
+
|
|
40
|
+
Raises:
|
|
41
|
+
TypeError: value 不是字符串。
|
|
42
|
+
ValueError: value 为空、缺少命名空间、以 ``/`` 开头或结尾,或包含空白。
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
value = require_non_empty_string(value, label)
|
|
46
|
+
if "/" not in value or value.startswith("/") or value.endswith("/"):
|
|
47
|
+
raise ValueError(f"{label} must be namespaced, for example 'acme/name'")
|
|
48
|
+
if any(char.isspace() for char in value):
|
|
49
|
+
raise ValueError(f"{label} must not contain whitespace")
|
|
50
|
+
return value
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def validate_timeout(timeout: float | None) -> None:
|
|
54
|
+
"""校验等待接口使用的超时参数。
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
timeout: 等待时限,单位秒;None 表示不限制。
|
|
58
|
+
|
|
59
|
+
Raises:
|
|
60
|
+
TypeError: timeout 不是数字或 None。
|
|
61
|
+
ValueError: timeout 为负数或非有限值。
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
if timeout is None:
|
|
65
|
+
return
|
|
66
|
+
if isinstance(timeout, bool) or not isinstance(timeout, (int, float)):
|
|
67
|
+
raise TypeError("timeout must be a number or None")
|
|
68
|
+
if not math.isfinite(timeout) or timeout < 0:
|
|
69
|
+
raise ValueError("timeout must be a finite non-negative number")
|