Documentation
¶
Overview ¶
pkg/model/format.go
pkg/model/index.go
pkg/model/index_factory.go
pkg/model/pusher.go
pkg/model/weights.go
pkg/model/weights_lock.go
pkg/model/weights_lock_generator.go
pkg/model/weights_pusher.go
Index ¶
- Constants
- Variables
- type BuildBaseOptions
- type BuildOptions
- type BuildRef
- type BundlePusher
- type DockerfileFactory
- type Factory
- type Image
- type ImagePusher
- type ImageSource
- type Index
- type IndexBuilder
- type IndexFactory
- func (f *IndexFactory) BuildIndex(ctx context.Context, modelImg v1.Image, weightsArtifact v1.Image, ...) (v1.ImageIndex, error)
- func (f *IndexFactory) BuildWeightsArtifact(ctx context.Context, lockPath string, filePaths map[string]string) (v1.Image, *WeightsManifest, error)
- func (f *IndexFactory) BuildWeightsArtifactFromManifest(ctx context.Context, manifest *WeightsManifest, filePaths map[string]string) (v1.Image, error)
- type IndexManifest
- type LocalRef
- type ManifestType
- type Model
- type ModelImageFormat
- type Option
- type ParseOption
- type ParsedRef
- type Platform
- type PushOptions
- type Pusher
- type Ref
- type RemoteRef
- type Resolver
- func (r *Resolver) Build(ctx context.Context, src *Source, opts BuildOptions) (*Model, error)
- func (r *Resolver) BuildBase(ctx context.Context, src *Source, opts BuildBaseOptions) (*Model, error)
- func (r *Resolver) Inspect(ctx context.Context, ref *ParsedRef, opts ...Option) (*Model, error)
- func (r *Resolver) InspectByID(ctx context.Context, id string) (*Model, error)
- func (r *Resolver) Pull(ctx context.Context, ref *ParsedRef, opts ...Option) (*Model, error)
- func (r *Resolver) Push(ctx context.Context, m *Model, opts PushOptions) error
- func (r *Resolver) Resolve(ctx context.Context, ref Ref) (*Model, error)
- func (r *Resolver) WithFactory(f Factory) *Resolver
- type Source
- type TagRef
- type WeightFile
- type WeightPushFileResult
- type WeightsArtifactBuilder
- type WeightsLock
- type WeightsLockGenerator
- type WeightsLockGeneratorOptions
- type WeightsManifest
- type WeightsPushOptions
- type WeightsPushProgress
- type WeightsPushResult
- type WeightsPusher
- type WeightsRetryEvent
Constants ¶
const ( AnnotationReferenceType = "vnd.cog.reference.type" AnnotationReferenceDigest = "vnd.cog.reference.digest" )
Annotation keys for weights manifests.
const ( // MediaTypeWeightsManifest is the artifactType for weights manifests. MediaTypeWeightsManifest = "application/vnd.cog.weights.v1" // MediaTypeWeightsLayerGzip is for gzip-compressed weight layers. MediaTypeWeightsLayerGzip = "application/vnd.cog.weights.layer.v1+gzip" // MediaTypeWeightsLayerZstd is for zstd-compressed weight layers (future). MediaTypeWeightsLayerZstd = "application/vnd.cog.weights.layer.v1+zstd" // MediaTypeWeightsLayer is for uncompressed weight layers. MediaTypeWeightsLayer = "application/vnd.cog.weights.layer.v1" )
Media types for weights artifacts.
const ( AnnotationWeightsName = "vnd.cog.weights.name" AnnotationWeightsDest = "vnd.cog.weights.dest" AnnotationWeightsDigestOriginal = "vnd.cog.weights.digest.original" AnnotationWeightsSizeUncompressed = "vnd.cog.weights.size.uncompressed" )
Annotation keys for weight file layers.
const (
// AnnotationValueWeights is the value for AnnotationReferenceType indicating a weights manifest.
AnnotationValueWeights = "weights"
)
Annotation values.
const (
// PlatformUnknown is used for artifacts that are not platform-specific (e.g., weights).
PlatformUnknown = "unknown"
)
Platform values for non-platform-specific artifacts.
const WeightsLockFilename = "weights.lock"
WeightsLockFilename is the default filename for the weights lock file.
Variables ¶
var ( // ErrNotCogModel indicates the image exists but is not a valid Cog model. // This occurs when the image lacks the required run.cog.config label. ErrNotCogModel = errors.New("image is not a Cog model") // ErrNotFound indicates the image was not found in the requested location(s). ErrNotFound = errors.New("image not found") )
Sentinel errors for Resolver operations.
var ( LabelConfig = global.LabelNamespace + "config" LabelVersion = global.LabelNamespace + "version" LabelOpenAPISchema = global.LabelNamespace + "openapi_schema" LabelWeightsManifest = global.LabelNamespace + "r8_weights_manifest" )
Label keys for Cog-specific metadata stored in image labels.
Functions ¶
This section is empty.
Types ¶
type BuildBaseOptions ¶
type BuildBaseOptions struct {
// UseCudaBaseImage controls CUDA base image usage: "auto", "true", or "false".
UseCudaBaseImage string
// UseCogBaseImage controls cog base image usage. nil means auto-detect.
UseCogBaseImage *bool
// ProgressOutput controls build output format: "auto", "plain", or "tty".
ProgressOutput string
// RequiresCog indicates whether the build requires cog to be installed.
RequiresCog bool
}
BuildBaseOptions contains settings for building a base image (dev mode). Base images don't copy /src - the source is mounted as a volume at runtime.
func (BuildBaseOptions) WithDefaults ¶
func (o BuildBaseOptions) WithDefaults() BuildBaseOptions
WithDefaults returns a copy of BuildBaseOptions with defaults applied.
type BuildOptions ¶
type BuildOptions struct {
// ImageName is the output image name (required).
ImageName string
// NoCache disables build cache.
NoCache bool
// SeparateWeights builds weights as a separate layer.
SeparateWeights bool
// Strip removes debug symbols from binaries.
Strip bool
// Precompile precompiles Python bytecode.
Precompile bool
// UseCudaBaseImage controls CUDA base image usage: "auto", "true", or "false".
UseCudaBaseImage string
// UseCogBaseImage controls cog base image usage. nil means auto-detect.
UseCogBaseImage *bool
// Secrets are build-time secrets to pass to the build.
Secrets []string
// ProgressOutput controls build output format: "auto", "plain", or "tty".
ProgressOutput string
// Annotations are extra labels to add to the image.
Annotations map[string]string
// SchemaFile is a custom OpenAPI schema file path.
SchemaFile string
// DockerfileFile is a custom Dockerfile path.
DockerfileFile string
// ImageFormat specifies the desired OCI format for the built image.
// FormatStandalone (default): Traditional single OCI image
// FormatBundle: OCI Image Index with weights artifact (requires weights.lock)
ImageFormat ModelImageFormat
// WeightsLockPath is the path to weights.lock file.
// Only used when ImageFormat == FormatBundle.
// Default: weights.lock in project directory.
WeightsLockPath string
}
BuildOptions contains all settings for building a Cog image. This consolidates the many parameters previously passed to image.Build().
func (BuildOptions) WithDefaults ¶
func (o BuildOptions) WithDefaults(src *Source) BuildOptions
WithDefaults returns a copy of BuildOptions with defaults applied from Source. This fills in sensible defaults for any unset fields.
type BuildRef ¶
type BuildRef struct {
Source *Source
Options BuildOptions
}
BuildRef resolves to a Model by building from source. This wraps a Source and BuildOptions for deferred building.
func FromBuild ¶
func FromBuild(src *Source, opts BuildOptions) *BuildRef
FromBuild creates a BuildRef from source and options. Unlike the other From* functions, this does not validate eagerly - validation happens at build time.
type BundlePusher ¶
type BundlePusher struct {
// contains filtered or unexported fields
}
BundlePusher pushes bundles (OCI Index with image + weights).
func NewBundlePusher ¶
func NewBundlePusher(docker command.Command, reg registry.Client) *BundlePusher
NewBundlePusher creates a new BundlePusher.
func (*BundlePusher) Push ¶
func (p *BundlePusher) Push(ctx context.Context, m *Model, opts PushOptions) error
Push pushes the model as an OCI Index with weights artifact.
type DockerfileFactory ¶
type DockerfileFactory struct {
// contains filtered or unexported fields
}
DockerfileFactory wraps existing Dockerfile-based build.
func (*DockerfileFactory) Build ¶
func (f *DockerfileFactory) Build(ctx context.Context, src *Source, opts BuildOptions) (*Image, error)
Build delegates to the existing image.Build() function.
func (*DockerfileFactory) BuildBase ¶
func (f *DockerfileFactory) BuildBase(ctx context.Context, src *Source, opts BuildBaseOptions) (*Image, error)
BuildBase delegates to the existing image.BuildBase() function.
func (*DockerfileFactory) Name ¶
func (f *DockerfileFactory) Name() string
Name returns the factory name.
type Factory ¶
type Factory interface {
// Build creates a Docker image from source and returns Image metadata.
Build(ctx context.Context, src *Source, opts BuildOptions) (*Image, error)
// BuildBase creates a base image for dev mode (without /src copied).
// The source directory is expected to be mounted as a volume at runtime.
BuildBase(ctx context.Context, src *Source, opts BuildBaseOptions) (*Image, error)
// Name returns the factory name for logging/debugging.
Name() string
}
Factory is the build backend interface. Different implementations handle different build strategies.
func DefaultFactory ¶
DefaultFactory returns a Factory based on environment variables. It checks COG_BUILDER and COGPACK to select the appropriate backend.
TODO: When FrontendFactory is implemented, check COG_BUILDER env var. TODO: When CogpacksFactory is implemented, check COGPACK env var.
type Image ¶
type Image struct {
Reference string // Full image reference
Digest string // Content-addressable digest (sha256:...)
Labels map[string]string // Image labels
Platform *Platform // OS/architecture
Source ImageSource // Where loaded from
}
Image represents an OCI image that may contain a Cog model.
func (*Image) CogVersion ¶
CogVersion returns the Cog version that built this image, or empty string if not set.
func (*Image) Config ¶
Config returns the raw cog.yaml config stored in image labels, or empty string if not set.
func (*Image) IsCogModel ¶
IsCogModel returns true if this image has Cog labels indicating it's a Cog model.
func (*Image) OpenAPISchema ¶
OpenAPISchema returns the OpenAPI schema stored in image labels, or empty string if not set.
func (*Image) ParsedConfig ¶
ParsedConfig returns the parsed cog.yaml config from image labels. Returns nil without error if no config label is present. Returns error if the label contains invalid JSON.
func (*Image) ParsedOpenAPISchema ¶
ParsedOpenAPISchema returns the parsed OpenAPI schema from image labels. Returns nil without error if no schema label is present. Returns error if the label contains invalid JSON.
type ImagePusher ¶
type ImagePusher struct {
// contains filtered or unexported fields
}
ImagePusher pushes standalone images using docker push.
func NewImagePusher ¶
func NewImagePusher(docker command.Command) *ImagePusher
NewImagePusher creates a new ImagePusher.
func (*ImagePusher) Push ¶
func (p *ImagePusher) Push(ctx context.Context, m *Model, opts PushOptions) error
Push pushes the model image to a registry.
type ImageSource ¶
type ImageSource string
ImageSource indicates where an image was loaded from.
const ( ImageSourceLocal ImageSource = "local" // Docker daemon ImageSourceRemote ImageSource = "remote" // Registry ImageSourceBuild ImageSource = "build" // Just built )
type Index ¶
type Index struct {
// Digest is the index digest (sha256:...).
Digest string
// Reference is the full image reference.
Reference string
// MediaType is typically application/vnd.oci.image.index.v1+json.
MediaType string
// Manifests are the child manifests in this index.
Manifests []IndexManifest
}
Index represents an OCI Image Index containing multiple manifests.
type IndexBuilder ¶
type IndexBuilder struct {
// contains filtered or unexported fields
}
IndexBuilder builds an OCI Image Index containing a model image and optional weights artifact.
func NewIndexBuilder ¶
func NewIndexBuilder() *IndexBuilder
NewIndexBuilder creates a new index builder.
func (*IndexBuilder) Build ¶
func (b *IndexBuilder) Build() (v1.ImageIndex, error)
Build creates the OCI Image Index.
func (*IndexBuilder) SetModelImage ¶
func (b *IndexBuilder) SetModelImage(img v1.Image, platform *v1.Platform)
SetModelImage sets the runnable model image.
func (*IndexBuilder) SetWeightsArtifact ¶
func (b *IndexBuilder) SetWeightsArtifact(artifact v1.Image, imageDigest string)
SetWeightsArtifact sets the weights artifact. imageDigest is the digest of the model image, used in the reference annotation.
type IndexFactory ¶
type IndexFactory struct{}
IndexFactory builds OCI Image Indexes with weights artifacts.
func NewIndexFactory ¶
func NewIndexFactory() *IndexFactory
NewIndexFactory creates a new IndexFactory.
func (*IndexFactory) BuildIndex ¶
func (f *IndexFactory) BuildIndex(ctx context.Context, modelImg v1.Image, weightsArtifact v1.Image, platform *Platform) (v1.ImageIndex, error)
BuildIndex creates an OCI Image Index from a model image and weights artifact.
func (*IndexFactory) BuildWeightsArtifact ¶
func (f *IndexFactory) BuildWeightsArtifact(ctx context.Context, lockPath string, filePaths map[string]string) (v1.Image, *WeightsManifest, error)
BuildWeightsArtifact builds an OCI artifact from a weights.lock file. The filePaths map provides name→filepath mappings for locating the actual weight files. Returns the artifact image and the populated WeightsManifest.
func (*IndexFactory) BuildWeightsArtifactFromManifest ¶
func (f *IndexFactory) BuildWeightsArtifactFromManifest(ctx context.Context, manifest *WeightsManifest, filePaths map[string]string) (v1.Image, error)
BuildWeightsArtifactFromManifest builds an OCI artifact from a WeightsManifest. This is similar to BuildWeightsArtifact but takes an already-parsed manifest instead of a lock file path. Useful for push operations where the manifest is already attached to the Model. The filePaths map provides name→filepath mappings for locating the actual weight files.
type IndexManifest ¶
type IndexManifest struct {
// Digest is the manifest digest.
Digest string
// MediaType is the manifest media type.
MediaType string
// Size is the manifest size in bytes.
Size int64
// Platform is the target platform (nil for artifacts).
Platform *Platform
// Annotations are OCI annotations on this manifest.
Annotations map[string]string
// Type is derived from platform/annotations (image or weights).
Type ManifestType
}
IndexManifest represents a single manifest within an index.
type LocalRef ¶
type LocalRef struct {
Parsed *ParsedRef
}
LocalRef resolves an image from the local docker daemon only. It will not fall back to remote registry if the image is not found locally.
type ManifestType ¶
type ManifestType string
ManifestType identifies the type of manifest in an index.
const ( // ManifestTypeImage is a runnable container image. ManifestTypeImage ManifestType = "image" // ManifestTypeWeights is a weights artifact. ManifestTypeWeights ManifestType = "weights" )
type Model ¶
type Model struct {
Image *Image // Underlying OCI image
Config *config.Config // Parsed cog.yaml
Schema *openapi3.T // OpenAPI schema
CogVersion string // Version of cog used to build
// ImageFormat describes the OCI structure.
// Set at build time, determines push strategy.
// FormatStandalone (default): Traditional single OCI image
// FormatBundle: OCI Image Index with image + weights artifact
ImageFormat ModelImageFormat
// Bundle-specific fields (nil for standalone)
Index *Index // OCI Image Index (populated when inspecting bundle)
WeightsManifest *WeightsManifest // Weight file metadata (populated for bundles)
}
Model represents a Cog model extracted from an Image.
func (*Model) IsBundle ¶
IsBundle returns true if this model uses the bundle format (OCI Index with weights).
func (*Model) SchemaJSON ¶
SchemaJSON returns the OpenAPI schema as JSON bytes, or nil if no schema.
type ModelImageFormat ¶
type ModelImageFormat string
ModelImageFormat describes the OCI structure of a model.
const ( // FormatStandalone is a traditional single OCI image. // All code, dependencies, and weights are baked into one image. FormatStandalone ModelImageFormat = "standalone" // FormatBundle is an OCI Image Index containing multiple manifests: // - A runnable image (code, dependencies) // - A weights artifact (model weights, fetched separately) FormatBundle ModelImageFormat = "bundle" )
func ImageFormatFromEnv ¶
func ImageFormatFromEnv() ModelImageFormat
ImageFormatFromEnv returns the image format based on the COG_OCI_INDEX environment variable. Returns FormatBundle if COG_OCI_INDEX=1, otherwise FormatStandalone.
func (ModelImageFormat) IsValid ¶
func (f ModelImageFormat) IsValid() bool
IsValid returns true if the format is a known value.
func (ModelImageFormat) String ¶
func (f ModelImageFormat) String() string
String returns the string representation of the format.
type Option ¶
type Option func(*options)
Option configures how Resolver methods behave.
func LocalOnly ¶
func LocalOnly() Option
LocalOnly loads only from the local docker daemon. Returns an error if the image is not found locally.
func PreferRemote ¶
func PreferRemote() Option
PreferRemote tries remote registry first, falls back to local on not-found.
func RemoteOnly ¶
func RemoteOnly() Option
RemoteOnly loads only from the remote registry. Does not check the local docker daemon.
func WithPlatform ¶
WithPlatform sets the platform for remote registry queries.
type ParseOption ¶
type ParseOption func(*parseOptions)
ParseOption configures how image references are parsed.
func Insecure ¶
func Insecure() ParseOption
Insecure allows parsing references to registries that use HTTP or have invalid/self-signed certificates. Use this for local development registries like localhost:5000.
func WithDefaultRegistry ¶
func WithDefaultRegistry(registry string) ParseOption
WithDefaultRegistry sets the registry to use when the reference doesn't include one. By default, Docker Hub (index.docker.io) is used.
func WithDefaultTag ¶
func WithDefaultTag(tag string) ParseOption
WithDefaultTag sets the tag to use when the reference doesn't include one. By default, "latest" is used.
type ParsedRef ¶
type ParsedRef struct {
// Original is the input string before parsing.
Original string
// Ref is the underlying parsed reference from go-containerregistry.
Ref name.Reference
}
ParsedRef wraps a validated and parsed image reference.
func ParseRef ¶
func ParseRef(ref string, opts ...ParseOption) (*ParsedRef, error)
ParseRef validates and parses an image reference.
func (*ParsedRef) Digest ¶
Digest returns the digest (e.g., "sha256:...") or empty string if this is a tag reference.
func (*ParsedRef) IsReplicate ¶
IsReplicate returns true if the registry is the Replicate registry (r8.im).
func (*ParsedRef) Repository ¶
Repository returns the repository path (e.g., "user/model", "library/nginx").
type PushOptions ¶
type PushOptions struct {
// ProjectDir is the base directory for resolving weight file paths.
//
// Deprecated: Use FilePaths instead.
ProjectDir string
// FilePaths maps weight name identifiers to their file paths.
// Required when Model.ImageFormat == FormatBundle.
// Keys are weight names (e.g., "model-v1"), values are absolute file paths.
FilePaths map[string]string
// Platform specifies the target platform for bundle indexes.
// Default: linux/amd64
Platform *Platform
}
PushOptions configures push behavior.
type Pusher ¶
type Pusher interface {
Push(ctx context.Context, m *Model, opts PushOptions) error
}
Pusher handles pushing a model to a registry.
type Ref ¶
type Ref interface {
// contains filtered or unexported methods
}
Ref represents something that can be resolved to a Model. This interface enables declarative model resolution - callers specify "what they have" (a tag, local image, or source to build) and the Resolver figures out how to produce a Model.
type RemoteRef ¶
type RemoteRef struct {
Parsed *ParsedRef
}
RemoteRef resolves an image from a remote registry only. It will not check the local docker daemon.
func FromRemote ¶
FromRemote parses and validates a reference for remote resolution. Returns an error immediately if the reference is invalid.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver orchestrates building and loading Models.
func NewResolver ¶
NewResolver creates a Resolver with the default factory.
func (*Resolver) BuildBase ¶
func (r *Resolver) BuildBase(ctx context.Context, src *Source, opts BuildBaseOptions) (*Model, error)
BuildBase creates a base image for dev mode (without /src copied). The source directory is expected to be mounted as a volume at runtime. Returns a Model with the built image info and the source config.
func (*Resolver) Inspect ¶
Inspect returns Model metadata for a parsed ref without pulling. By default (PreferLocal), tries local docker daemon first, then remote registry. Only falls back on "not found" errors; real errors (docker down, auth) are surfaced. Returns ErrNotCogModel if the image is not a valid Cog model.
func (*Resolver) InspectByID ¶
InspectByID returns Model metadata from the local docker daemon by image ID. This supports both full IDs (sha256:...) and short IDs (e.g., "9056219a5fb2"). Use this when you have an image ID rather than a tagged reference. Returns ErrNotCogModel if the image is not a valid Cog model.
func (*Resolver) Pull ¶
Pull ensures a Model is locally available for running. It first checks if the image exists locally. If not, it pulls from the registry. Returns ErrNotCogModel if the image is not a valid Cog model. Returns ErrNotFound if the image cannot be found locally or remotely.
func (*Resolver) Push ¶
Push pushes a Model to a container registry. The push strategy is determined by Model.ImageFormat: - FormatStandalone (or empty): Standard docker push - FormatBundle: Push image, build index with weights, push index
func (*Resolver) Resolve ¶
Resolve resolves any Ref to a Model. This is the main entry point for declarative model resolution.
func (*Resolver) WithFactory ¶
WithFactory sets a custom factory and returns the Resolver for chaining.
type Source ¶
type Source struct {
Config *config.Config
ProjectDir string
ConfigFilename string // Base filename like "cog.yaml" or "my-config.yaml"
Warnings []config.DeprecationWarning
}
Source represents a Cog project ready to build. It combines the parsed configuration with the project directory location.
type TagRef ¶
type TagRef struct {
Parsed *ParsedRef
}
TagRef resolves an image by tag or digest reference. It uses the default Load behavior: try local docker daemon first, then fall back to remote registry if not found locally.
type WeightFile ¶
type WeightFile struct {
// Name is the identifier/handle for this weight (e.g., "personaplex-7b-v1", "model-v42.5").
// This is a logical name that maps to deployment blob metadata, not a file path.
Name string `json:"name"`
// Dest is the mount path in the container (e.g., /cache/model.safetensors).
Dest string `json:"dest"`
// DigestOriginal is the SHA256 of the uncompressed file (canonical ID).
DigestOriginal string `json:"digestOriginal"`
// Digest is the SHA256 of the compressed blob (OCI layer ID).
Digest string `json:"digest"`
// Size is the compressed size in bytes.
Size int64 `json:"size"`
// SizeUncompressed is the original size in bytes.
SizeUncompressed int64 `json:"sizeUncompressed"`
// MediaType is the OCI layer media type (e.g., application/vnd.cog.weights.layer.v1+gzip).
MediaType string `json:"mediaType"`
// ContentType is the file's MIME type (e.g., application/octet-stream).
ContentType string `json:"contentType,omitempty"`
}
WeightFile represents a single weight file entry in a weights lockfile or manifest. The Name field is an identifier/handle (like a Docker volume name), not a filename.
type WeightPushFileResult ¶
type WeightPushFileResult struct {
// Name is the weight file identifier.
Name string
// Digest is the layer digest after pushing.
Digest string
// Size is the layer size in bytes.
Size int64
// Err is any error that occurred during push.
Err error
}
WeightPushFileResult contains the result of pushing a single weight file.
type WeightsArtifactBuilder ¶
type WeightsArtifactBuilder struct {
// contains filtered or unexported fields
}
WeightsArtifactBuilder builds OCI artifacts containing model weights.
func NewWeightsArtifactBuilder ¶
func NewWeightsArtifactBuilder() *WeightsArtifactBuilder
NewWeightsArtifactBuilder creates a new builder for weights artifacts.
func (*WeightsArtifactBuilder) AddLayerFromFile ¶
func (b *WeightsArtifactBuilder) AddLayerFromFile(wf WeightFile, filePath string) error
AddLayerFromFile adds a weight file as a layer to the artifact, streaming from disk. The file is read on-demand when the layer is consumed, avoiding loading into memory.
func (*WeightsArtifactBuilder) AddLayersFromLock ¶
func (b *WeightsArtifactBuilder) AddLayersFromLock(ctx context.Context, lock *WeightsLock, filePaths map[string]string) error
AddLayersFromLock adds layers for all files in a WeightsLock. The filePaths map provides name→filepath mappings for locating the actual weight files. Files are stored uncompressed since model weights (safetensors, GGUF, etc.) don't compress well.
type WeightsLock ¶
type WeightsLock struct {
// Version is the lockfile format version.
Version string `json:"version"`
// Created is when the lockfile was generated.
Created time.Time `json:"created"`
// Files are the weight file entries.
Files []WeightFile `json:"files"`
}
WeightsLock represents a weights.lock file that pins weight file metadata. This is a placeholder format that will be replaced by the declarative weights implementation.
func LoadWeightsLock ¶
func LoadWeightsLock(path string) (*WeightsLock, error)
LoadWeightsLock loads a weights.lock file from disk.
func ParseWeightsLock ¶
func ParseWeightsLock(data []byte) (*WeightsLock, error)
ParseWeightsLock parses a weights.lock JSON document.
func (*WeightsLock) Save ¶
func (wl *WeightsLock) Save(path string) error
Save writes the weights.lock to disk.
func (*WeightsLock) ToWeightsManifest ¶
func (wl *WeightsLock) ToWeightsManifest() *WeightsManifest
ToWeightsManifest converts the lockfile to a WeightsManifest.
type WeightsLockGenerator ¶
type WeightsLockGenerator struct {
// contains filtered or unexported fields
}
WeightsLockGenerator generates weights.lock files from weight sources.
func NewWeightsLockGenerator ¶
func NewWeightsLockGenerator(opts WeightsLockGeneratorOptions) *WeightsLockGenerator
NewWeightsLockGenerator creates a new WeightsLockGenerator with the given options.
func (*WeightsLockGenerator) Generate ¶
func (g *WeightsLockGenerator) Generate(ctx context.Context, projectDir string, sources []config.WeightSource) (*WeightsLock, error)
Generate processes weight sources and returns a WeightsLock.
func (*WeightsLockGenerator) GenerateWithFilePaths ¶
func (g *WeightsLockGenerator) GenerateWithFilePaths(ctx context.Context, projectDir string, sources []config.WeightSource) (*WeightsLock, map[string]string, error)
GenerateWithFilePaths processes weight sources and returns a WeightsLock along with a map of weight names to their absolute file paths.
type WeightsLockGeneratorOptions ¶
type WeightsLockGeneratorOptions struct {
// DestPrefix is the prefix for destination paths in the container (e.g., "/weights").
DestPrefix string
}
WeightsLockGeneratorOptions configures the WeightsLockGenerator.
type WeightsManifest ¶
type WeightsManifest struct {
// Digest is the manifest digest (sha256:...).
Digest string
// ArtifactType is the OCI artifact type (application/vnd.cog.weights.v1).
ArtifactType string
// Created is when the manifest was created.
Created time.Time
// Files are the individual weight files.
Files []WeightFile
}
WeightsManifest contains metadata about weight files in a model.
func (*WeightsManifest) FindByDest ¶
func (wm *WeightsManifest) FindByDest(dest string) *WeightFile
FindByDest returns the WeightFile with the given destination path, or nil.
func (*WeightsManifest) TotalSize ¶
func (wm *WeightsManifest) TotalSize() int64
TotalSize returns the sum of compressed sizes of all files.
func (*WeightsManifest) TotalSizeUncompressed ¶
func (wm *WeightsManifest) TotalSizeUncompressed() int64
TotalSizeUncompressed returns the sum of uncompressed sizes of all files.
type WeightsPushOptions ¶
type WeightsPushOptions struct {
// Repo is the registry repository to push to (e.g., "registry.example.com/user/model").
Repo string
// Lock is the weights lock file containing file metadata.
Lock *WeightsLock
// FilePaths maps weight names to their local file paths.
FilePaths map[string]string
// ProgressFn is an optional callback for reporting progress of each file upload.
ProgressFn func(WeightsPushProgress)
// RetryFn is an optional callback for reporting retry attempts.
// Return false from this callback to abort the retry.
RetryFn func(WeightsRetryEvent) bool
// RetryBackoff configures retry behavior. If nil, default backoff is used.
RetryBackoff *remote.Backoff
}
WeightsPushOptions configures the weights push operation.
type WeightsPushProgress ¶
type WeightsPushProgress struct {
// Name identifies which file this progress is for.
Name string
// Complete is the number of bytes uploaded so far.
Complete int64
// Total is the total number of bytes to upload.
Total int64
// Done indicates the upload has finished (check Err for success/failure).
Done bool
// Err is any error that occurred (only set when Done is true).
Err error
}
WeightsPushProgress reports progress for a weight file upload.
type WeightsPushResult ¶
type WeightsPushResult struct {
// Files contains the result for each file pushed.
Files []WeightPushFileResult
// TotalSize is the sum of successfully pushed file sizes.
TotalSize int64
}
WeightsPushResult contains the results of pushing weights.
type WeightsPusher ¶
type WeightsPusher struct {
// contains filtered or unexported fields
}
WeightsPusher handles pushing weight files to a registry.
func NewWeightsPusher ¶
func NewWeightsPusher(registry registry.Client) *WeightsPusher
NewWeightsPusher creates a new WeightsPusher.
func (*WeightsPusher) Push ¶
func (p *WeightsPusher) Push(ctx context.Context, opts WeightsPushOptions) (*WeightsPushResult, error)
Push pushes weight files to the registry concurrently.
type WeightsRetryEvent ¶
type WeightsRetryEvent struct {
// Name identifies which file is being retried.
Name string
// Attempt is the current retry attempt number (1-indexed).
Attempt int
// MaxAttempts is the maximum number of retry attempts.
MaxAttempts int
// Err is the error that caused the retry.
Err error
// NextRetryIn is the duration until the next retry attempt.
NextRetryIn time.Duration
}
WeightsRetryEvent reports a retry attempt for a weight file upload.