backend

package
v0.0.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Login logs into a registry.
	Login(ctx context.Context, registry, username, password string, opts ...Option) error

	// Logout logs out from a registry.
	Logout(ctx context.Context, registry string) error

	// Build builds the user materials into the OCI image which follows the Model Spec.
	Build(ctx context.Context, modelfilePath, workDir, target string) error

	// Pull pulls an artifact from a registry.
	Pull(ctx context.Context, target string, opts ...Option) error

	// Push pushes the image to the registry.
	Push(ctx context.Context, target string, opts ...Option) error

	// List lists all the model artifacts.
	List(ctx context.Context) ([]*ModelArtifact, error)

	// Remove deletes the model artifact.
	Remove(ctx context.Context, target string) (string, error)

	// Prune prunes the unused blobs and clean up the storage.
	Prune(ctx context.Context, dryRun, removeUntagged bool) error

	// Inspect inspects the model artifact.
	Inspect(ctx context.Context, target string) (*InspectedModelArtifact, error)

	// Extract extracts the model artifact.
	Extract(ctx context.Context, target string, output string) error
}

Backend is the interface to represent the backend.

func New

func New(storageDir string) (Backend, error)

New creates a new backend.

type InspectedModelArtifact

type InspectedModelArtifact struct {
	// ID is the image id of the model artifact.
	ID string `json:"Id"`
	// Digest is the digest of the model artifact.
	Digest string `json:"Digest"`
	// Architecture is the architecture of the model.
	Architecture string `json:"Architecture"`
	// CreatedAt is the creation time of the model artifact.
	CreatedAt string `json:"CreatedAt"`
	// Family is the family of the model.
	Family string `json:"Family"`
	// Format is the format of the model.
	Format string `json:"Format"`
	// Name is the name of the model.
	Name string `json:"Name"`
	// ParamSize is the param size of the model.
	ParamSize string `json:"ParamSize"`
	// Precision is the precision of the model.
	Precision string `json:"Precision"`
	// Quantization is the quantization of the model.
	Quantization string `json:"Quantization"`
	// Layers is the layers of the model artifact.
	Layers []InspectedModelArtifactLayer `json:"Layers"`
}

InspectedModelArtifact is the data structure for model artifact that has been inspected.

type InspectedModelArtifactLayer

type InspectedModelArtifactLayer struct {
	// Digest is the digest of the model artifact layer.
	Digest string `json:"Digest"`
	// Size is the size of the model artifact layer.
	Size int64 `json:"Size"`
	// Filepath is the filepath of the model artifact layer.
	Filepath string `json:"Filepath"`
}

InspectedModelArtifactLayer is the data structure for model artifact layer that has been inspected.

type ModelArtifact

type ModelArtifact struct {
	// Repository is the repository of the model artifact.
	Repository string
	// Tag is the tag of the model artifact.
	Tag string
	// Digest is the digest of the model artifact.
	Digest string
	// Size is the size of the model artifact.
	Size int64
	// CreatedAt is the creation time of the model artifact.
	CreatedAt time.Time
}

ModelArtifact is the data model to represent the model artifact.

type Option

type Option func(*Options)

func WithConcurrency

func WithConcurrency(concurrency int) Option

WithConcurrency sets the concurrency option.

func WithInsecure

func WithInsecure(insecure bool) Option

WithInsecure sets the insecure option.

func WithOutput

func WithOutput(output string) Option

WithOutput sets the output option.

func WithPlainHTTP

func WithPlainHTTP(plainHTTP bool) Option

WithPlainHTTP sets the plain HTTP option.

func WithProxy

func WithProxy(proxy string) Option

WithProxy sets the proxy option.

type Options

type Options struct {
	// contains filtered or unexported fields
}

type ProgressBar

type ProgressBar struct {
	// contains filtered or unexported fields
}

ProgressBar is a progress bar.

func NewProgressBar

func NewProgressBar() *ProgressBar

NewProgressBar creates a new progress bar.

func (*ProgressBar) Abort

func (p *ProgressBar) Abort(desc ocispec.Descriptor)

Abort aborts the progress bar by the given desc.

func (*ProgressBar) Add

func (p *ProgressBar) Add(prompt string, desc ocispec.Descriptor, reader io.Reader) io.Reader

Add adds a new progress bar.

func (*ProgressBar) PrintMessage

func (p *ProgressBar) PrintMessage(prompt string, desc ocispec.Descriptor, message string)

PrintMessage adds a new progress bar for printing the message. background: before the all progress bar finished, any stdout print such as fmt.Println will effect the rendering of progress bar, so here create a bar to print message. issue: https://github.com/vbauerster/mpb/issues/118

func (*ProgressBar) Wait

func (p *ProgressBar) Wait()

Wait waits for the progress bar to finish.

type Referencer

type Referencer interface {
	// Repository returns the repository of the reference.
	Repository() string
	// Tag returns the tag of the reference.
	Tag() string
	// Digest returns the digest of the reference.
	Digest() string
}

Referencer is the interface for the reference.

func ParseReference

func ParseReference(ref string) (Referencer, error)

ParseReference parses the reference.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳