pub struct GraphSession { /* private fields */ }Expand description
The primary orchestrator: Graph + catalog + cache + events.
let mut lib = NodeCatalog::new();
lib.register("scaler", Box::new(MyScaler::new()));
lib.register("model", Box::new(MyModel::new()));
let mut session = GraphSession::new(graph, lib);
session.fit(&train_x, Some(&train_y))?;
let output = session.forward(&test_x)?;Implementations§
Source§impl GraphSession
impl GraphSession
Sourcepub fn new(graph: Graph, catalog: NodeCatalog) -> Self
pub fn new(graph: Graph, catalog: NodeCatalog) -> Self
A session over graph with an in-memory cache and its own event
bus; the with_* builders swap in shared or persistent components.
Sourcepub fn with_cache(self, cache: Arc<dyn CacheStore>) -> Self
pub fn with_cache(self, cache: Arc<dyn CacheStore>) -> Self
Replace the default in-memory cache, e.g. with a tiered or persistent store shared across sessions.
Sourcepub fn with_event_bus(self, bus: Arc<EventBus>) -> Self
pub fn with_event_bus(self, bus: Arc<EventBus>) -> Self
Replace the session’s own event bus, e.g. with one a tracker is already subscribed to.
Sourcepub fn with_data_store(self, store: Arc<dyn DataStore>) -> Self
pub fn with_data_store(self, store: Arc<dyn DataStore>) -> Self
Attach the data store batched forward passes read rows from.
Sourcepub fn with_transport(self, transport: Arc<dyn Transport>) -> Self
pub fn with_transport(self, transport: Arc<dyn Transport>) -> Self
Attach the transport that carries Remote plan nodes to workers.
Sourcepub fn with_driver(self, driver: EffectDriver) -> Self
pub fn with_driver(self, driver: EffectDriver) -> Self
Attach the effect driver a graph containing steps needs.
The session clones the driver per run and hands it the catalog at
that moment, so filters or steps registered through
Self::catalog_mut after this call still count. Without a driver,
executing a step keeps failing with the executor’s own explanation.
Sourcepub fn compile(&self, mode: CompileMode) -> Result<CompileResult>
pub fn compile(&self, mode: CompileMode) -> Result<CompileResult>
Compile the graph and return diagnostics without executing.
Sourcepub fn run(&mut self, mode: CompileMode) -> Result<HashMap<String, Value>>
pub fn run(&mut self, mode: CompileMode) -> Result<HashMap<String, Value>>
Compile and execute the graph, returning all node outputs.
Emits a RunStarted/RunCompleted (or RunFailed) bracket
around the node events so readers can compute total duration
and group the run.
Sourcepub fn fit(
&mut self,
x: &Value,
y: Option<&Value>,
) -> Result<HashMap<String, Value>>
pub fn fit( &mut self, x: &Value, y: Option<&Value>, ) -> Result<HashMap<String, Value>>
Fit all trainable filters in topological order. Delegates to LocalRunner — same execution path as remote workers.
Emits a RunStarted/RunCompleted (or RunFailed) bracket
tagged with the same run id as the node events inside it.
Sourcepub fn forward_with(
&self,
x: &Value,
strategy: &dyn ForwardStrategy,
) -> Result<Value>
pub fn forward_with( &self, x: &Value, strategy: &dyn ForwardStrategy, ) -> Result<Value>
Forward pass using the given strategy.
Strategies define HOW data flows through the compiled graph:
crate::forward::Standard— full input at once with inference caching (default)crate::forward::Stream— chunked input through StreamExecutorcrate::forward::Batched— rows from DataStore, batch by batch
Sourcepub fn forward(&self, x: &Value) -> Result<Value>
pub fn forward(&self, x: &Value) -> Result<Value>
Standard forward pass (shortcut for forward_with(x, &Standard)).
Sourcepub fn persist_states(&self) -> Result<DataRef>
pub fn persist_states(&self) -> Result<DataRef>
Persist all trained states to the data store.
Sourcepub fn load_states(&mut self, data_ref: &DataRef) -> Result<()>
pub fn load_states(&mut self, data_ref: &DataRef) -> Result<()>
Load previously persisted states from a data store reference.
Sourcepub fn catalog(&self) -> &NodeCatalog
pub fn catalog(&self) -> &NodeCatalog
Access the node catalog.
Sourcepub fn catalog_mut(&mut self) -> &mut NodeCatalog
pub fn catalog_mut(&mut self) -> &mut NodeCatalog
Mutable access to the node catalog (for registering nodes after creation).