pub struct ModelHost { /* private fields */ }Expand description
Cheap to clone; every clone is the same host.
Implementations§
Source§impl ModelHost
impl ModelHost
pub fn new( catalog: Arc<Mutex<Catalog>>, runtime: Arc<dyn ModelRuntime>, probe: Arc<dyn MemoryProbe + Send + Sync>, residency: Residency, ) -> Self
Sourcepub fn status(&self, id: &str) -> Result<ModelStatus, HostError>
pub fn status(&self, id: &str) -> Result<ModelStatus, HostError>
Status of one catalogue model.
Sourcepub fn statuses(&self) -> Vec<ModelStatus>
pub fn statuses(&self) -> Vec<ModelStatus>
Status of every catalogue model, in catalogue order.
Sourcepub fn subscribe(&self) -> Receiver<ModelStatus>
pub fn subscribe(&self) -> Receiver<ModelStatus>
Receive every state transition from now on.
Sourcepub fn loaded_gib(&self) -> f32
pub fn loaded_gib(&self) -> f32
Sum of the estimates of models holding (or about to hold) memory.
Sourcepub fn load(&self, id: &str) -> Result<ModelStatus, HostError>
pub fn load(&self, id: &str) -> Result<ModelStatus, HostError>
Load id and mark it resident. Answers the state after the
request: loading, or loaded when it already was.
Sourcepub fn unload(&self, id: &str) -> Result<ModelStatus, HostError>
pub fn unload(&self, id: &str) -> Result<ModelStatus, HostError>
Unload id and clear its residency.
Sourcepub fn restore_residents(&self)
pub fn restore_residents(&self)
Load every resident model, in catalogue order. Failures are logged; a refused or failed model stays resident for next time.
Sourcepub fn with_lane<R>(
&self,
id: &str,
f: impl FnOnce(&dyn LoadedModel, &Lane) -> R,
) -> Result<R, HostError>
pub fn with_lane<R>( &self, id: &str, f: impl FnOnce(&dyn LoadedModel, &Lane) -> R, ) -> Result<R, HostError>
Serve one request on id’s lane. Blocks while the lane is busy.
Sourcepub fn try_with_lane<R>(
&self,
id: &str,
f: impl FnOnce(&dyn LoadedModel, &Lane) -> R,
) -> Result<R, HostError>
pub fn try_with_lane<R>( &self, id: &str, f: impl FnOnce(&dyn LoadedModel, &Lane) -> R, ) -> Result<R, HostError>
Like Self::with_lane but refuses (LaneBusy) instead of waiting,
for long requests such as a stream that would otherwise queue.
Sourcepub fn can_load(&self, model: &CatalogModel) -> bool
pub fn can_load(&self, model: &CatalogModel) -> bool
Whether model can be loaded (its engine has an in-process loader).
Sourcepub fn wait_for(
&self,
id: &str,
pred: impl Fn(&ModelState) -> bool,
timeout: Duration,
) -> Option<ModelStatus>
pub fn wait_for( &self, id: &str, pred: impl Fn(&ModelState) -> bool, timeout: Duration, ) -> Option<ModelStatus>
Block until id’s state satisfies pred, or timeout passes.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ModelHost
impl !UnwindSafe for ModelHost
impl Freeze for ModelHost
impl Send for ModelHost
impl Sync for ModelHost
impl Unpin for ModelHost
impl UnsafeUnpin for ModelHost
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more