pydantic_graph.state
StateT
module-attribute
StateT = TypeVar('StateT', default=None)
Type variable for the state in a graph.
deep_copy_state
Default method for snapshotting the state in a graph run, uses copy.deepcopy
.
Source code in pydantic_graph/pydantic_graph/state.py
24 25 26 27 28 29 |
|
NodeStep
dataclass
Bases: Generic[StateT, RunEndT]
History step describing the execution of a node in a graph.
Source code in pydantic_graph/pydantic_graph/state.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
node
instance-attribute
The node that was run.
start_ts
class-attribute
instance-attribute
The timestamp when the node started running.
duration
class-attribute
instance-attribute
duration: float | None = None
The duration of the node run in seconds.
kind
class-attribute
instance-attribute
kind: Literal['node'] = 'node'
The kind of history step, can be used as a discriminator when deserializing history.
snapshot_state
class-attribute
instance-attribute
snapshot_state: Annotated[
Callable[[StateT], StateT],
Field(exclude=True, repr=False),
] = field(default=deep_copy_state, repr=False)
Function to snapshot the state of the graph.
data_snapshot
Returns a deep copy of self.node
.
Useful for summarizing history.
Source code in pydantic_graph/pydantic_graph/state.py
56 57 58 59 60 61 |
|
EndStep
dataclass
History step describing the end of a graph run.
Source code in pydantic_graph/pydantic_graph/state.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
ts
class-attribute
instance-attribute
The timestamp when the graph run ended.
kind
class-attribute
instance-attribute
kind: Literal['end'] = 'end'
The kind of history step, can be used as a discriminator when deserializing history.
data_snapshot
Returns a deep copy of self.result
.
Useful for summarizing history.
Source code in pydantic_graph/pydantic_graph/state.py
75 76 77 78 79 80 |
|