oci

package
v2.0.0-beta.12 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 36 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 oci moves snapshots through an OCI registry. A file of a snapshot is one blob whose digest is the SHA-256 the manifest already records, or, above the piece size, consecutive piece blobs (pieces.go). Blobs two snapshots share are stored and transferred once, and a pull checks every blob as it streams in. manifest.json is the artifact's config.

Index

Constants

View Source
const (
	CatalogRepository   = "catalog"
	CatalogArtifactType = "application/vnd.warmctl.catalog.v1"
	CatalogType         = "application/vnd.warmctl.catalog.v1+json"
)

A registry namespace publishes its models in a catalog: the artifact <namespace>/catalog:latest, whose one layer is the JSON list. Each model's repository, <namespace>/<name>, holds its platform index.

View Source
const (
	IndexTag          = "latest"
	IndexArtifactType = "application/vnd.warmctl.snapshot.index.v2"
	// AnnotationPlatform is the GPU count and hardware row: 8xh100-80gb-sxm.
	AnnotationPlatform = "io.warmctl.platform"
	// AnnotationGPU is the GPU model as nvidia-smi names it, AnnotationGPUs
	// how many: enough for a host to rule an entry out without its manifest.
	AnnotationGPU     = "io.warmctl.gpu"
	AnnotationGPUs    = "io.warmctl.gpus"
	AnnotationDriver  = "io.warmctl.driver"
	AnnotationProfile = "io.warmctl.profile"
	AnnotationVLLM    = "io.warmctl.vllm"
	AnnotationSize    = "io.warmctl.size"
)

A model's snapshots for several platforms share one repository, each under its platform tag (8xh100-80gb-sxm-580.95.05). The repository's IndexTag is an OCI image index listing them, so that, as with a multi-arch image, `up NAME` takes the one this host can restore.

View Source
const (
	ArtifactType = "application/vnd.warmctl.snapshot.v2"
	ConfigType   = "application/vnd.warmctl.snapshot.manifest.v2+json"
	PartType     = "application/vnd.warmctl.weights.part"
	FileType     = "application/vnd.warmctl.file"
	// Scheme prefixes a registry reference on the command line.
	Scheme = "oci://"
)

Media types of a warmctl snapshot artifact.

View Source
const (
	PieceType  = "application/vnd.warmctl.file.piece"
	BundleType = "application/vnd.warmctl.file.bundle"
	// AnnotationPieceOf names the file a piece belongs to, and
	// AnnotationPieceOffset where in it the piece starts.
	AnnotationPieceOf     = "io.warmctl.piece.of"
	AnnotationPieceOffset = "io.warmctl.piece.offset"
	// AnnotationBundleOf names a bundle's first file, AnnotationBundleFiles
	// how many consecutive files of manifest.json it holds.
	AnnotationBundleOf    = "io.warmctl.bundle.of"
	AnnotationBundleFiles = "io.warmctl.bundle.files"
	// DefaultPieceSize keeps every layer under the 100 MB request limit of
	// a registry on Cloudflare Workers, so each goes in one request.
	DefaultPieceSize = 64 << 20
)

A snapshot's files map onto layers three ways. A file larger than the piece size travels as consecutive piece layers: pieces transfer in parallel and stay under registries' blob and request limits and CDN caches (Cloudflare caches objects up to 512 MB). A run of consecutive files each under a quarter piece travels as one bundle layer, their bytes back to back: CRIU writes thousands of small images, and a layer each would swell the artifact manifest past registries' 4 MiB limit. Every other file is a layer of its own, whose digest is the file's SHA-256. Pieces are checked against their digests, bundled files against the SHA-256 manifest.json records.

View Source
const DefaultChunkSize = 64 << 20

DefaultChunkSize is the chunk a push falls back to after a registry refused a whole blob: under the smallest Workers request limit, above the 5 MiB minimum part of S3-style multipart stores.

View Source
const DigestsFile = ".push-digests.json"

DigestsFile in a snapshot directory records the digests of its pieces and bundles, so that a repeat push does not read the snapshot to hash them. Each is keyed by what manifest.json records of its bytes, so a file whose SHA-256 changed, or another piece size, misses and is hashed again.

View Source
const DirScheme = "dir:"

DirScheme prefixes a repository kept as an OCI image layout on a file system, usually a shared one: dir:/mnt/shared/warmctl/glm53-flash:latest.

Variables

This section is empty.

Functions

func AddToIndex

func AddToIndex(ctx context.Context, target oras.Target, desc ocispec.Descriptor, m manifest.Manifest,
	tag string) (int, error)

AddToIndex records the snapshot m, pushed as desc under tag, in the repository's index, in place of an entry of the same platform and driver, and returns how many entries the index lists. Two pushes racing on one repository may lose an entry; the last write wins.

func Choose

func Choose(ctx context.Context, target oras.ReadOnlyTarget, ref string, check func(manifest.Manifest) error) (
	string, error)

Choose returns the tag of the snapshot ref stands for: ref itself when it names a snapshot, or, when it names an index, the first entry whose manifest.json check accepts (nil accepts any). Otherwise the error lists every platform and why it does not fit.

func IsRef

func IsRef(s string) bool

IsRef reports an oci:// reference.

func Mirror

func Mirror(ctx context.Context, src oras.ReadOnlyTarget, tag string, dst oras.Target,
	choose func(manifest.Manifest) error, o Options) (int, error)

Mirror copies the snapshot src names under tag, or, when tag is an index, every entry choose accepts (nil: all), into dst: blobs dst lacks stream from src without touching the local disk, then each snapshot's manifest and tag, and dst's index lists them. It returns how many snapshots it copied.

func Open

func Open(ctx context.Context, ref string, o Options) (oras.Target, string, error)

Open returns the repository ref names, a registry (oci://) or an OCI image layout (dir:), and the tag or digest it names, "" for none.

func PlatformTag

func PlatformTag(m manifest.Manifest) string

PlatformTag is the tag a snapshot is pushed under next to the index: its platform and driver, since a snapshot restores only on the same driver.

func Platforms

func Platforms(ctx context.Context, target oras.ReadOnlyTarget) ([]ocispec.Descriptor, error)

Platforms lists the entries of a repository's index, none when it has no index.

func Pull

func Pull(ctx context.Context, target oras.Target, ref, output string, s store.Store,
	o Options) (manifest.Manifest, error)

Pull fetches the snapshot ref names into the store and links it into output, which must not exist. It returns the snapshot's manifest.

func Push

func Push(ctx context.Context, target oras.Target, dir, tag string, o Options) (ocispec.Descriptor, error)

Push uploads the snapshot in dir and tags it.

func PushCatalog

func PushCatalog(ctx context.Context, target oras.Target, c Catalog) (ocispec.Descriptor, error)

PushCatalog publishes c in target, the catalog repository, as IndexTag.

func ReadManifest

func ReadManifest(ctx context.Context, target oras.ReadOnlyTarget, ref string) (manifest.Manifest, error)

ReadManifest reads the manifest.json of the snapshot ref names, without any of its files.

func Repository

func Repository(ref string, o Options) (*remote.Repository, string, error)

Repository opens the repository of an oci:// reference with the Docker credentials of this user, and returns the tag or digest it names.

func Tags

func Tags(ctx context.Context, repo *remote.Repository) ([]string, error)

Tags lists a repository's tags.

Types

type Catalog

type Catalog struct {
	Models []Model `json:"models" yaml:"models"`
}

Catalog is the list of published models.

func FetchCatalog

func FetchCatalog(ctx context.Context, target oras.ReadOnlyTarget) (Catalog, error)

FetchCatalog reads the catalog from target, the catalog repository.

func (Catalog) Find

func (c Catalog) Find(name string) (Model, bool)

Find returns the model called name.

type Model

type Model struct {
	Name        string `json:"name" yaml:"name"`
	Title       string `json:"title" yaml:"title"`
	License     string `json:"license" yaml:"license"`
	Gated       bool   `json:"gated,omitempty" yaml:"gated"`
	Description string `json:"description,omitempty" yaml:"description"`
}

Model is one entry of the catalog.

type Options

type Options struct {
	PlainHTTP   bool
	Concurrency int
	// ChunkSize uploads blobs larger than it in chunks of that size. Zero
	// sends every blob whole, and DefaultChunkSize chunks once a registry
	// refuses a whole blob as too large.
	ChunkSize int64
	// PieceSize splits files larger than it into pieces of that size; zero
	// means DefaultPieceSize.
	PieceSize int64
	// Check, when set, vets the snapshot's manifest after a pull resolves
	// it and before any blob is downloaded: a host that cannot restore it
	// should not fetch hundreds of GiB first.
	Check func(manifest.Manifest) error
	Log   func(format string, args ...any)
}

Options of a transfer.

Jump to

Keyboard shortcuts

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