modelops

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modelops is the daemon's on-demand model operations service: catalog browsing, operator-triggered downloads (with cancel), and runtime load/unload/default switching. It is the write-half the local API lacked — before it, models moved only at daemon startup or via the coordinator's ModelAssignment stub.

Index

Constants

This section is empty.

Variables

View Source
var ErrDownloadRunning = errors.New("modelops: download already running")

ErrDownloadRunning is returned when a download for the id is in flight.

View Source
var ErrUnknownModel = errors.New("modelops: model not in catalog")

ErrUnknownModel is returned when an id is in neither the catalog nor the local cache.

Functions

This section is empty.

Types

type Loader

type Loader interface {
	Load(ctx context.Context, m rt.ModelSpec, res rt.ResourceBudget) (rt.Instance, error)
}

Loader loads a model artifact into a serving runtime instance (*llamacpp.Adapter in production; fakes in tests).

type Service

type Service struct {
	Mgr    *models.Manager
	Eng    *engine.Engine
	Loader Loader
	Budget rt.ResourceBudget
	Log    *slog.Logger

	// Catalog sources, mirroring config (path wins).
	ManifestPath string
	ManifestURL  string

	// OnLoaded is called after a model becomes servable (used to stamp the
	// runtime build id into the capability profile). May be nil.
	OnLoaded func(inst rt.Instance)

	// Events receives models_changed on download-complete, load, unload and
	// default switches. May be nil.
	Events *events.Hub
	// contains filtered or unexported fields
}

Service wires catalog + cache + runtime together. Nil Service (mock runtime) means the local API reports these operations unsupported.

func (*Service) CancelDownload

func (s *Service) CancelDownload(id string) bool

CancelDownload aborts an in-flight download. The .partial file is kept so a later attempt resumes.

func (*Service) Catalog

func (s *Service) Catalog(ctx context.Context, refresh bool) (*models.Catalog, error)

Catalog returns the model catalog, cached for catalogTTL. refresh forces a refetch.

func (*Service) Downloading

func (s *Service) Downloading(id string) bool

Downloading reports whether a download for id is in flight.

func (*Service) Load

func (s *Service) Load(ctx context.Context, id string) error

Load makes a model servable: cache hit or download, then runtime load and engine registration. Synchronous — llama-server startup takes seconds and callers want the outcome. No-op if already loaded.

func (*Service) LoadInstance

func (s *Service) LoadInstance(ctx context.Context, id string) (rt.Instance, error)

LoadInstance is Load returning the runtime instance (startup needs it).

func (*Service) LoadInstanceOrigin

func (s *Service) LoadInstanceOrigin(ctx context.Context, id, origin string) (rt.Instance, error)

LoadInstanceOrigin is LoadInstance with ownership of a fresh download (models.OriginMesh for coordinator placements: the fetch may then only evict other mesh-placed models to make room).

func (*Service) SetDefault

func (s *Service) SetDefault(id string) error

SetDefault switches the model served when a request names none.

func (*Service) StartDownload

func (s *Service) StartDownload(ctx context.Context, id string) (bool, error)

StartDownload begins fetching a catalog model in the background. It returns (false, nil) if the model is already cached and ready, and ErrDownloadRunning if a download is already in flight.

func (*Service) Unload

func (s *Service) Unload(ctx context.Context, id string) error

Unload removes a model from serving (the artifact stays cached).

Jump to

Keyboard shortcuts

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