pub struct ModelIndex {
pub(super) paths: Paths,
}Expand description
Persistent model references and artifact ownership under one storage root. Operations lock the catalog as needed; this handle does not retain artifact leases.
Fields§
§paths: PathsImplementations§
Source§impl ModelIndex
impl ModelIndex
pub(super) fn lock(&self) -> Result<LockedCatalog>
Source§impl ModelIndex
impl ModelIndex
Sourcepub fn add_disk_store(
&self,
name: &str,
path: &Path,
layout: DiskLayout,
) -> Result<DiskStore>
pub fn add_disk_store( &self, name: &str, path: &Path, layout: DiskLayout, ) -> Result<DiskStore>
Register an existing filesystem root without crawling or importing models.
Sourcepub fn disk_stores(&self) -> Result<Vec<DiskStore>>
pub fn disk_stores(&self) -> Result<Vec<DiskStore>>
List store registrations without opening their roots or contacting providers.
Sourcepub fn set_disk_store_enabled(&self, name: &str, enabled: bool) -> Result<()>
pub fn set_disk_store_enabled(&self, name: &str, enabled: bool) -> Result<()>
Enable or disable resolution through a store’s URI without changing its ID.
Sourcepub fn remove_disk_store(&self, name: &str) -> Result<()>
pub fn remove_disk_store(&self, name: &str) -> Result<()>
Forget a store registration without deleting files or registered model entries.
Source§impl ModelIndex
impl ModelIndex
Sourcepub fn remove(&self, reference: &str, source_only: bool) -> Result<Removal>
pub fn remove(&self, reference: &str, source_only: bool) -> Result<Removal>
Remove a model registration, or release only its retained source reference.
Source-only removal first checks the prepared checkpoint. Files remain until
Self::gc collects unreferenced owned artifacts; external files are untouched.
Source§impl ModelIndex
impl ModelIndex
Sourcepub fn pack(
&self,
reference: &str,
request: PackOptions<'_>,
) -> Result<ModelDetails>
pub fn pack( &self, reference: &str, request: PackOptions<'_>, ) -> Result<ModelDetails>
Prepare requested variants and atomically update the model’s artifact reference. Existing usable stores can be reused. Rebuilds leave previously leased stores unchanged. HF imports use a full local snapshot; newly downloaded sources are discarded after success unless retention was requested.
fn prepared_copy( &self, model: &ModelEntry, ) -> Result<Option<(Artifact, ArtifactLease)>>
Sourcefn metadata_repair(
&self,
model: &ModelEntry,
previous: Option<&ArtifactLease>,
) -> Result<Option<ArtifactLease>>
fn metadata_repair( &self, model: &ModelEntry, previous: Option<&ArtifactLease>, ) -> Result<Option<ArtifactLease>>
Hold the source only when a prepared artifact needs missing metadata copied.
Sourcefn available_metadata(
&self,
model: &ModelEntry,
) -> Result<Option<ArtifactLease>>
fn available_metadata( &self, model: &ModelEntry, ) -> Result<Option<ArtifactLease>>
Retain available source metadata without downloading another weight snapshot.
fn acquire_source( &self, model: &ModelEntry, token: Option<&str>, downloaded: &mut Option<Pending>, ) -> Result<ArtifactLease>
fn local_source_lease( &self, model: &ModelEntry, path: &Path, ) -> Result<ArtifactLease>
fn export(&self, pending: &Pending, path: &Path) -> Result<Artifact>
fn discard(&self, id: &str) -> Result<()>
Source§impl ModelIndex
impl ModelIndex
Sourcepub fn select(
&self,
input: &Path,
options: ResolveOptions<'_>,
) -> Result<ModelDetails>
pub fn select( &self, input: &Path, options: ResolveOptions<'_>, ) -> Result<ModelDetails>
Resolve an alias, ID, URI, or explicit path; register unknown sources. Unqualified known HF URIs reuse their pinned entry without contacting HF.
Sourcefn select_disk(
&self,
name: &str,
repo: &str,
revision: Option<&str>,
alias: Option<&str>,
) -> Result<ModelDetails>
fn select_disk( &self, name: &str, repo: &str, revision: Option<&str>, alias: Option<&str>, ) -> Result<ModelDetails>
Locate disk files only after lookup has ruled out an existing indexed identity.
Sourcefn name_existing(
&self,
model: ModelEntry,
name: Option<&str>,
) -> Result<ModelDetails>
fn name_existing( &self, model: ModelEntry, name: Option<&str>, ) -> Result<ModelDetails>
Assign an optional name through the normal collision and ownership checks.
Source§impl ModelIndex
impl ModelIndex
pub(super) fn artifact_root(&self, id: &str) -> PathBuf
pub(super) fn artifact_path(&self, artifact: &Artifact) -> PathBuf
pub(super) fn lease_file(&self, id: &str) -> Result<File>
pub(super) fn lease(&self, artifact: &Artifact) -> Result<ArtifactLease>
Sourcepub fn acquire_prepared(&self, reference: &str) -> Result<ArtifactLease>
pub fn acquire_prepared(&self, reference: &str) -> Result<ArtifactLease>
Lease an existing, published prepared artifact without building or downloading. Fail if the model is unprepared or its artifact path is missing.
pub(super) fn begin(&self, kind: ArtifactKind) -> Result<Pending>
pub(super) fn publish( &self, model: &ModelEntry, pending: Artifact, retained: Option<Artifact>, ) -> Result<()>
Source§impl ModelIndex
impl ModelIndex
Sourcepub fn resolve(&self, reference: &str) -> Result<ModelEntry>
pub fn resolve(&self, reference: &str) -> Result<ModelEntry>
Look up a source reference, alias, or model ID and return its catalog entry. The returned metadata does not keep its artifacts alive.
Sourcepub fn add(
&self,
source: &str,
revision: Option<&str>,
name: Option<&str>,
token: Option<&str>,
) -> Result<ModelDetails>
pub fn add( &self, source: &str, revision: Option<&str>, name: Option<&str>, token: Option<&str>, ) -> Result<ModelDetails>
Register a local checkpoint path or an hf://owner/repo source.
Hub registration pins a commit and reads metadata without downloading the
full weights. revision defaults to main; it and token apply only to HF.
Registration does not transfer file ownership. The same source reuses its ID.
Sourcefn add_local(&self, path: &Path, name: Option<&str>) -> Result<ModelDetails>
fn add_local(&self, path: &Path, name: Option<&str>) -> Result<ModelDetails>
Inspect a local source and adopt existing prepared output without copying it.
fn register( &self, source: Source, description: ModelDescription, name: Option<&str>, prepared: Option<PathBuf>, ) -> Result<String>
fn adopt_prepared(&self, catalog: &mut Catalog, path: &Path) -> Result<String>
Sourcefn require_registered_location(
&self,
catalog: &Catalog,
path: &Path,
) -> Result<()>
fn require_registered_location( &self, catalog: &Catalog, path: &Path, ) -> Result<()>
An exact managed entry reuses its ownership record. Other paths inside the artifact namespace cannot safely be recorded as external locations.
fn require_external_path(&self, canonical_path: &Path) -> Result<()>
Sourcefn artifact_at(
&self,
catalog: &Catalog,
kind: ArtifactKind,
path: &Path,
) -> Option<String>
fn artifact_at( &self, catalog: &Catalog, kind: ArtifactKind, path: &Path, ) -> Option<String>
Registering a managed path adds a reference to its existing ownership record.
Sourcepub fn list(&self) -> Result<Vec<ModelSummary>>
pub fn list(&self) -> Result<Vec<ModelSummary>>
Summarize registered models and inspect their current artifact availability. An absent index returns an empty list without creating it.
Sourcepub fn show(&self, reference: &str) -> Result<ModelDetails>
pub fn show(&self, reference: &str) -> Result<ModelDetails>
Report a model’s source, preparation requirements, and referenced artifacts.
Sourcepub fn description(&self, reference: &str) -> Result<ModelDescription>
pub fn description(&self, reference: &str) -> Result<ModelDescription>
Inspect the referenced prepared artifact, or return registered source metadata. A recorded prepared artifact that is missing or unreadable returns an error.
fn details(&self, catalog: &Catalog, model: &ModelEntry) -> Result<ModelDetails>
Trait Implementations§
Source§impl Clone for ModelIndex
impl Clone for ModelIndex
Source§fn clone(&self) -> ModelIndex
fn clone(&self) -> ModelIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ModelIndex
impl RefUnwindSafe for ModelIndex
impl Send for ModelIndex
impl Sync for ModelIndex
impl Unpin for ModelIndex
impl UnsafeUnpin for ModelIndex
impl UnwindSafe for ModelIndex
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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