pub struct ModelService { /* private fields */ }Expand description
Model management service
Implementations§
Source§impl ModelService
impl ModelService
Sourcepub async fn pull(
&self,
name: &str,
progress: Option<&ProgressBar>,
) -> Result<PathBuf, Error>
pub async fn pull( &self, name: &str, progress: Option<&ProgressBar>, ) -> Result<PathBuf, Error>
Download a model from the catalog
Sourcepub async fn pull_from_repo(
&self,
repo: &str,
filename: &str,
name: &str,
progress: Option<&ProgressBar>,
) -> Result<PathBuf, Error>
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
impl ModelService
Sourcepub fn registry_model_dir(&self, model_name: &str, version: i32) -> PathBuf
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
impl ModelService
Sourcepub async fn pull_registry_version(
&self,
base_url: &str,
api_key: &str,
model_name: &str,
version: i32,
progress: Option<&ProgressBar>,
) -> Result<PathBuf, Error>
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
impl ModelService
Sourcepub fn new() -> Result<ModelService, Error>
pub fn new() -> Result<ModelService, Error>
Create a new ModelService with default settings
Sourcepub fn with_models_dir(models_dir: PathBuf) -> Result<ModelService, Error>
pub fn with_models_dir(models_dir: PathBuf) -> Result<ModelService, Error>
Create a ModelService with custom models directory
Sourcepub fn list_catalog(&self) -> Result<Vec<ModelCatalogEntry>, Error>
pub fn list_catalog(&self) -> Result<Vec<ModelCatalogEntry>, Error>
List all models in the catalog
Sourcepub fn get_catalog_entry(&self, name: &str) -> Option<&ModelCatalogEntry>
pub fn get_catalog_entry(&self, name: &str) -> Option<&ModelCatalogEntry>
Get catalog entry for a model by name
Sourcepub async fn list_installed(&self) -> Result<Vec<InstalledModel>, Error>
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.
Sourcepub async fn remove(&self, name: &str) -> Result<(), Error>
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).
Sourcepub fn get_model_path(&self, name: &str) -> PathBuf
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.
Sourcepub async fn is_installed(&self, name: &str) -> bool
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.
Sourcepub async fn info(
&self,
name: &str,
version: Option<i32>,
) -> Result<ModelInfo, Error>
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).
Auto Trait Implementations§
impl Freeze for ModelService
impl RefUnwindSafe for ModelService
impl Send for ModelService
impl Sync for ModelService
impl Unpin for ModelService
impl UnsafeUnpin for ModelService
impl UnwindSafe for ModelService
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
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