Skip to main content

ModelService

Struct ModelService 

Source
pub struct ModelService { /* private fields */ }

Implementations§

Source§

impl ModelService

Source

pub async fn pull( &self, name: &str, progress: Option<&ProgressBar>, ) -> Result<PathBuf, Error>

Download a model from the catalog

Source

pub async fn pull_from_repo( &self, repo: &str, filename: &str, name: &str, progress: Option<&ProgressBar>, ) -> Result<PathBuf, Error>

Download a model via mecha10-api (mirrors HuggingFace repo/filename structure)

The private Minio bucket is never contacted directly - this calls GET /api/downloads/model/{repo}/{filename}, which streams models/{repo}/{filename} out of Minio from inside mecha10-api.

Source§

impl ModelService

Source

pub fn registry_model_dir(&self, model_name: &str, version: i32) -> PathBuf

models_dir/registry/<model_name>/<version>/ - a registry model’s namespaced, per-version subdirectory (LAB-1802). Pure path computation (no I/O), so it’s available regardless of the model-download feature - callers that only need to check/derive paths (e.g. node-runner’s preflight existence check) don’t need the download machinery linked in.

Source§

impl ModelService

Source

pub async fn pull_registry_version( &self, base_url: &str, api_key: &str, model_name: &str, version: i32, progress: Option<&ProgressBar>, ) -> Result<PathBuf, Error>

Resolve model_name’s registry Model id via mecha10-api, then download version’s artifact and cache it at registry_model_dir(model_name, version)/model.onnx. Returns the cached path immediately (without a network round-trip) if it’s already present.

Source§

impl ModelService

Source

pub fn new() -> Result<ModelService, Error>

Create a new ModelService with default settings

Source

pub fn with_models_dir(models_dir: PathBuf) -> Result<ModelService, Error>

Create a ModelService with custom models directory. Infallible (always Ok) - kept returning Result for call-site compatibility with when this used to also parse the compiled-in model_catalog.toml, which could fail.

Source

pub async fn list_catalog(&self) -> Result<Vec<ModelCatalogEntry>, Error>

List all models in the public catalog - a live GET /api/models/catalog call every time (see [catalog::fetch_catalog]), no caching, no fallback.

Source

pub async fn get_catalog_entry( &self, name: &str, ) -> Result<Option<ModelCatalogEntry>, Error>

Get catalog entry for a model by name - fetches the live catalog (see Self::list_catalog) and looks it up by name.

Source

pub async fn list_installed(&self) -> Result<Vec<InstalledModel>, Error>

List all installed models, from both the catalog and registry namespaced subtrees (LAB-1802) - this is what makes a registry model (e.g. one auto-registered from a completed training job and then locally fetched via mecha10 model set) show up in mecha10 model list/installed alongside catalog models, instead of only being visible through the separate mecha10 model registry verb.

Source

pub async fn remove(&self, name: &str) -> Result<(), Error>

Remove an installed catalog model. Registry models are versioned (a name alone doesn’t identify a unique artifact - see the module docs), so this only ever removes from the catalog namespace; if name only exists under the registry namespace, this returns a clear error pointing at the versioned directory instead of silently doing nothing or guessing a version to delete (LAB-1802).

Source

pub fn get_model_path(&self, name: &str) -> PathBuf

Get the path to a catalog model’s ONNX file

Note: This method is no longer used by CLI (replaced by node-runner in Phase 2). Kept for potential future use.

Source

pub async fn is_installed(&self, name: &str) -> bool

Check if a catalog model is installed

Note: This method is no longer used by CLI (replaced by node-runner in Phase 2). Kept for potential future use.

Source

pub async fn info( &self, name: &str, version: Option<i32>, ) -> Result<ModelInfo, Error>

Get info about a model (catalog or installed), from either origin (LAB-1808) - a Registry-origin model is just as valid a target here as a Catalog one, since list_installed already merges both namespaced subtrees.

version disambiguates which installed entry to report when a Registry model has more than one version cached locally (a Catalog entry is versionless/always-latest, so version is ignored for it - there is only ever one candidate). When version is None, the highest installed Registry version is reported (Catalog has no versions to pick between).

Source

pub async fn validate(&self, path: &Path) -> Result<bool, Error>

Validate a model file is a valid ONNX file

Auto Trait Implementations§

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
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.

Source§

impl<T> Instrument for T

Source§

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

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

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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