types

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyInUse   = errors.New("already in use")
	ErrInvalidInput   = errors.New("invalid input")
	ErrInternal       = errors.New("internal error")
	ErrBadRequest     = errors.New("bad request")
	ErrNotFound       = errors.New("not found")
	ErrNotInitialized = errors.New("not initialized")
)

Functions

func ArtifactIDMap

func ArtifactIDMap(artifacts []Artifact) map[string]Artifact

func ArtifactIDs

func ArtifactIDs(artifacts []Artifact) []string

func BestRuns added in v0.1.3

func BestRuns(runs []*BenchRun, metrics ...BenchMetric) map[string]*BenchRun

BestRuns returns the best performing bechmark run for each metric provided.

func IsValidContentType

func IsValidContentType(contentType string) bool

func NewAPIKey added in v0.1.3

func NewAPIKey(length int) (string, error)

NewAPIKey generates a new API key.

func NewAlreadyInUseErr

func NewAlreadyInUseErr(s string) error

func NewBadRequest

func NewBadRequest(s string) error

func NewInternalErr

func NewInternalErr(s string) error

func NewInvalidInputErr

func NewInvalidInputErr(s string) error

func NewNotFoundErr

func NewNotFoundErr(s string) error

func NormalizeID

func NormalizeID(s string) string

func ParseVal

func ParseVal(s string) any

func SanitizeName added in v0.1.3

func SanitizeName(name string) string

SanitizeName sanatizes a name by removing any whitespace and converting the string to lower case.

func SanitizeNames added in v0.1.3

func SanitizeNames(names []string) []string

SanitizeNames sanitizes a list of names in place.

func UniqueMetrics

func UniqueMetrics(runs []*Run) []string

UniqueMetrics returns all distinct/unique metric names ids from a slice of runs.

Types

type Artifact

type Artifact interface {
	Name() string
	Content() []byte
	ContentType() ContentType
}

func NewArtifact

func NewArtifact(name string, contentType string, content []byte) (Artifact, error)

type Bench added in v0.1.3

type Bench struct {
	ID             string        `json:"id"             validate:"required"`
	Name           string        `json:"name"           validate:"required"`
	Paused         bool          `json:"paused"`
	EagerStart     bool          `json:"eagerStart"`
	AutoTag        bool          `json:"autoTag"`
	Tag            string        `json:"tag"            validate:"required"`
	DecisionMetric string        `json:"decisionMetric"`
	Registries     []string      `json:"registries"     validate:"required"`
	Metrics        []BenchMetric `json:"metrics"        validate:"required"`
	DatasetName    string        `json:"datasetName"    validate:"required"`
	DatasetURL     string        `json:"datasetUrl"     validate:"required,url"`
	FromS3         bool          `json:"fromS3"`
	Timestamp      time.Time     `json:"timestamp"      validate:"required"`
}

Bench represents a benchmark.

func (*Bench) BenchMetrics added in v0.1.3

func (b *Bench) BenchMetrics() []string

BenchMetrics returns the names of metrics tracked.

func (*Bench) GenerateID added in v0.1.3

func (b *Bench) GenerateID()

GenerateID generates a new ID.

func (*Bench) Sanitize added in v0.1.3

func (b *Bench) Sanitize()

Sanitize validates and cleans benchmark fields.

func (*Bench) Validate added in v0.1.3

func (b *Bench) Validate() error

Validate validates Bench fields.

type BenchEvent added in v0.1.3

type BenchEvent struct {
	BenchID     string
	BenchName   string
	Registry    string
	Version     int64
	DockerImage string
	ModelURL    string
	DatasetName string
	DatasetURL  string
	FromS3      bool
	AutoTag     bool
	Tag         string
}

BenchEvent represents a benchmarking event.

type BenchMetric added in v0.1.3

type BenchMetric struct {
	Name     string `json:"name"`
	DescSort bool   `json:"descSort"`
}

BenchMetric represents a benchmark metric.

func NewBenchMetric added in v0.1.3

func NewBenchMetric(name string, descSort bool) BenchMetric

NewBenchMetric creates a new bench metric and sanitizes its name.

type BenchRun added in v0.1.3

type BenchRun struct {
	Registry  string
	Version   int64
	Metrics   map[string]float32
	Timestamp time.Time
}

BenchRun represents a benchmark run on a registry and version.

func (*BenchRun) SanitizedMetrics added in v0.1.3

func (br *BenchRun) SanitizedMetrics() map[string]float32

SanitizedMetrics returns a metrics with sanitized metric names.

type CheckpointArtifact

type CheckpointArtifact struct {
	Model      string
	Checkpoint []byte
}

func (CheckpointArtifact) Content

func (c CheckpointArtifact) Content() []byte

func (CheckpointArtifact) ContentType

func (c CheckpointArtifact) ContentType() ContentType

func (CheckpointArtifact) Name

func (c CheckpointArtifact) Name() string

type ContentType

type ContentType string
const (
	TextContentType  ContentType = "content-type/text"
	ModelContentType ContentType = "content-type/model"
)

type Experiment

type Experiment struct {
	Name string
	Runs []*Run
}

type ExperimentInfo

type ExperimentInfo struct {
	Description string `redis:"Description"`
}

ExperimentInfo is struct that represent additional (user-set) information on an experiment.

func NewExperimentInfo

func NewExperimentInfo(m map[string]string) ExperimentInfo

NewExperimentInfo creates an ExperimentInfo struct from the provided hasmap.

type GenericMetric

type GenericMetric[T cmp.Ordered] struct {
	Key    string
	Values []T
	// contains filtered or unexported fields
}

func NewGenericMetric

func NewGenericMetric[T cmp.Ordered](key string, sizeAlloc int) *GenericMetric[T]

func (*GenericMetric[T]) Add

func (s *GenericMetric[T]) Add(v T)

func (*GenericMetric[T]) AddVal

func (s *GenericMetric[T]) AddVal(v any)

func (*GenericMetric[T]) Commit

func (s *GenericMetric[T]) Commit()

func (*GenericMetric[T]) LastVal

func (s *GenericMetric[T]) LastVal() any

func (GenericMetric[T]) Name

func (s GenericMetric[T]) Name() string

func (*GenericMetric[T]) SetVals

func (s *GenericMetric[T]) SetVals(vs []any)

func (*GenericMetric[T]) Type

func (s *GenericMetric[T]) Type() MetricType

Type infers the MetricType using reflection. If the metric has multiple values it can either be a ContinuousMetric (numerical) or a MultiValueMetric. In the case where no value is present or a single value is present, it can be SingleMetric or SingleNumericMetric.

func (*GenericMetric[T]) UnCommited

func (s *GenericMetric[T]) UnCommited() []T

func (GenericMetric[T]) Vals

func (s GenericMetric[T]) Vals() []any

func (GenericMetric[T]) ValsToCommit

func (s GenericMetric[T]) ValsToCommit() []any

type Metric

type Metric interface {
	Name() string
	Vals() []any
	SetVals(vs []any)
	ValsToCommit() []any
	Commit()
	LastVal() any
	AddVal(v any)
	Type() MetricType
}

type MetricType

type MetricType string
const (
	ContinuousMetric    MetricType = "metric/continuous"
	MultiValueMetric    MetricType = "metric/multival"
	SingleNumericMetric MetricType = "metric/single-numeric"
	SingleMetric        MetricType = "metric/single"
	ComplexMetric       MetricType = "metric/complex"
)

func CollectMetric

func CollectMetric(runs []*Run, metric string) (map[string]any, MetricType)

CollectMetric aggregates all values of a metric present in a slice of runs. Returns a key-value map of runIds (keys) and metric values.

type ModelEntry

type ModelEntry struct {
	URL       string    `json:"url"`
	Tags      []string  `json:"tags"`
	Name      string    `json:"name"`
	Timestamp time.Time `json:"timestamp"`
}

ModelEntry represents a model entry in a registry.

type ModelRegistry

type ModelRegistry struct {
	Name           string
	Models         []ModelEntry
	Tags           map[string][]int
	Timestamp      time.Time
	BenchmarkImage string
}

ModelRegistry holds data related to a registry.

func NewModelRegistry

func NewModelRegistry(name string) *ModelRegistry

NewModelRegistry creates a new registry.

func NewModelRegistryWithTime

func NewModelRegistryWithTime(name string, t time.Time) *ModelRegistry

NewModelRegistryWithTime creates a new registry with a specific Timestamp.

func (*ModelRegistry) Add

func (m *ModelRegistry) Add(url string, tags ...string)

Add registers a model checkpoint with a highest version number. Additional tags can be supplied such (`latest`, `prod`, `dev`).

func (*ModelRegistry) AddTag

func (m *ModelRegistry) AddTag(tag string, version int) error

AddTag adds a tag to model entry by its version number.

func (*ModelRegistry) LastModel

func (m *ModelRegistry) LastModel() ModelEntry

LastModel returns the last model push to the registry.

func (*ModelRegistry) LatestVersion

func (m *ModelRegistry) LatestVersion() int

LatestVersion returns the latest version number in the registry.

func (*ModelRegistry) MarshalEntries

func (m *ModelRegistry) MarshalEntries() ([][]byte, error)

MarshalEntries marshals all model entries to json.

func (*ModelRegistry) ModelByTag

func (m *ModelRegistry) ModelByTag(tag string) (ModelEntry, error)

ModelByTag returns the last model entry tagged with tag.

func (*ModelRegistry) ModelByVersion

func (m *ModelRegistry) ModelByVersion(version int) (ModelEntry, error)

ModelByVersion returns a model entry by its version.

func (*ModelRegistry) ModelsByTag

func (m *ModelRegistry) ModelsByTag(tag string) ([]ModelEntry, error)

ModelsByTag returns the models tagged with tag.

func (*ModelRegistry) SetBenchmarkImage added in v0.1.3

func (m *ModelRegistry) SetBenchmarkImage(image string) error

SetBenchmarkImage sets the benchmark image of Model registry.

func (*ModelRegistry) VersionTag

func (m *ModelRegistry) VersionTag(version int) string

VersionTag builds the version tag of a model.

type PlainTextArtifact

type PlainTextArtifact struct {
	FileName    string
	FileContent string
}

func (PlainTextArtifact) Content

func (p PlainTextArtifact) Content() []byte

func (PlainTextArtifact) ContentType

func (p PlainTextArtifact) ContentType() ContentType

func (PlainTextArtifact) Name

func (p PlainTextArtifact) Name() string

type Run

type Run struct {
	Name         string
	Timestamp    time.Time
	ExperimentID string
	Color        string
	Metrics      map[string]Metric
	Artifacts    map[string]Artifact
}

Run struct holds all data (information, metrics, artifacts) related to a run.

func NewRun

func NewRun(name string, expID string) Run

NewRun initializes a new run with a name and an experiment id. The supplied name is normalized to avoid whitespace.

func (*Run) AddAritifact

func (r *Run) AddAritifact(name string, a Artifact) error

AddAritifact adds a new artifact to the run. Retruns a non-nil error if the supplied name is already in use `ErrAlreadyInUse`.

func (*Run) AddMetric

func (r *Run) AddMetric(name string, m Metric) error

AddMetric adds a new metric with a name. returns an error if the metric name is already in use `ErrAlreadyInUse`.

func (*Run) ArtifactsSlice

func (r *Run) ArtifactsSlice() []Artifact

type SavedArtifact

type SavedArtifact struct {
	Name        string
	ContentType ContentType
	S3Key       string
}

type UpdateBench added in v0.1.3

type UpdateBench struct {
	Name           string
	AutoTag        *bool
	Tag            string
	DecisionMetric string
}

UpdateBench struct used to update a benchmark.

Jump to

Keyboard shortcuts

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