penguiflow 1.0.0__tar.gz → 1.0.2__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.
Potentially problematic release.
This version of penguiflow might be problematic. Click here for more details.
- {penguiflow-1.0.0 → penguiflow-1.0.2}/PKG-INFO +13 -1
- {penguiflow-1.0.0 → penguiflow-1.0.2}/README.md +12 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow/__init__.py +1 -1
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow/core.py +22 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow.egg-info/PKG-INFO +13 -1
- {penguiflow-1.0.0 → penguiflow-1.0.2}/pyproject.toml +1 -1
- {penguiflow-1.0.0 → penguiflow-1.0.2}/tests/test_core.py +43 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/LICENSE +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow/middlewares.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow/node.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow/patterns.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow/registry.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow/types.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow/viz.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow.egg-info/SOURCES.txt +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow.egg-info/dependency_links.txt +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow.egg-info/requires.txt +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/penguiflow.egg-info/top_level.txt +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/setup.cfg +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/tests/test_controller.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/tests/test_patterns.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/tests/test_registry.py +0 -0
- {penguiflow-1.0.0 → penguiflow-1.0.2}/tests/test_types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: penguiflow
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: Async agent orchestration primitives.
|
|
5
5
|
Author: PenguiFlow Team
|
|
6
6
|
License: MIT License
|
|
@@ -147,11 +147,13 @@ await flow.stop()
|
|
|
147
147
|
* Flows are orchestrators, mostly I/O-bound.
|
|
148
148
|
* Async tasks are cheap, predictable, and cancellable.
|
|
149
149
|
* Heavy CPU work should be offloaded inside a node (process pool, Ray, etc.), not in PenguiFlow itself.
|
|
150
|
+
* v1 intentionally stays in-process; scaling out or persisting state will arrive with future pluggable backends.
|
|
150
151
|
|
|
151
152
|
2. **Typed contracts.**
|
|
152
153
|
|
|
153
154
|
* In/out models per node are defined with Pydantic.
|
|
154
155
|
* Validated at runtime via cached `TypeAdapter`s.
|
|
156
|
+
* `flow.run(registry=...)` verifies every validating node is registered so misconfigurations fail fast.
|
|
155
157
|
|
|
156
158
|
3. **Reliability first.**
|
|
157
159
|
|
|
@@ -331,6 +333,16 @@ flow focused on high-level orchestration logic.
|
|
|
331
333
|
* **NodePolicy**: set validation scope plus per-node timeout, retries, and backoff curves.
|
|
332
334
|
* **Structured logs**: enrich every node event with `{ts, trace_id, node_name, event, latency_ms, q_depth_in, attempt}`.
|
|
333
335
|
* **Middleware hooks**: subscribe observers (e.g., MLflow) to the structured event stream.
|
|
336
|
+
* See `examples/reliability_middleware/` for a concrete timeout + retry walkthrough.
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## ⚠️ Current Constraints
|
|
341
|
+
|
|
342
|
+
- **In-process runtime**: there is no built-in distribution layer yet. Long-running CPU work should be delegated to your own pools or services.
|
|
343
|
+
- **Registry-driven typing**: nodes default to validation. Provide a `ModelRegistry` when calling `flow.run(...)` or set `validate="none"` explicitly for untyped hops.
|
|
344
|
+
- **Observability**: structured logs + middleware hooks are available, but integrations with third-party stacks (OTel, Prometheus) are DIY for now.
|
|
345
|
+
- **Roadmap**: v2 targets streaming, distributed backends, richer observability, and test harnesses. Contributions and proposals are welcome!
|
|
334
346
|
|
|
335
347
|
---
|
|
336
348
|
|
|
@@ -108,11 +108,13 @@ await flow.stop()
|
|
|
108
108
|
* Flows are orchestrators, mostly I/O-bound.
|
|
109
109
|
* Async tasks are cheap, predictable, and cancellable.
|
|
110
110
|
* Heavy CPU work should be offloaded inside a node (process pool, Ray, etc.), not in PenguiFlow itself.
|
|
111
|
+
* v1 intentionally stays in-process; scaling out or persisting state will arrive with future pluggable backends.
|
|
111
112
|
|
|
112
113
|
2. **Typed contracts.**
|
|
113
114
|
|
|
114
115
|
* In/out models per node are defined with Pydantic.
|
|
115
116
|
* Validated at runtime via cached `TypeAdapter`s.
|
|
117
|
+
* `flow.run(registry=...)` verifies every validating node is registered so misconfigurations fail fast.
|
|
116
118
|
|
|
117
119
|
3. **Reliability first.**
|
|
118
120
|
|
|
@@ -292,6 +294,16 @@ flow focused on high-level orchestration logic.
|
|
|
292
294
|
* **NodePolicy**: set validation scope plus per-node timeout, retries, and backoff curves.
|
|
293
295
|
* **Structured logs**: enrich every node event with `{ts, trace_id, node_name, event, latency_ms, q_depth_in, attempt}`.
|
|
294
296
|
* **Middleware hooks**: subscribe observers (e.g., MLflow) to the structured event stream.
|
|
297
|
+
* See `examples/reliability_middleware/` for a concrete timeout + retry walkthrough.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## ⚠️ Current Constraints
|
|
302
|
+
|
|
303
|
+
- **In-process runtime**: there is no built-in distribution layer yet. Long-running CPU work should be delegated to your own pools or services.
|
|
304
|
+
- **Registry-driven typing**: nodes default to validation. Provide a `ModelRegistry` when calling `flow.run(...)` or set `validate="none"` explicitly for untyped hops.
|
|
305
|
+
- **Observability**: structured logs + middleware hooks are available, but integrations with third-party stacks (OTel, Prometheus) are DIY for now.
|
|
306
|
+
- **Roadmap**: v2 targets streaming, distributed backends, richer observability, and test harnesses. Contributions and proposals are welcome!
|
|
295
307
|
|
|
296
308
|
---
|
|
297
309
|
|
|
@@ -288,6 +288,8 @@ class PenguiFlow:
|
|
|
288
288
|
raise RuntimeError("PenguiFlow already running")
|
|
289
289
|
self._running = True
|
|
290
290
|
self._registry = registry
|
|
291
|
+
if registry is not None:
|
|
292
|
+
self._ensure_registry_covers_nodes(registry)
|
|
291
293
|
loop = asyncio.get_running_loop()
|
|
292
294
|
|
|
293
295
|
for node in self._nodes:
|
|
@@ -542,6 +544,26 @@ class PenguiFlow:
|
|
|
542
544
|
},
|
|
543
545
|
)
|
|
544
546
|
|
|
547
|
+
def _ensure_registry_covers_nodes(self, registry: ModelRegistry) -> None:
|
|
548
|
+
missing: list[str] = []
|
|
549
|
+
for node in self._nodes:
|
|
550
|
+
if node.policy.validate == "none":
|
|
551
|
+
continue
|
|
552
|
+
node_name = node.name
|
|
553
|
+
if node_name is None:
|
|
554
|
+
continue
|
|
555
|
+
try:
|
|
556
|
+
registry.adapters(node_name)
|
|
557
|
+
except KeyError:
|
|
558
|
+
missing.append(node_name)
|
|
559
|
+
|
|
560
|
+
if missing:
|
|
561
|
+
formatted = ", ".join(sorted(missing))
|
|
562
|
+
raise RuntimeError(
|
|
563
|
+
"ModelRegistry is missing entries for nodes requiring validation: "
|
|
564
|
+
f"{formatted}"
|
|
565
|
+
)
|
|
566
|
+
|
|
545
567
|
|
|
546
568
|
PlaybookFactory = Callable[[], tuple["PenguiFlow", ModelRegistry | None]]
|
|
547
569
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: penguiflow
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: Async agent orchestration primitives.
|
|
5
5
|
Author: PenguiFlow Team
|
|
6
6
|
License: MIT License
|
|
@@ -147,11 +147,13 @@ await flow.stop()
|
|
|
147
147
|
* Flows are orchestrators, mostly I/O-bound.
|
|
148
148
|
* Async tasks are cheap, predictable, and cancellable.
|
|
149
149
|
* Heavy CPU work should be offloaded inside a node (process pool, Ray, etc.), not in PenguiFlow itself.
|
|
150
|
+
* v1 intentionally stays in-process; scaling out or persisting state will arrive with future pluggable backends.
|
|
150
151
|
|
|
151
152
|
2. **Typed contracts.**
|
|
152
153
|
|
|
153
154
|
* In/out models per node are defined with Pydantic.
|
|
154
155
|
* Validated at runtime via cached `TypeAdapter`s.
|
|
156
|
+
* `flow.run(registry=...)` verifies every validating node is registered so misconfigurations fail fast.
|
|
155
157
|
|
|
156
158
|
3. **Reliability first.**
|
|
157
159
|
|
|
@@ -331,6 +333,16 @@ flow focused on high-level orchestration logic.
|
|
|
331
333
|
* **NodePolicy**: set validation scope plus per-node timeout, retries, and backoff curves.
|
|
332
334
|
* **Structured logs**: enrich every node event with `{ts, trace_id, node_name, event, latency_ms, q_depth_in, attempt}`.
|
|
333
335
|
* **Middleware hooks**: subscribe observers (e.g., MLflow) to the structured event stream.
|
|
336
|
+
* See `examples/reliability_middleware/` for a concrete timeout + retry walkthrough.
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## ⚠️ Current Constraints
|
|
341
|
+
|
|
342
|
+
- **In-process runtime**: there is no built-in distribution layer yet. Long-running CPU work should be delegated to your own pools or services.
|
|
343
|
+
- **Registry-driven typing**: nodes default to validation. Provide a `ModelRegistry` when calling `flow.run(...)` or set `validate="none"` explicitly for untyped hops.
|
|
344
|
+
- **Observability**: structured logs + middleware hooks are available, but integrations with third-party stacks (OTel, Prometheus) are DIY for now.
|
|
345
|
+
- **Roadmap**: v2 targets streaming, distributed backends, richer observability, and test harnesses. Contributions and proposals are welcome!
|
|
334
346
|
|
|
335
347
|
---
|
|
336
348
|
|
|
@@ -6,9 +6,11 @@ import asyncio
|
|
|
6
6
|
import logging
|
|
7
7
|
|
|
8
8
|
import pytest
|
|
9
|
+
from pydantic import BaseModel
|
|
9
10
|
|
|
10
11
|
from penguiflow.core import CycleError, PenguiFlow, create
|
|
11
12
|
from penguiflow.node import Node, NodePolicy
|
|
13
|
+
from penguiflow.registry import ModelRegistry
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
@pytest.mark.asyncio
|
|
@@ -249,3 +251,44 @@ async def test_middlewares_receive_events() -> None:
|
|
|
249
251
|
|
|
250
252
|
events_names = [name for name, _ in events]
|
|
251
253
|
assert "node_success" in events_names
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
@pytest.mark.asyncio
|
|
257
|
+
async def test_run_with_registry_requires_registered_nodes() -> None:
|
|
258
|
+
async def handler(msg: str, ctx) -> str:
|
|
259
|
+
return msg
|
|
260
|
+
|
|
261
|
+
node = Node(handler, name="handler")
|
|
262
|
+
flow = create(node.to())
|
|
263
|
+
registry = ModelRegistry()
|
|
264
|
+
|
|
265
|
+
with pytest.raises(RuntimeError) as exc:
|
|
266
|
+
flow.run(registry=registry)
|
|
267
|
+
|
|
268
|
+
assert "handler" in str(exc.value)
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
@pytest.mark.asyncio
|
|
272
|
+
async def test_run_with_registry_accepts_registered_nodes() -> None:
|
|
273
|
+
class EchoModel(BaseModel):
|
|
274
|
+
text: str
|
|
275
|
+
|
|
276
|
+
async def handler(msg: EchoModel, ctx) -> EchoModel:
|
|
277
|
+
return msg
|
|
278
|
+
|
|
279
|
+
node = Node(handler, name="echo")
|
|
280
|
+
flow = create(node.to())
|
|
281
|
+
|
|
282
|
+
registry = ModelRegistry()
|
|
283
|
+
registry.register("echo", EchoModel, EchoModel)
|
|
284
|
+
|
|
285
|
+
flow.run(registry=registry)
|
|
286
|
+
|
|
287
|
+
message = EchoModel(text="hi")
|
|
288
|
+
await flow.emit(message)
|
|
289
|
+
result = await flow.fetch()
|
|
290
|
+
|
|
291
|
+
assert isinstance(result, EchoModel)
|
|
292
|
+
assert result.text == "hi"
|
|
293
|
+
|
|
294
|
+
await flow.stop()
|
|
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
|