pub struct TransportContext<'a> { /* private fields */ }Expand description
A StrategyContext over one Transport per worker.
This is the piece that was missing: StrategyExecutor was written and
had nowhere to run, because nothing implemented the context it takes.
It deliberately does not send GetState/SetState over the wire,
even though the worker now answers them: a Fit already returns its
trained states in the plan result, so asking again would be a second
round trip for something already in hand. Gradients are different —
nothing else carries them — so those two do go to the worker.
Implementations§
Source§impl<'a> TransportContext<'a>
impl<'a> TransportContext<'a>
Sourcepub fn new(
transports: Vec<Arc<dyn Transport>>,
plan: &'a ExecutionPlan,
catalog: &'a NodeCatalog,
seed: Option<i64>,
) -> Self
pub fn new( transports: Vec<Arc<dyn Transport>>, plan: &'a ExecutionPlan, catalog: &'a NodeCatalog, seed: Option<i64>, ) -> Self
One transport per worker, in the order the strategy will index them.
Sourcepub fn with_targets(self, identities: Vec<WorkerIdentity>) -> Self
pub fn with_targets(self, identities: Vec<WorkerIdentity>) -> Self
Name the workers, so a partition pinned to an id or a tag can find
one. Without this, worker_for refuses rather than guessing.
Trait Implementations§
Source§impl StrategyContext for TransportContext<'_>
impl StrategyContext for TransportContext<'_>
Source§fn num_workers(&self) -> usize
fn num_workers(&self) -> usize
Number of available workers.
Source§fn execute_on_worker(
&self,
worker_idx: usize,
_plan: &Value,
input: &Value,
y: Option<&Value>,
) -> Result<HashMap<String, Value>>
fn execute_on_worker( &self, worker_idx: usize, _plan: &Value, input: &Value, y: Option<&Value>, ) -> Result<HashMap<String, Value>>
Execute a plan on a specific worker (by index). Returns trained states.
Source§fn get_state(
&self,
worker_idx: usize,
node_ids: &[String],
) -> Result<HashMap<String, Value>>
fn get_state( &self, worker_idx: usize, node_ids: &[String], ) -> Result<HashMap<String, Value>>
Get trained states from a worker.
Source§fn worker_for(&self, target: &RemoteTarget) -> Result<usize>
fn worker_for(&self, target: &RemoteTarget) -> Result<usize>
Which worker answers to
target. Read moreSource§fn execute_partition(
&self,
worker_idx: usize,
node_ids: &[String],
input: &Value,
y: Option<&Value>,
) -> Result<(Value, HashMap<String, Value>)>
fn execute_partition( &self, worker_idx: usize, node_ids: &[String], input: &Value, y: Option<&Value>, ) -> Result<(Value, HashMap<String, Value>)>
Run part of the graph on a worker, returning the activation and
the states it learned. Read more
Source§fn read_back_state(
&self,
worker_idx: usize,
node_ids: &[String],
) -> Result<HashMap<String, Value>>
fn read_back_state( &self, worker_idx: usize, node_ids: &[String], ) -> Result<HashMap<String, Value>>
Read a worker’s state now, over the wire, rather than recalling
what its last fit returned. Read more
Source§fn set_state(
&self,
worker_idx: usize,
states: &HashMap<String, Value>,
) -> Result<()>
fn set_state( &self, worker_idx: usize, states: &HashMap<String, Value>, ) -> Result<()>
Set states on a worker (e.g. after aggregation).
Auto Trait Implementations§
impl<'a> !Freeze for TransportContext<'a>
impl<'a> !RefUnwindSafe for TransportContext<'a>
impl<'a> Send for TransportContext<'a>
impl<'a> Sync for TransportContext<'a>
impl<'a> Unpin for TransportContext<'a>
impl<'a> UnsafeUnpin for TransportContext<'a>
impl<'a> !UnwindSafe for TransportContext<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more