store

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: Apache-2.0, Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CurrentVersion is the current version of the store layout
	CurrentVersion = "1.0.0"
)

Variables

View Source
var ErrModelNotFound = errors.New("model not found")

Functions

This section is empty.

Types

type Index

type Index struct {
	Models []IndexEntry `json:"models"`
}

Index represents the index of all models in the store

func (Index) Add

func (i Index) Add(entry IndexEntry) Index

func (Index) Find

func (i Index) Find(reference string) (IndexEntry, int, bool)

func (Index) Remove

func (i Index) Remove(reference string) Index

func (Index) Tag

func (i Index) Tag(reference string, tag string) (Index, error)

func (Index) UnTag

func (i Index) UnTag(tag string) (name.Tag, Index, error)

type IndexEntry

type IndexEntry struct {
	// ID is the globally unique model identifier.
	ID string `json:"id"`
	// Tags are the list of tags associated with the model.
	Tags []string `json:"tags"`
	// Files are the files associated with the model.
	Files []string `json:"files"`
}

IndexEntry represents a model with its metadata and tags

func (IndexEntry) HasTag

func (e IndexEntry) HasTag(tag string) bool

func (IndexEntry) MatchesReference

func (e IndexEntry) MatchesReference(reference string) bool

func (IndexEntry) Tag

func (e IndexEntry) Tag(tag name.Tag) IndexEntry

func (IndexEntry) UnTag

func (e IndexEntry) UnTag(tag name.Tag) IndexEntry

type Layout

type Layout struct {
	Version string `json:"version"`
}

Layout represents the layout information of the store

type LocalStore

type LocalStore struct {
	// contains filtered or unexported fields
}

LocalStore implements the Store interface for local storage

func New

func New(opts Options) (*LocalStore, error)

New creates a new LocalStore

func (*LocalStore) AddTags

func (s *LocalStore) AddTags(ref string, newTags []string) error

AddTags adds tags to an existing model

func (*LocalStore) BundleForModel

func (s *LocalStore) BundleForModel(ref string) (types.ModelBundle, error)

BundleForModel returns a runtime bundle for the given model

func (*LocalStore) CleanupStaleIncompleteFiles added in v1.0.4

func (s *LocalStore) CleanupStaleIncompleteFiles(maxAge time.Duration) error

CleanupStaleIncompleteFiles removes incomplete download files that haven't been modified for more than the specified duration. This prevents disk space leaks from abandoned downloads.

func (*LocalStore) Delete

func (s *LocalStore) Delete(ref string) (string, []string, error)

Delete deletes a model by reference

func (*LocalStore) GetIncompleteSize added in v1.0.4

func (s *LocalStore) GetIncompleteSize(hash v1.Hash) (int64, error)

GetIncompleteSize returns the size of an incomplete blob if it exists, or 0 if it doesn't.

func (*LocalStore) List

func (s *LocalStore) List() ([]IndexEntry, error)

List lists all models in the store

func (*LocalStore) Read

func (s *LocalStore) Read(reference string) (*Model, error)

Read reads a model from the store by reference (either tag or ID)

func (*LocalStore) RemoveTags

func (s *LocalStore) RemoveTags(tags []string) ([]string, error)

RemoveTags removes tags from models

func (*LocalStore) Reset

func (s *LocalStore) Reset() error

Reset clears all contents of the store directory and reinitializes the store. It removes all files and subdirectories within the store's root path, but preserves the root directory itself. This allows the method to work correctly when the store directory is a mounted volume (e.g., in Docker Engine).

func (*LocalStore) RootPath

func (s *LocalStore) RootPath() string

RootPath returns the root path of the store

func (*LocalStore) Version

func (s *LocalStore) Version() string

Version returns the store version

func (*LocalStore) Write

func (s *LocalStore) Write(mdl v1.Image, tags []string, w io.Writer) (err error)

Write writes a model to the store

func (*LocalStore) WriteBlob

func (s *LocalStore) WriteBlob(diffID v1.Hash, r io.Reader) error

WriteBlob writes the blob to the store, reporting progress to the given channel. If the blob is already in the store, it is a no-op and the blob is not consumed from the reader. If an incomplete download exists, it will be resumed by appending to the existing file.

func (*LocalStore) WriteLightweight

func (s *LocalStore) WriteLightweight(mdl v1.Image, tags []string) (err error)

WriteLightweight writes only the manifest and config for a model, assuming layers already exist in the store. This is used for config-only modifications where the layer data hasn't changed.

func (*LocalStore) WriteManifest

func (s *LocalStore) WriteManifest(hash v1.Hash, raw []byte) error

WriteManifest writes the model's manifest to the store

type Model

type Model struct {
	// contains filtered or unexported fields
}

func (*Model) ChatTemplatePath

func (m *Model) ChatTemplatePath() (string, error)

func (*Model) Config

func (m *Model) Config() (mdtypes.Config, error)

func (*Model) ConfigArchivePath

func (m *Model) ConfigArchivePath() (string, error)

func (*Model) ConfigFile

func (m *Model) ConfigFile() (*v1.ConfigFile, error)

func (*Model) ConfigName

func (m *Model) ConfigName() (v1.Hash, error)

func (*Model) Descriptor

func (m *Model) Descriptor() (mdtypes.Descriptor, error)

func (*Model) Digest

func (m *Model) Digest() (v1.Hash, error)

func (*Model) GGUFPaths

func (m *Model) GGUFPaths() ([]string, error)

func (*Model) ID

func (m *Model) ID() (string, error)

func (*Model) LayerByDiffID

func (m *Model) LayerByDiffID(hash v1.Hash) (v1.Layer, error)

func (*Model) LayerByDigest

func (m *Model) LayerByDigest(hash v1.Hash) (v1.Layer, error)

func (*Model) Layers

func (m *Model) Layers() ([]v1.Layer, error)

func (*Model) MMPROJPath

func (m *Model) MMPROJPath() (string, error)

func (*Model) Manifest

func (m *Model) Manifest() (*v1.Manifest, error)

func (*Model) MediaType

func (m *Model) MediaType() (types.MediaType, error)

func (*Model) RawConfigFile

func (m *Model) RawConfigFile() ([]byte, error)

func (*Model) RawManifest

func (m *Model) RawManifest() ([]byte, error)

func (*Model) SafetensorsPaths

func (m *Model) SafetensorsPaths() ([]string, error)

func (*Model) Size

func (m *Model) Size() (int64, error)

func (*Model) Tags

func (m *Model) Tags() []string

type Options

type Options struct {
	RootPath string
}

Options represents options for creating a store

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL