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 ¶
- Variables
- type Loader
- type Service
- func (s *Service) CancelDownload(id string) bool
- func (s *Service) Catalog(ctx context.Context, refresh bool) (*models.Catalog, error)
- func (s *Service) Downloading(id string) bool
- func (s *Service) Load(ctx context.Context, id string) error
- func (s *Service) LoadInstance(ctx context.Context, id string) (rt.Instance, error)
- func (s *Service) LoadInstanceOrigin(ctx context.Context, id, origin string) (rt.Instance, error)
- func (s *Service) SetDefault(id string) error
- func (s *Service) StartDownload(ctx context.Context, id string) (bool, error)
- func (s *Service) Unload(ctx context.Context, id string) error
Constants ¶
This section is empty.
Variables ¶
var ErrDownloadRunning = errors.New("modelops: download already running")
ErrDownloadRunning is returned when a download for the id is in flight.
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 ¶
CancelDownload aborts an in-flight download. The .partial file is kept so a later attempt resumes.
func (*Service) Catalog ¶
Catalog returns the model catalog, cached for catalogTTL. refresh forces a refetch.
func (*Service) Downloading ¶
Downloading reports whether a download for id is in flight.
func (*Service) Load ¶
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 ¶
LoadInstance is Load returning the runtime instance (startup needs it).
func (*Service) LoadInstanceOrigin ¶
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 ¶
SetDefault switches the model served when a request names none.
func (*Service) StartDownload ¶
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.