Skip to main content

RunContext

Struct RunContext 

Source
pub struct RunContext<'a> {
    pub catalog: &'a NodeCatalog,
    pub cache: &'a dyn CacheStore,
    pub events: &'a Arc<EventBus>,
    pub run_id: &'a str,
    pub graph_info: GraphInfo,
    pub seed: Option<i64>,
    pub driver: Option<EffectDriver>,
}
Expand description

Everything a runner needs besides the plan and the data.

A struct rather than six more parameters, and one of them is the point: graph_info. Both runner methods used to build GraphInfo::for_linear(plan.node_ids()) — chaining the plan’s nodes in flattened order as if every graph were a chain. On a diamond that is simply wrong: GraphSession::forward on a → {b, c} → d answered with d(c(...)), d never seeing b and a never seeing the input.

The caller supplies the real topology now. A caller that genuinely has only a plan can still pass GraphInfo::for_linear, but it has to say so.

Fields§

§catalog: &'a NodeCatalog

Implementations and trained states for every node in the plan.

§cache: &'a dyn CacheStore

Output cache consulted and filled by run_node.

§events: &'a Arc<EventBus>

Bus the run emits its node events on.

§run_id: &'a str

Tags every node event of this run — callers that emit a RunStarted/RunCompleted bracket pass the same id so readers can group a run’s events.

§graph_info: GraphInfo

The real topology for input resolution — the reason this struct exists; see the type docs.

§seed: Option<i64>

The run’s experiment seed, folded into every cache key.

Without it two seeds share a state cache line, so the second one trains on the first one’s recorded state and the sweep measures one seed N times. Only the Python fit path used to salt.

§driver: Option<EffectDriver>

Performs and journals step effects.

Needed only when the plan contains a step. It lives here rather than being built inside the runner because a driver carries the journal — which is what makes a resumed run replay instead of re-calling a model — and only the caller knows where that journal lives.

Implementations§

Source§

impl<'a> RunContext<'a>

Source

pub fn new( catalog: &'a NodeCatalog, cache: &'a dyn CacheStore, events: &'a Arc<EventBus>, run_id: &'a str, graph_info: GraphInfo, ) -> Self

A context over the real topology; use Self::linear only when a plan is genuinely all you have.

Source

pub fn with_seed(self, seed: Option<i64>) -> Self

Fold this run’s seed into the cache keys.

Source

pub fn with_driver(self, driver: EffectDriver) -> Self

Register the effect driver a plan containing steps needs.

The driver should already carry its catalog (crate::effects::EffectDriver::with_catalog) if a step may fan out dynamically — the same rule as crate::executor::Context::with_driver, so the two entry points cannot drift apart on who attaches it.

Source

pub fn linear( catalog: &'a NodeCatalog, cache: &'a dyn CacheStore, events: &'a Arc<EventBus>, run_id: &'a str, plan: &ExecutionPlan, ) -> Self

For a caller that has only a plan: treat it as a chain.

Correct for a linear pipeline and a fabrication for anything else, which is why it is spelled out at the call site rather than being what you get by default.

Auto Trait Implementations§

§

impl<'a> Freeze for RunContext<'a>

§

impl<'a> !RefUnwindSafe for RunContext<'a>

§

impl<'a> Send for RunContext<'a>

§

impl<'a> Sync for RunContext<'a>

§

impl<'a> Unpin for RunContext<'a>

§

impl<'a> UnsafeUnpin for RunContext<'a>

§

impl<'a> !UnwindSafe for RunContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

The receiver as &dyn Any, ready for downcast_ref.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more