Skip to content
PACKAGES

Graph

Kind: class

Source: src/graphrefly/_facade.py:700

Graph(*, report: Callable[[HostReport], object] | None = None, clock: Clock | None = None, require_recipe: bool = False)

A graph of nodes: one single-threaded domain on the Python kernel.

NameTypeDescription
closedboolReturn whether this graph facade has been closed.
close() -> None

Close 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(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(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(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]) -> R

Run 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(node: Node[Any], deps: Iterable[Node[Any]], callback: NodeCallback, *, setup: SetupCallback | None = None, recipe: Recipe | None = None) -> None

Give a computed node a new instance under the same name and subscribers.

Source: src/graphrefly/_facade.py:1003

definition(node: Node[Any]) -> NodeDefinition

Return the node’s current definition; reading changes nothing.

Source: src/graphrefly/_facade.py:1031

find(node_id: str, /) -> Node[Any] | None

Return 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() -> 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(nodes: Iterable[Node[Any]], callback: Callable[[GraphEvent], object]) -> Subscription

Subscribe 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(node: Node[Any]) -> Subscription

Hold 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() -> GraphReentryQueue

Return this graph’s explicit owner-thread async re-entry queue.

Source: src/graphrefly/_facade.py:1148

checkpoint() -> GraphCheckpoint

Capture this graph at a wave boundary as strict JSON (R-checkpoint).

Source: src/graphrefly/_facade.py:1162