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.
Files changed (51) hide show
  1. interlace/__init__.py +13 -0
  2. interlace/_validation.py +69 -0
  3. interlace/adapters/__init__.py +5 -0
  4. interlace/adapters/memory.py +791 -0
  5. interlace/engine/__init__.py +21 -0
  6. interlace/engine/core.py +239 -0
  7. interlace/engine/errors.py +147 -0
  8. interlace/engine/events.py +370 -0
  9. interlace/engine/execution.py +957 -0
  10. interlace/engine/execution_resources.py +168 -0
  11. interlace/engine/executor.py +1103 -0
  12. interlace/engine/extension.py +611 -0
  13. interlace/engine/graph.py +889 -0
  14. interlace/engine/hooks.py +133 -0
  15. interlace/engine/observation.py +118 -0
  16. interlace/engine/options.py +32 -0
  17. interlace/engine/points.py +35 -0
  18. interlace/engine/policies.py +179 -0
  19. interlace/engine/runner.py +193 -0
  20. interlace/engine/slots.py +451 -0
  21. interlace/nodes/__init__.py +5 -0
  22. interlace/nodes/keyed_join.py +142 -0
  23. interlace/plugins/__init__.py +50 -0
  24. interlace/plugins/background.py +115 -0
  25. interlace/plugins/host.py +874 -0
  26. interlace/plugins/points.py +92 -0
  27. interlace/plugins/settings.py +213 -0
  28. interlace/py.typed +1 -0
  29. interlace/runtime/__init__.py +14 -0
  30. interlace/runtime/_utils.py +132 -0
  31. interlace/runtime/direct.py +61 -0
  32. interlace/runtime/facade.py +680 -0
  33. interlace/runtime/history.py +148 -0
  34. interlace/runtime/plugin.py +305 -0
  35. interlace/runtime/router.py +447 -0
  36. interlace/runtime/worker.py +980 -0
  37. interlace/service/__init__.py +7 -0
  38. interlace/service/catalog.py +217 -0
  39. interlace/service/diagnostics.py +428 -0
  40. interlace/service/errors.py +31 -0
  41. interlace/service/http.py +689 -0
  42. interlace/service/models.py +135 -0
  43. interlace/service/service.py +1069 -0
  44. interlace/service/store.py +832 -0
  45. interlace/spi/__init__.py +57 -0
  46. interlace/spi/roles.py +298 -0
  47. interlace/spi/runtime.py +369 -0
  48. interlace_py-0.2.0.dist-info/METADATA +170 -0
  49. interlace_py-0.2.0.dist-info/RECORD +51 -0
  50. interlace_py-0.2.0.dist-info/WHEEL +4 -0
  51. interlace_py-0.2.0.dist-info/licenses/LICENSE +21 -0
interlace/__init__.py ADDED
@@ -0,0 +1,13 @@
1
+ """Interlace 顶层公共 API:写业务和编排只需要这六个名字。"""
2
+
3
+ from .engine import Context, Event, Graph, Node, Output
4
+ from .runtime import Runtime
5
+
6
+ __all__ = [
7
+ "Context",
8
+ "Event",
9
+ "Graph",
10
+ "Node",
11
+ "Output",
12
+ "Runtime",
13
+ ]
@@ -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")
@@ -0,0 +1,5 @@
1
+ """Interlace 随包提供的部署适配器。"""
2
+
3
+ from . import memory
4
+
5
+ __all__ = ["memory"]