machinelearning

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package machinelearning owns FrogML's versioned model layout and publication invariants. Temporary uploads are never published model versions.

Index

Constants

View Source
const (
	ManifestName    = "model-manifest.json"
	TransactionName = ".transaction.json"
	MaxManifestSize = 4 << 20
	MaxFiles        = 10000
	MaxFileSize     = 10 << 30
)

Variables

This section is empty.

Functions

func CheckTransaction

func CheckTransaction(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	id Identity,
	tx string, by string,
) error

CheckTransaction rechecks ownership and expiry on every upload and commit. Knowing the millisecond transaction ID is not an authorization capability.

func File

func File(s string) bool

func Missing

func Missing(err error) bool

func Name

func Name(s string) bool

func Private

func Private(p string) bool

Private identifies staging records and manifests, which must not bypass transaction ownership or the native manifest's per-artifact authorization.

func Publication

func Publication(ctx context.Context) context.Context

Publication is used only inside the native transaction which verifies every file before publishing the manifest and rebuilding the index once.

func Segment

func Segment(s string) bool

func Serves

func Serves(t repo.PackageType) bool

func Transaction

func Transaction(s string) bool

func Verify

func Verify(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	prefix string,
	m Manifest,
) ([]types.Item, error)

Verify checks the exact declared files against immutable stored checksums. It returns ErrNotFound for a version made incomplete by item deletion.

func Version

func Version(s string) bool

Version excludes layout markers: with an optional namespace, category names would make one model's manifest indistinguishable from another model's file.

Types

type Artifact

type Artifact struct {
	Path        string    `json:"artifact_path"`
	Size        int64     `json:"size"`
	Checksums   Checksums `json:"checksums"`
	DownloadURL string    `json:"download_url,omitempty"`
}

type Checksums

type Checksums struct {
	SHA256 string `json:"sha2"`
}

type FileEntry

type FileEntry struct {
	Path     string
	Artifact Artifact
}

type Handler

type Handler struct{ generic.Handler }

func (Handler) Admit

func (Handler) Admit(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	w format.Write,
) (format.Write, error)

func (Handler) Classify

func (Handler) Classify(_ repo.Config, p string) format.Class

func (Handler) Deleted

func (h Handler) Deleted(ctx context.Context, env format.Env, c repo.Config, _ []types.Item) error

func (Handler) Deployed

func (h Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it types.Item) error

func (Handler) GuardTransferSource

func (Handler) GuardTransferSource(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	it types.Item,
) error

func (Handler) Reindex

func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error

Reindex publishes only complete manifest-backed versions. Removing one file withdraws the version; restoring the full set makes it visible again.

func (Handler) Resolve

func (Handler) Resolve(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	d format.Download,
) (string, error)

type Identity

type Identity struct{ Name, Version string }

Identity names a model, optionally within one SDK namespace, and its version.

func ParsePath

func ParsePath(p string) (id Identity, tx, rest string, ok bool)

ParsePath distinguishes committed files from one transaction's private files.

func (Identity) Manifest

func (id Identity) Manifest() string

func (Identity) Prefix

func (id Identity) Prefix() string

func (Identity) Staging

func (id Identity) Staging(tx string) string

type Manifest

type Manifest struct {
	Created      string        `json:"created_date"`
	Artifacts    []Artifact    `json:"model_artifacts"`
	Format       Serialization `json:"model_format"`
	Dependencies []Artifact    `json:"dependency_artifacts,omitempty"`
	Code         *Artifact     `json:"code_artifacts,omitempty"`
	ID           string        `json:"id,omitempty"`
	Version      string        `json:"version,omitempty"`
}

func Decode

func Decode(body io.Reader) (Manifest, error)

func Read

func Read(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	id Identity,
) (Manifest, types.Item, error)

Read opens the bounded manifest, independently of any HTTP route.

func (Manifest) Files

func (m Manifest) Files() []FileEntry

type Serialization

type Serialization struct {
	Framework        string `json:"framework"`
	FrameworkVersion string `json:"framework_version"`
	Format           string `json:"serialization_format"`
	Runtime          string `json:"runtime"`
	RuntimeVersion   string `json:"runtime_version"`
}

Jump to

Keyboard shortcuts

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