Graph
Kind: class
Source: src/graphrefly/_facade.py:700
Signature
Section titled “Signature”Graph(*, report: Callable[[HostReport], object] | None = None, clock: Clock | None = None, require_recipe: bool = False)Description
Section titled “Description”A graph of nodes: one single-threaded domain on the Python kernel.
Attributes
Section titled “Attributes”| Name | Type | Description |
|---|---|---|
closed | bool | Return whether this graph facade has been closed. |
Methods
Section titled “Methods”close() -> NoneClose this graph: release facade subscriptions, retains and async work.
Source: src/graphrefly/_facade.py:742
state(value: object = _ABSENT, name: str | None = None) -> State[Any]Create a state node, with an initial value or empty.
Source: src/graphrefly/_facade.py:756
producer
Section titled “producer”producer(callback: Callable[[], T] | None = None, name: str | None = None, *, recipe: Recipe | None = None) -> Node[T] | Callable[[Callable[[], T]], Node[T]]Create or decorate a dependency-free node whose callback’s value it sends
once per activation (Python sugar). A recipe makes it restorable: its
factory gives this callback again.
Source: src/graphrefly/_facade.py:779
derived
Section titled “derived”derived(deps: Iterable[Node[Any]], callback: Callable[..., U] | None = None, name: str | None = None, *, recipe: Recipe | None = None) -> Node[U] | Callable[[Callable[..., U]], Node[U]]Create or decorate a value-level node over dependencies.
Python sugar, not protocol: it runs once every dependency has a value and
recomputes when a dependency sent DATA in the wave. A recipe makes it
restorable: its factory gives this value-level callback again.
Source: src/graphrefly/_facade.py:819
effect
Section titled “effect”effect(deps: Iterable[Node[Any]], callback: Callable[..., object] | None = None, name: str | None = None, *, recipe: Recipe | None = None) -> Node[object] | Callable[[Callable[..., object]], Node[object]]Create or decorate a value-level side effect over dependencies (Python
sugar, with derived’s gate); it sends nothing. A recipe makes it
restorable: its factory gives this callback again.
Source: src/graphrefly/_facade.py:878
node(deps: Iterable[Node[Any]], callback: NodeCallback | None = None, name: str | None = None, *, complete: Policy = 'auto', error: Policy = 'auto', invalidate: Policy = 'auto', quiet: bool = False, setup: SetupCallback | None = None, recipe: Recipe | None = None) -> Node[object] | Callable[[NodeCallback], Node[object]]Create or decorate an advanced Ctx-level node.
Its callback runs on every wave it is given, with no first-run gate.
complete, error and invalidate choose each kind’s auto or manual
policy; a quiet node passes no pending mark on. setup(ctx) runs once per
lifetime before the first run and may return the lifetime’s cleanup. A
recipe makes the node restorable.
Source: src/graphrefly/_facade.py:930
batch(callback: Callable[[], R]) -> RRun callback at once and commit its host inputs as one wave.
Nothing is delivered while it runs; it returns what callback returned. A
callback that raises commits nothing. During a wave the commit waits until
the wave ends.
Source: src/graphrefly/_facade.py:991
replace
Section titled “replace”replace(node: Node[Any], deps: Iterable[Node[Any]], callback: NodeCallback, *, setup: SetupCallback | None = None, recipe: Recipe | None = None) -> NoneGive a computed node a new instance under the same name and subscribers.
Source: src/graphrefly/_facade.py:1003
definition
Section titled “definition”definition(node: Node[Any]) -> NodeDefinitionReturn the node’s current definition; reading changes nothing.
Source: src/graphrefly/_facade.py:1031
find(node_id: str, /) -> Node[Any] | NoneReturn the node with this id, or None; it activates nothing (R-graph-surface).
A state node comes back as its State, so it can be written after a lookup or
a restore; narrow the result with isinstance(node, State).
Source: src/graphrefly/_facade.py:1051
describe
Section titled “describe”describe() -> list[dict[str, Any]]Return the topology as JSON-ready data (R-graph-surface, R-node).
Every node in creation order as exactly {"id", "kind", "deps", "quiet"}:
kind is "state" or "node" and deps are the current dependencies,
a ctx.rewire’s included, while definition gives the declared ones. A
value or a status is read from the node. It activates and runs nothing.
Source: src/graphrefly/_facade.py:1064
observe
Section titled “observe”observe(nodes: Iterable[Node[Any]], callback: Callable[[GraphEvent], object]) -> SubscriptionSubscribe callback to each node as an ordinary subscriber (R-graph-surface).
It activates a cold node and keeps it active, and gets one GraphEvent(id, msgs) per array a node delivers, in delivery order: the START array first,
PENDING prefixes and the kernel’s RESOLVED included. Observing the whole graph
is observing every node describe gives. Calling the returned stop() stops
it; nothing more is handed on after that. A callback that raises goes to the graph’s
reporter as a SubscriberCallbackError, as a subscriber’s does.
Source: src/graphrefly/_facade.py:1079
retain
Section titled “retain”retain(node: Node[Any]) -> SubscriptionHold a node active as a subscriber that ignores what it receives
(R-graph-surface); calling the returned release() releases it. Each call is
its own subscription, so a node retained twice stays active until both are
released.
Source: src/graphrefly/_facade.py:1130
reentry_queue
Section titled “reentry_queue”reentry_queue() -> GraphReentryQueueReturn this graph’s explicit owner-thread async re-entry queue.
Source: src/graphrefly/_facade.py:1148
checkpoint
Section titled “checkpoint”checkpoint() -> GraphCheckpointCapture this graph at a wave boundary as strict JSON (R-checkpoint).
Source: src/graphrefly/_facade.py:1162