retriever-core 0.0.1__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 (123) hide show
  1. THIRD_PARTY_NOTICES.md +46 -0
  2. retriever/__init__.py +196 -0
  3. retriever/_internal/__init__.py +5 -0
  4. retriever/_internal/helpers.py +113 -0
  5. retriever/cli.py +718 -0
  6. retriever/config.py +149 -0
  7. retriever/context/__init__.py +6 -0
  8. retriever/context/client.py +118 -0
  9. retriever/context/config.py +61 -0
  10. retriever/context/flow.py +110 -0
  11. retriever/error.py +398 -0
  12. retriever/flow/__init__.py +70 -0
  13. retriever/flow/adapter.py +496 -0
  14. retriever/flow/base.py +490 -0
  15. retriever/flow/builder.py +1222 -0
  16. retriever/flow/clock.py +493 -0
  17. retriever/flow/config.py +231 -0
  18. retriever/flow/functional.py +21 -0
  19. retriever/flow/graph.py +530 -0
  20. retriever/flow/io.py +239 -0
  21. retriever/flow/pipeline.py +1092 -0
  22. retriever/flow/service.py +164 -0
  23. retriever/flow/sync.py +108 -0
  24. retriever/flow/temporal.py +424 -0
  25. retriever/flow/types.py +661 -0
  26. retriever/hub/__init__.py +167 -0
  27. retriever/hub/_cache.py +75 -0
  28. retriever/hub/_check.py +116 -0
  29. retriever/hub/_fetch.py +85 -0
  30. retriever/hub/_http.py +64 -0
  31. retriever/hub/_index.py +77 -0
  32. retriever/hub/_loader.py +454 -0
  33. retriever/hub/_ref.py +51 -0
  34. retriever/hub/_resolve.py +84 -0
  35. retriever/ir/__init__.py +35 -0
  36. retriever/ir/assets/cytoscape-dagre.min.js +8 -0
  37. retriever/ir/assets/cytoscape.min.js +32 -0
  38. retriever/ir/assets/dagre.min.js +3809 -0
  39. retriever/ir/core.py +805 -0
  40. retriever/ir/execution.py +269 -0
  41. retriever/ir/resources.py +242 -0
  42. retriever/ir/rules.py +308 -0
  43. retriever/ir/temporal.py +363 -0
  44. retriever/ir/viz.py +888 -0
  45. retriever/lib/__init__.py +1 -0
  46. retriever/lib/gym.py +97 -0
  47. retriever/lib/hf.py +107 -0
  48. retriever/lib/jax.py +192 -0
  49. retriever/lib/mcap.py +592 -0
  50. retriever/lib/rerun.py +901 -0
  51. retriever/lib/torch.py +130 -0
  52. retriever/lib/wrapper.py +80 -0
  53. retriever/recording.py +750 -0
  54. retriever/registry/__init__.py +77 -0
  55. retriever/registry/flow.py +262 -0
  56. retriever/registry/pipeline.py +676 -0
  57. retriever/registry/types.py +387 -0
  58. retriever/rt/__init__.py +29 -0
  59. retriever/rt/backend/__init__.py +44 -0
  60. retriever/rt/backend/dora/__init__.py +120 -0
  61. retriever/rt/backend/dora/benchmarks.py +215 -0
  62. retriever/rt/backend/dora/channel.py +131 -0
  63. retriever/rt/backend/dora/compiler.py +429 -0
  64. retriever/rt/backend/dora/engine.py +571 -0
  65. retriever/rt/backend/dora/executor.py +689 -0
  66. retriever/rt/backend/dora/scheduler.py +232 -0
  67. retriever/rt/backend/dora/serde.py +346 -0
  68. retriever/rt/backend/dora/telemetry.py +75 -0
  69. retriever/rt/backend/factory.py +166 -0
  70. retriever/rt/backend/in_process.py +204 -0
  71. retriever/rt/backend/interface.py +342 -0
  72. retriever/rt/backend/multiprocessing/__init__.py +41 -0
  73. retriever/rt/backend/multiprocessing/channel.py +161 -0
  74. retriever/rt/backend/multiprocessing/engine.py +259 -0
  75. retriever/rt/backend/multiprocessing/executor.py +420 -0
  76. retriever/rt/backend/multiprocessing/mp_context.py +17 -0
  77. retriever/rt/backend/multiprocessing/scheduler.py +294 -0
  78. retriever/rt/buffer_engine.py +110 -0
  79. retriever/rt/control/__init__.py +79 -0
  80. retriever/rt/control/channel.py +260 -0
  81. retriever/rt/control/controllable.py +255 -0
  82. retriever/rt/control/controller.py +294 -0
  83. retriever/rt/control/dashboard.html +778 -0
  84. retriever/rt/control/keyboard.py +166 -0
  85. retriever/rt/control/output_capture.py +178 -0
  86. retriever/rt/control/web.py +384 -0
  87. retriever/rt/fused.py +219 -0
  88. retriever/rt/lifecycle.py +109 -0
  89. retriever/rt/logging/__init__.py +7 -0
  90. retriever/rt/logging/config.py +32 -0
  91. retriever/rt/logging/handlers/__init__.py +14 -0
  92. retriever/rt/logging/handlers/console.py +77 -0
  93. retriever/rt/logging/handlers/file.py +50 -0
  94. retriever/rt/logging/handlers/otel.py +92 -0
  95. retriever/rt/logging/manager.py +143 -0
  96. retriever/rt/logging/worker.py +86 -0
  97. retriever/rt/runtime.py +237 -0
  98. retriever/rt/step.py +547 -0
  99. retriever/rt/stepper.py +484 -0
  100. retriever/types/__init__.py +50 -0
  101. retriever/types/core.py +80 -0
  102. retriever/types/data/__init__.py +55 -0
  103. retriever/types/data/dataset.py +135 -0
  104. retriever/types/data/events.py +368 -0
  105. retriever/types/data/interop.py +185 -0
  106. retriever/types/data/streams.py +304 -0
  107. retriever/types/data/v1.py +42 -0
  108. retriever/types/language/__init__.py +35 -0
  109. retriever/types/language/v1.py +200 -0
  110. retriever/types/perception/__init__.py +43 -0
  111. retriever/types/perception/v1.py +310 -0
  112. retriever/types/schema.py +80 -0
  113. retriever/types/spatial/__init__.py +35 -0
  114. retriever/types/spatial/v1.py +186 -0
  115. retriever/types/symbolic/__init__.py +27 -0
  116. retriever/types/symbolic/objects.py +208 -0
  117. retriever/types/symbolic/options.py +126 -0
  118. retriever/types/symbolic/skills.py +68 -0
  119. retriever_core-0.0.1.dist-info/METADATA +326 -0
  120. retriever_core-0.0.1.dist-info/RECORD +123 -0
  121. retriever_core-0.0.1.dist-info/WHEEL +4 -0
  122. retriever_core-0.0.1.dist-info/entry_points.txt +2 -0
  123. retriever_core-0.0.1.dist-info/licenses/LICENSE +202 -0
THIRD_PARTY_NOTICES.md ADDED
@@ -0,0 +1,46 @@
1
+ # Third-Party Notices
2
+
3
+ Retriever vendors a small set of JavaScript assets so generated IR visualization
4
+ HTML files can open offline. The runtime also references public CDN URLs for the
5
+ same libraries when appropriate.
6
+
7
+ ## Cytoscape.js
8
+
9
+ - Local file: `src/retriever/ir/assets/cytoscape.min.js`
10
+ - Version used by CDN fallback: `3.26.0`
11
+ - Upstream project: https://js.cytoscape.org/
12
+ - License: MIT
13
+ - Copyright: Copyright (c) 2016-2023, The Cytoscape Consortium.
14
+
15
+ The bundled minified file includes the upstream MIT license notice.
16
+
17
+ ## Dagre
18
+
19
+ - Local file: `src/retriever/ir/assets/dagre.min.js`
20
+ - Version used by CDN fallback: `0.8.5`
21
+ - Upstream project: https://github.com/dagrejs/dagre
22
+ - License: MIT
23
+ - Copyright: Copyright (c) 2012-2014 Chris Pettitt.
24
+
25
+ The bundled minified file includes the upstream MIT license notice.
26
+
27
+ ## Graphlib
28
+
29
+ - Local file: embedded inside `src/retriever/ir/assets/dagre.min.js`
30
+ - Upstream project: https://github.com/dagrejs/graphlib
31
+ - License: BSD-style license
32
+ - Copyright: Copyright (c) 2014, Chris Pettitt.
33
+
34
+ The bundled Dagre artifact includes Graphlib and its redistribution notice.
35
+
36
+ ## cytoscape-dagre
37
+
38
+ - Local file: `src/retriever/ir/assets/cytoscape-dagre.min.js`
39
+ - Version used by CDN fallback: `2.5.0`
40
+ - Upstream package: https://www.npmjs.com/package/cytoscape-dagre
41
+ - Source repository: https://github.com/cytoscape/cytoscape.js-dagre
42
+ - License: MIT
43
+
44
+ The local file was minified by jsDelivr from the upstream npm package. Keep this
45
+ notice with the vendored artifact because the minified file itself only contains
46
+ the jsDelivr minification header.
retriever/__init__.py ADDED
@@ -0,0 +1,196 @@
1
+ """Top-level convenience surface for Retriever.
2
+
3
+ `retriever` re-exports the most common runtime/core entry points so notebooks and
4
+ small scripts can stay terse. The preferred explicit surfaces still live in:
5
+
6
+ - `retriever.flow` for authoring `Flow` and `Pipeline`
7
+ - `retriever.rt` for backend execution
8
+ - `retriever.registry` for discoverable flows, pipelines, and types
9
+ - `retriever.types` for shared payload and contract definitions
10
+ """
11
+
12
+ from importlib import import_module
13
+ from importlib.metadata import (
14
+ PackageNotFoundError,
15
+ packages_distributions as _packages_distributions,
16
+ version as _package_version,
17
+ )
18
+ from types import ModuleType
19
+
20
+
21
+ def _resolve_version() -> str:
22
+ # Resolve the version from whichever installed distribution provides the
23
+ # `retriever` import package, rather than assuming one dist name. Fall back
24
+ # to a source-tree marker when running uninstalled.
25
+ candidates: list[str] = []
26
+ try:
27
+ candidates = list(_packages_distributions().get("retriever", []))
28
+ except Exception:
29
+ candidates = []
30
+ for dist in [*candidates, "retriever-core"]:
31
+ try:
32
+ return _package_version(dist)
33
+ except PackageNotFoundError:
34
+ continue
35
+ return "0.0.0+local"
36
+
37
+
38
+ __version__ = _resolve_version()
39
+
40
+ from retriever.flow import Flow, Rate, Clock, Trigger, Hybrid, Tick
41
+ from retriever.flow.adapter import Latest, Hold, Window, Events
42
+ from retriever.flow.pipeline import (
43
+ Pipeline,
44
+ clear_default_pipeline,
45
+ connect,
46
+ default_pipeline,
47
+ reset_default_pipeline,
48
+ run,
49
+ step,
50
+ reset,
51
+ view,
52
+ )
53
+ from retriever.flow import io, TemporalFlow, PipelineBuilder, compose, select
54
+
55
+
56
+ from typing import Any, Optional, Union
57
+ from retriever.config import RecordConfig, VizConfig, _UNSET as _CONFIG_UNSET, set_global_config
58
+
59
+ def init(
60
+ name: Optional[str] | object = _CONFIG_UNSET,
61
+ record: Optional[Union[str, RecordConfig]] | object = _CONFIG_UNSET,
62
+ backend: Optional[str] | object = _CONFIG_UNSET,
63
+ backend_config: Optional[dict] | object = _CONFIG_UNSET,
64
+ default_sync: Optional[Any] | object = _CONFIG_UNSET,
65
+ default_viz: Optional[VizConfig] | object = _CONFIG_UNSET,
66
+ ) -> None:
67
+ """
68
+ Set process-wide default configuration for convenience helpers.
69
+
70
+ `retriever.init(...)` only updates global defaults used by the thread-local
71
+ default pipeline and by `Pipeline.connect(...)` when `sync=` is omitted.
72
+ Pass `None` explicitly to clear optional defaults like `record`,
73
+ `default_sync`, or `default_viz`. It does not build, reset, or run a
74
+ pipeline by itself. For scripts and shared examples, prefer an explicit
75
+ `Pipeline(...)` object and pass runtime settings directly to `pipe.run(...)`.
76
+
77
+ Args:
78
+ name: Session name (useful for logging/recording)
79
+ record: Recording path (str) or configuration (RecordConfig)
80
+ backend: Default backend for `pipe.run()` / `retriever.run()`
81
+ (e.g. "multiprocessing", "dora")
82
+ backend_config: Default backend configuration dict. Values are merged
83
+ with (and overridden by) `pipe.run(backend_config=...)`.
84
+ default_sync: Default sync adapter for connections (e.g. Latest()).
85
+ Pass None explicitly to clear it so every explicit connection
86
+ must specify sync=.
87
+ default_viz: Default visualization policy for all output ports that do not
88
+ have an explicit viz= on their .then() connection.
89
+ Example: retriever.init(default_viz=VizConfig(hz=5.0))
90
+ enables lightweight visualization across the whole pipeline.
91
+ """
92
+ set_global_config(
93
+ name=name,
94
+ record=record,
95
+ backend=backend,
96
+ backend_config=backend_config,
97
+ default_sync=default_sync,
98
+ default_viz=default_viz,
99
+ )
100
+
101
+
102
+
103
+ # Registry Exports
104
+ from retriever.registry import (
105
+ register_flow,
106
+ get_flow,
107
+ get_flow_class,
108
+ list_flows,
109
+ find_flows,
110
+ register_pipeline,
111
+ get_pipeline,
112
+ get_pipeline_factory,
113
+ list_pipelines,
114
+ find_pipelines,
115
+ build_ir,
116
+ build_pipeline_flow,
117
+ build_pipeline_surface,
118
+ get_type_info,
119
+ get_registered_types,
120
+ register_type,
121
+ get_type,
122
+ list_types,
123
+ find_types,
124
+ get_type_name,
125
+ resolve_schema_ref,
126
+ )
127
+
128
+ # Import built-in shared schema types so registry lookups are stable after plain `import retriever`.
129
+ from retriever.types import ClockDomain as _ClockDomain, SchemaRef as _SchemaRef, StreamId as _StreamId # noqa: F401
130
+ # Import built-in domain typing packages so registry lookups are stable after plain `import retriever`.
131
+ from retriever.types import data as _data # noqa: F401
132
+ from retriever.types import spatial as _spatial # noqa: F401
133
+
134
+
135
+ def __getattr__(name: str) -> ModuleType:
136
+ """Load optional top-level convenience modules on first access."""
137
+
138
+ if name == "hub":
139
+ module = import_module("retriever.hub")
140
+ globals()[name] = module
141
+ return module
142
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
143
+
144
+
145
+ __all__ = [
146
+ "Flow",
147
+ "Rate",
148
+ "Clock",
149
+ "Trigger",
150
+ "Hybrid",
151
+ "Tick",
152
+ "Latest",
153
+ "Hold",
154
+ "Window",
155
+ "Events",
156
+ "Pipeline",
157
+ "connect",
158
+ "default_pipeline",
159
+ "reset_default_pipeline",
160
+ "clear_default_pipeline",
161
+ "run",
162
+ "step",
163
+ "reset",
164
+ "view",
165
+ "init",
166
+ "RecordConfig",
167
+ "VizConfig",
168
+ "io",
169
+ "compose",
170
+ "select",
171
+ "TemporalFlow",
172
+ "PipelineBuilder",
173
+ # Registry
174
+ "register_flow",
175
+ "get_flow",
176
+ "get_flow_class",
177
+ "list_flows",
178
+ "find_flows",
179
+ "register_pipeline",
180
+ "get_pipeline",
181
+ "get_pipeline_factory",
182
+ "list_pipelines",
183
+ "find_pipelines",
184
+ "build_ir",
185
+ "build_pipeline_flow",
186
+ "build_pipeline_surface",
187
+ "register_type",
188
+ "get_type",
189
+ "get_type_info",
190
+ "get_registered_types",
191
+ "get_type_name",
192
+ "list_types",
193
+ "find_types",
194
+ "resolve_schema_ref",
195
+ "hub",
196
+ ]
@@ -0,0 +1,5 @@
1
+ """Internal helper surface for Retriever implementation modules."""
2
+
3
+ from .helpers import as_tagged, load_plugins, type_to_str
4
+
5
+ __all__ = ["as_tagged", "load_plugins", "type_to_str"]
@@ -0,0 +1,113 @@
1
+ """
2
+ Retriever utility functions.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import logging
8
+ from dataclasses import asdict, is_dataclass
9
+ from importlib import metadata
10
+ from typing import Any, Dict, Iterable, TypeVar
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+ T = TypeVar('T')
15
+
16
+ # ============================================================
17
+ # Plugin Loading
18
+ # ============================================================
19
+
20
+ _PLUGINS_LOADED = False
21
+
22
+
23
+ def _iter_entry_points(group: str) -> Iterable[Any]:
24
+ """Iterate entry points for a given group across Python versions."""
25
+ eps = metadata.entry_points()
26
+ # Python 3.10+: EntryPoints has `.select`
27
+ if hasattr(eps, "select"):
28
+ return eps.select(group=group) # type: ignore[attr-defined]
29
+ # Older: dict-like
30
+ return eps.get(group, []) # type: ignore[return-value]
31
+
32
+
33
+ def load_plugins(*, force: bool = False, group: str = "retriever.plugins") -> int:
34
+ """
35
+ Load plugins registered under the given entry point group.
36
+
37
+ Convention:
38
+ - Plugins are exposed via Python entry points under the group `retriever.plugins`
39
+ - Each entry point must resolve to a callable with signature `() -> None`
40
+ that performs registration (e.g., calls `register_pipeline(...)`).
41
+
42
+ Returns:
43
+ Number of successfully invoked plugin callables.
44
+ """
45
+ global _PLUGINS_LOADED
46
+ if _PLUGINS_LOADED and not force:
47
+ return 0
48
+
49
+ invoked = 0
50
+ for ep in _iter_entry_points(group):
51
+ try:
52
+ plugin = ep.load()
53
+ except Exception as e:
54
+ logger.warning("Failed to load plugin entry point '%s': %s", getattr(ep, "name", ep), e)
55
+ continue
56
+
57
+ if not callable(plugin):
58
+ logger.warning(
59
+ "Plugin entry point '%s' resolved to non-callable: %r",
60
+ getattr(ep, "name", ep),
61
+ plugin,
62
+ )
63
+ continue
64
+
65
+ try:
66
+ plugin()
67
+ invoked += 1
68
+ except Exception as e:
69
+ logger.warning("Plugin '%s' raised during registration: %s", getattr(ep, "name", ep), e)
70
+
71
+ _PLUGINS_LOADED = True
72
+ return invoked
73
+
74
+
75
+ # ============================================================
76
+ # Type Utilities
77
+ # ============================================================
78
+
79
+
80
+ def type_to_str(typ: type) -> str:
81
+ """
82
+ Convert Python type to string representation.
83
+
84
+ Args:
85
+ typ: Python type object
86
+
87
+ Returns:
88
+ String representation of type
89
+ """
90
+ if hasattr(typ, '__module__') and hasattr(typ, '__name__'):
91
+ if typ.__module__ == 'builtins':
92
+ return typ.__name__
93
+ return f"{typ.__module__}.{typ.__name__}"
94
+ return str(typ)
95
+
96
+
97
+ def as_tagged(obj: T) -> Dict[str, Any]:
98
+ """
99
+ Convert dataclass to tagged dict format: {ClassName: {fields}}.
100
+
101
+ Used for polymorphic serialization with type discrimination.
102
+
103
+ Args:
104
+ obj: Dataclass instance
105
+
106
+ Returns:
107
+ Dict in format {ClassName: fields_dict}
108
+ """
109
+ if not is_dataclass(obj):
110
+ return obj
111
+ class_name = obj.__class__.__name__
112
+ fields = asdict(obj)
113
+ return {class_name: fields}