flowgentic.store¶
store
¶
Key-value stores in the allocation's memory: RaDEX, or a dictionary in-process.
A KeyValueStore holds picklable values under string keys. The LangGraph
checkpointer (flowgentic.langgraph.KeyValueSaver) keeps agents' state in
one, and tools can share tensors through the same client.
RadexStore: RaDEX's client on a Dragon distributed dictionary.RadexStore.attach(descriptor)returns this process's one client for that dictionary: every attach costs Dragon channels, so a process attaches once. RaDEX is built from source; it is imported only when a store is attached. A call that times out, as on a node that is slow for a while, is made again, after a pause that grows, untildeadlineseconds have passed since the call was made: a slow manager delays its callers, and only one that stays silent fails them. A sync call made on an event loop's thread is tried once, as a loop must not wait for the pauses. Its async calls (aget,aput, ...) go to Dragon from a pool of clients, one call at a time for each of the dictionary's managers: a manager that does not answer holds the calls for its own keys, and the others go on.MemoryStore: a dictionary in this process, for tests and local runs. It pickles values as RaDEX does, so callers share no objects.
Values are pickled: a store must be trusted by every process that reads it, which holds for a store inside one job's allocation.
Classes:
| Name | Description |
|---|---|
KeyValueStore |
What the checkpointer needs from a store. |
AsyncKeyValueStore |
A store whose calls an event loop can await: each waits only for itself. |
MemoryStore |
A dictionary in this process, shared by its threads. |
RadexStore |
RaDEX's Dragon client, as a |
Attributes:
| Name | Type | Description |
|---|---|---|
MISSING |
Any
|
The default of |
MISSING
module-attribute
¶
The default of get: raise KeyError for a missing key.
KeyValueStore
¶
Bases: Protocol
What the checkpointer needs from a store.
A store must be safe to call from several threads at once. LoopRunner
calls a store that has no async calls (AsyncKeyValueStore) from its
store_threads threads, 8 by default, and a call that waits holds only
its own thread. MemoryStore and RadexStore are safe; a store of
your own needs a lock around what its calls share, or store_threads=0,
which calls it on the event loop, one call at a time.
Methods:
| Name | Description |
|---|---|
get |
The value under |
put |
Store |
delete |
Remove |
contains |
Whether |
AsyncKeyValueStore
¶
Bases: Protocol
A store whose calls an event loop can await: each waits only for itself.
LoopRunner uses them when the store has them.
MemoryStore
¶
A dictionary in this process, shared by its threads.
Methods:
| Name | Description |
|---|---|
put_tensor |
Store an array as float64. Tensors need NumPy, as RaDEX's client does. |
put_tensor
¶
Store an array as float64. Tensors need NumPy, as RaDEX's client does.
RadexStore
¶
RaDEX's Dragon client, as a KeyValueStore. Use attach.
timeout: seconds each of Dragon's operations in a call may take, RaDEX's
attach timeout. A call whose operation times out is made again, after 0.25 s,
then twice as long each time up to 5 s, until deadline seconds have
passed since the call was made, its wait for a lane included; then the last
timeout is raised, or, for a call that waited that long for a lane, a
timeout of the same kind. The last attempt begins before the deadline and
can end up to timeout after it. Every call is safe to make again: a put replaces,
and a delete checks first. A sync call made on the thread of a running
event loop is tried once, as in 0.6.0: the loop would wait for every pause,
and so would all its agents. timeouts: the times a call's operation, or
its wait for a lane, timed out.
Its calls (get, put, ...) share one client, which makes one call at
a time: a call that waits for a manager that does not answer holds every
other call of the process. Its async calls (aget, aput, adelete,
acontains, aput_tensor, aget_tensor) do not. Each runs on one of
clients threads, each with a client of its own, and waits off the event
loop. With a RaDEX that tells which manager holds a key
(DragonClient.manager_of), each manager has a lane: one async call at a
time per manager and event loop, which waits for its lane on the event
loop. A call on two managers (a tensor's value and its metadata) takes both
lanes at once, and waits for a busy one holding neither. A manager that
does not answer then holds one thread, the calls for its own keys and at
most one other lane, that of the call in flight; the others go on. Between
attempts, a call holds its lanes and no thread. A cancelled call keeps its
lanes until its thread's call ends, so a later call for the manager does
not overtake it. lanes: whether the async calls have them.
Methods:
| Name | Description |
|---|---|
attach |
This process's store for the dictionary |
aput_tensor |
Store an array as a float64 tensor. |
put_tensor |
Store an array as a float64 tensor. |
attach
classmethod
¶
attach(
descriptor: str,
timeout: int = 30,
deadline: float = 600.0,
clients: int = 8,
) -> RadexStore
This process's store for the dictionary descriptor names; the
first attach's timeout, deadline and clients hold for the
process.