Documentation
¶
Index ¶
- Variables
- func ArtifactIDMap(artifacts []Artifact) map[string]Artifact
- func ArtifactIDs(artifacts []Artifact) []string
- func BestRuns(runs []*BenchRun, metrics ...BenchMetric) map[string]*BenchRun
- func IsValidContentType(contentType string) bool
- func NewAPIKey(length int) (string, error)
- func NewAlreadyInUseErr(s string) error
- func NewBadRequest(s string) error
- func NewInternalErr(s string) error
- func NewInvalidInputErr(s string) error
- func NewNotFoundErr(s string) error
- func NormalizeID(s string) string
- func ParseVal(s string) any
- func SanitizeName(name string) string
- func SanitizeNames(names []string) []string
- func UniqueMetrics(runs []*Run) []string
- type Artifact
- type Bench
- type BenchEvent
- type BenchMetric
- type BenchRun
- type CheckpointArtifact
- type ContentType
- type Experiment
- type ExperimentInfo
- type GenericMetric
- func (s *GenericMetric[T]) Add(v T)
- func (s *GenericMetric[T]) AddVal(v any)
- func (s *GenericMetric[T]) Commit()
- func (s *GenericMetric[T]) LastVal() any
- func (s GenericMetric[T]) Name() string
- func (s *GenericMetric[T]) SetVals(vs []any)
- func (s *GenericMetric[T]) Type() MetricType
- func (s *GenericMetric[T]) UnCommited() []T
- func (s GenericMetric[T]) Vals() []any
- func (s GenericMetric[T]) ValsToCommit() []any
- type Metric
- type MetricType
- type ModelEntry
- type ModelRegistry
- func (m *ModelRegistry) Add(url string, tags ...string)
- func (m *ModelRegistry) AddTag(tag string, version int) error
- func (m *ModelRegistry) LastModel() ModelEntry
- func (m *ModelRegistry) LatestVersion() int
- func (m *ModelRegistry) MarshalEntries() ([][]byte, error)
- func (m *ModelRegistry) ModelByTag(tag string) (ModelEntry, error)
- func (m *ModelRegistry) ModelByVersion(version int) (ModelEntry, error)
- func (m *ModelRegistry) ModelsByTag(tag string) ([]ModelEntry, error)
- func (m *ModelRegistry) SetBenchmarkImage(image string) error
- func (m *ModelRegistry) VersionTag(version int) string
- type PlainTextArtifact
- type Run
- type SavedArtifact
- type UpdateBench
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ArtifactIDMap ¶
func ArtifactIDs ¶
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 NewAlreadyInUseErr ¶
func NewBadRequest ¶
func NewInternalErr ¶
func NewInvalidInputErr ¶
func NewNotFoundErr ¶
func NormalizeID ¶
func SanitizeName ¶ added in v0.1.3
SanitizeName sanatizes a name by removing any whitespace and converting the string to lower case.
func SanitizeNames ¶ added in v0.1.3
SanitizeNames sanitizes a list of names in place.
func UniqueMetrics ¶
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
}
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
BenchMetrics returns the names of metrics tracked.
func (*Bench) GenerateID ¶ added in v0.1.3
func (b *Bench) GenerateID()
GenerateID generates a new ID.
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
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
SanitizedMetrics returns a metrics with sanitized metric names.
type CheckpointArtifact ¶
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 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 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 ¶
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 ¶
NewRun initializes a new run with a name and an experiment id. The supplied name is normalized to avoid whitespace.
func (*Run) AddAritifact ¶
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 ¶
AddMetric adds a new metric with a name. returns an error if the metric name is already in use `ErrAlreadyInUse`.
func (*Run) ArtifactsSlice ¶
type SavedArtifact ¶
type SavedArtifact struct {
Name string
ContentType ContentType
S3Key string
}