pydantic-graph 1.22.0__tar.gz → 1.34.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.
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/PKG-INFO +1 -1
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/graph.py +14 -11
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/graph_builder.py +5 -3
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/mermaid.py +1 -1
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/graph.py +1 -1
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/.gitignore +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/LICENSE +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/README.md +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/__init__.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/_utils.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/__init__.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/decision.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/id_types.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/join.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/node.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/node_types.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/parent_forks.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/paths.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/step.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/beta/util.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/exceptions.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/mermaid.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/nodes.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/persistence/__init__.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/persistence/_utils.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/persistence/file.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/persistence/in_mem.py +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pydantic_graph/py.typed +0 -0
- {pydantic_graph-1.22.0 → pydantic_graph-1.34.0}/pyproject.toml +0 -0
|
@@ -13,7 +13,7 @@ from contextlib import AbstractContextManager, AsyncExitStack, ExitStack, asyncc
|
|
|
13
13
|
from dataclasses import dataclass, field
|
|
14
14
|
from typing import TYPE_CHECKING, Any, Generic, Literal, TypeGuard, cast, get_args, get_origin, overload
|
|
15
15
|
|
|
16
|
-
from anyio import CancelScope, create_memory_object_stream, create_task_group
|
|
16
|
+
from anyio import BrokenResourceError, CancelScope, create_memory_object_stream, create_task_group
|
|
17
17
|
from anyio.abc import TaskGroup
|
|
18
18
|
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
|
|
19
19
|
from typing_extensions import TypeVar, assert_never
|
|
@@ -43,9 +43,9 @@ from pydantic_graph.beta.util import unpack_type_expression
|
|
|
43
43
|
from pydantic_graph.nodes import BaseNode, End
|
|
44
44
|
|
|
45
45
|
if sys.version_info < (3, 11):
|
|
46
|
-
from exceptiongroup import
|
|
46
|
+
from exceptiongroup import BaseExceptionGroup as BaseExceptionGroup # pragma: lax no cover
|
|
47
47
|
else:
|
|
48
|
-
|
|
48
|
+
BaseExceptionGroup = BaseExceptionGroup # pragma: lax no cover
|
|
49
49
|
|
|
50
50
|
if TYPE_CHECKING:
|
|
51
51
|
from pydantic_graph.beta.mermaid import StateDiagramDirection
|
|
@@ -562,7 +562,7 @@ class _GraphIterator(Generic[StateT, DepsT, OutputT]):
|
|
|
562
562
|
self.iter_stream_sender, self.iter_stream_receiver = create_memory_object_stream[_GraphTaskResult]()
|
|
563
563
|
self._next_node_run_id = 1
|
|
564
564
|
|
|
565
|
-
async def iter_graph( # noqa C901
|
|
565
|
+
async def iter_graph( # noqa: C901
|
|
566
566
|
self, first_task: GraphTask
|
|
567
567
|
) -> AsyncGenerator[EndMarker[OutputT] | Sequence[GraphTask], EndMarker[OutputT] | Sequence[GraphTask]]:
|
|
568
568
|
async with self.iter_stream_sender:
|
|
@@ -748,12 +748,15 @@ class _GraphIterator(Generic[StateT, DepsT, OutputT]):
|
|
|
748
748
|
with CancelScope() as scope:
|
|
749
749
|
self.cancel_scopes[t_.task_id] = scope
|
|
750
750
|
result = await self._run_task(t_)
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
751
|
+
try:
|
|
752
|
+
if isinstance(result, _GraphTaskAsyncIterable):
|
|
753
|
+
async for new_tasks in result.iterable:
|
|
754
|
+
await self.iter_stream_sender.send(_GraphTaskResult(t_, new_tasks, False))
|
|
755
|
+
await self.iter_stream_sender.send(_GraphTaskResult(t_, []))
|
|
756
|
+
else:
|
|
757
|
+
await self.iter_stream_sender.send(_GraphTaskResult(t_, result))
|
|
758
|
+
except BrokenResourceError:
|
|
759
|
+
pass # pragma: no cover # This can happen in difficult-to-reproduce circumstances when cancelling an asyncio task
|
|
757
760
|
|
|
758
761
|
async def _run_task(
|
|
759
762
|
self,
|
|
@@ -970,7 +973,7 @@ def _unwrap_exception_groups():
|
|
|
970
973
|
else:
|
|
971
974
|
try:
|
|
972
975
|
yield
|
|
973
|
-
except
|
|
976
|
+
except BaseExceptionGroup as e:
|
|
974
977
|
exception = e.exceptions[0]
|
|
975
978
|
if exception.__cause__ is None:
|
|
976
979
|
# bizarrely, this prevents recursion errors when formatting the exception for logfire
|
|
@@ -284,6 +284,8 @@ class GraphBuilder(Generic[StateT, DepsT, GraphInputT, GraphOutputT]):
|
|
|
284
284
|
async def wrapper(ctx: StepContext[StateT, DepsT, InputT]):
|
|
285
285
|
return call(ctx)
|
|
286
286
|
|
|
287
|
+
node_id = node_id or get_callable_name(call)
|
|
288
|
+
|
|
287
289
|
return self.step(call=wrapper, node_id=node_id, label=label)
|
|
288
290
|
|
|
289
291
|
@overload
|
|
@@ -318,7 +320,7 @@ class GraphBuilder(Generic[StateT, DepsT, GraphInputT, GraphOutputT]):
|
|
|
318
320
|
preferred_parent_fork: Literal['farthest', 'closest'] = 'farthest',
|
|
319
321
|
) -> Join[StateT, DepsT, InputT, OutputT]:
|
|
320
322
|
if initial_factory is UNSET:
|
|
321
|
-
initial_factory = lambda: initial # pyright: ignore[reportAssignmentType] # noqa E731
|
|
323
|
+
initial_factory = lambda: initial # pyright: ignore[reportAssignmentType] # noqa: E731
|
|
322
324
|
|
|
323
325
|
return Join[StateT, DepsT, InputT, OutputT](
|
|
324
326
|
id=JoinID(NodeID(node_id or generate_placeholder_node_id(get_callable_name(reducer)))),
|
|
@@ -329,7 +331,7 @@ class GraphBuilder(Generic[StateT, DepsT, GraphInputT, GraphOutputT]):
|
|
|
329
331
|
)
|
|
330
332
|
|
|
331
333
|
# Edge building
|
|
332
|
-
def add(self, *edges: EdgePath[StateT, DepsT]) -> None: # noqa C901
|
|
334
|
+
def add(self, *edges: EdgePath[StateT, DepsT]) -> None: # noqa: C901
|
|
333
335
|
"""Add one or more edge paths to the graph.
|
|
334
336
|
|
|
335
337
|
This method processes edge paths and automatically creates any necessary
|
|
@@ -674,7 +676,7 @@ class GraphBuilder(Generic[StateT, DepsT, GraphInputT, GraphOutputT]):
|
|
|
674
676
|
)
|
|
675
677
|
|
|
676
678
|
|
|
677
|
-
def _validate_graph_structure( # noqa C901
|
|
679
|
+
def _validate_graph_structure( # noqa: C901
|
|
678
680
|
nodes: dict[NodeID, AnyNode],
|
|
679
681
|
edges_by_source: dict[NodeID, list[Path]],
|
|
680
682
|
) -> None:
|
|
@@ -49,7 +49,7 @@ class MermaidEdge:
|
|
|
49
49
|
label: str | None
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def build_mermaid_graph( # noqa C901
|
|
52
|
+
def build_mermaid_graph( # noqa: C901
|
|
53
53
|
graph_nodes: dict[NodeID, AnyNode], graph_edges_by_source: dict[NodeID, list[Path]]
|
|
54
54
|
) -> MermaidGraph:
|
|
55
55
|
"""Build a mermaid graph."""
|
|
@@ -167,7 +167,7 @@ class Graph(Generic[StateT, DepsT, RunEndT]):
|
|
|
167
167
|
) -> GraphRunResult[StateT, RunEndT]:
|
|
168
168
|
"""Synchronously run the graph.
|
|
169
169
|
|
|
170
|
-
This is a convenience method that wraps [`self.run`][pydantic_graph.Graph.run] with `loop.run_until_complete(...)`.
|
|
170
|
+
This is a convenience method that wraps [`self.run`][pydantic_graph.graph.Graph.run] with `loop.run_until_complete(...)`.
|
|
171
171
|
You therefore can't use this method inside async code or if there's an active event loop.
|
|
172
172
|
|
|
173
173
|
Args:
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|