pub struct ModelCatalog { /* private fields */ }Expand description
In-memory model catalog keyed by (measurement, model_name).
§Thread Safety
ModelCatalog is not internally synchronised. The server wraps it
in Arc<RwLock<ModelCatalog>> (see AppState::model_catalog),
which provides correct concurrent access. This is intentional:
embedding a lock would impose overhead on single-threaded forecast
pipelines and prevents read-side parallelism that RwLock provides.
Implementations§
Source§impl ModelCatalog
impl ModelCatalog
Sourcepub fn save_model<M: ModelStore>(
&mut self,
measurement: &str,
name: &str,
model: &M,
model_type: ModelType,
training_range: (i64, i64),
training_points: usize,
mse: f64,
mae: f64,
r_squared: f64,
) -> Result<ModelMetadata, StorageError>
pub fn save_model<M: ModelStore>( &mut self, measurement: &str, name: &str, model: &M, model_type: ModelType, training_range: (i64, i64), training_points: usize, mse: f64, mae: f64, r_squared: f64, ) -> Result<ModelMetadata, StorageError>
Saves a model to the catalog.
If a model with the same (measurement, name) already exists
the version is auto-incremented.
Sourcepub fn load_model<M: ModelStore>(
&self,
measurement: &str,
name: &str,
) -> Result<M, StorageError>
pub fn load_model<M: ModelStore>( &self, measurement: &str, name: &str, ) -> Result<M, StorageError>
Loads a model from the catalog, deserializing it.
Sourcepub fn get_metadata(
&self,
measurement: &str,
name: &str,
) -> Option<&ModelMetadata>
pub fn get_metadata( &self, measurement: &str, name: &str, ) -> Option<&ModelMetadata>
Returns metadata for a stored model (if it exists).
Sourcepub fn list_models(&self, measurement: &str) -> Vec<&ModelMetadata>
pub fn list_models(&self, measurement: &str) -> Vec<&ModelMetadata>
Lists metadata for all models under a given measurement.
Sourcepub fn list_all(&self) -> Vec<&ModelMetadata>
pub fn list_all(&self) -> Vec<&ModelMetadata>
Lists metadata for all models in the catalog.
Sourcepub fn delete_model(&mut self, measurement: &str, name: &str) -> bool
pub fn delete_model(&mut self, measurement: &str, name: &str) -> bool
Deletes a model from the catalog.
Trait Implementations§
Source§impl Debug for ModelCatalog
impl Debug for ModelCatalog
Source§impl Default for ModelCatalog
impl Default for ModelCatalog
Source§fn default() -> ModelCatalog
fn default() -> ModelCatalog
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ModelCatalog
impl RefUnwindSafe for ModelCatalog
impl Send for ModelCatalog
impl Sync for ModelCatalog
impl Unpin for ModelCatalog
impl UnsafeUnpin for ModelCatalog
impl UnwindSafe for ModelCatalog
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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