Skip to main content

ModelIndex

Struct ModelIndex 

Source
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: Paths

Implementations§

Source§

impl ModelIndex

Source

pub(super) fn lock(&self) -> Result<LockedCatalog>

Source§

impl ModelIndex

Source

pub fn add_disk_store( &self, name: &str, path: &Path, layout: DiskLayout, ) -> Result<DiskStore>

Register an existing filesystem root without crawling or importing models.

Source

pub fn disk_stores(&self) -> Result<Vec<DiskStore>>

List store registrations without opening their roots or contacting providers.

Source

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.

Source

pub fn remove_disk_store(&self, name: &str) -> Result<()>

Forget a store registration without deleting files or registered model entries.

Source§

impl ModelIndex

Source

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

pub fn gc(&self, dry_run: bool) -> Result<GcReport>

Collect unreferenced catalog artifacts that have no active lease. Owned directories are deleted; external records are removed without deleting their files. A dry run reports candidates without removing either.

Source§

impl ModelIndex

Source

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.

Source

fn prepared_copy( &self, model: &ModelEntry, ) -> Result<Option<(Artifact, ArtifactLease)>>

Source

fn metadata_repair( &self, model: &ModelEntry, previous: Option<&ArtifactLease>, ) -> Result<Option<ArtifactLease>>

Hold the source only when a prepared artifact needs missing metadata copied.

Source

fn available_metadata( &self, model: &ModelEntry, ) -> Result<Option<ArtifactLease>>

Retain available source metadata without downloading another weight snapshot.

Source

fn acquire_source( &self, model: &ModelEntry, token: Option<&str>, downloaded: &mut Option<Pending>, ) -> Result<ArtifactLease>

Source

fn local_source_lease( &self, model: &ModelEntry, path: &Path, ) -> Result<ArtifactLease>

Source

fn export(&self, pending: &Pending, path: &Path) -> Result<Artifact>

Source

fn discard(&self, id: &str) -> Result<()>

Source§

impl ModelIndex

Source

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.

Source

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.

Source

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

Source

pub(super) fn artifact_root(&self, id: &str) -> PathBuf

Source

pub(super) fn artifact_path(&self, artifact: &Artifact) -> PathBuf

Source

pub(super) fn lease_file(&self, id: &str) -> Result<File>

Source

pub(super) fn lease(&self, artifact: &Artifact) -> Result<ArtifactLease>

Source

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.

Source

pub(super) fn begin(&self, kind: ArtifactKind) -> Result<Pending>

Source

pub(super) fn publish( &self, model: &ModelEntry, pending: Artifact, retained: Option<Artifact>, ) -> Result<()>

Source§

impl ModelIndex

Source

pub fn new(paths: Paths) -> Self

Select the index location without opening or creating it.

Source

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.

Source

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.

Source

fn add_local(&self, path: &Path, name: Option<&str>) -> Result<ModelDetails>

Inspect a local source and adopt existing prepared output without copying it.

Source

fn register( &self, source: Source, description: ModelDescription, name: Option<&str>, prepared: Option<PathBuf>, ) -> Result<String>

Source

fn adopt_prepared(&self, catalog: &mut Catalog, path: &Path) -> Result<String>

Source

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.

Source

fn require_external_path(&self, canonical_path: &Path) -> Result<()>

Source

fn artifact_at( &self, catalog: &Catalog, kind: ArtifactKind, path: &Path, ) -> Option<String>

Registering a managed path adds a reference to its existing ownership record.

Source

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.

Source

pub fn show(&self, reference: &str) -> Result<ModelDetails>

Report a model’s source, preparation requirements, and referenced artifacts.

Source

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.

Source

fn details(&self, catalog: &Catalog, model: &ModelEntry) -> Result<ModelDetails>

Trait Implementations§

Source§

impl Clone for ModelIndex

Source§

fn clone(&self) -> ModelIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> AutoreleaseSafe for T
where T: ?Sized,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> DropFlavorWrapper<T> for T

§

type Flavor = MayDrop

The DropFlavor that [wrap]s T into Self
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

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

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

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
§

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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