Documentation ¶
Overview ¶
Package experiment enables extraction of useful information from experiment objects and their formatting.
Index ¶
- Variables
- func ConditionFromObjective(objective v2alpha2.Objective) string
- func GetMetricNameAndUnits(metricInfo v2alpha2.MetricInfo) string
- func StringifyReward(reward v2alpha2.Reward) string
- type ConditionType
- type Experiment
- func (e *Experiment) Assert(conditions []ConditionType) error
- func (e *Experiment) Completed() bool
- func (e *Experiment) GetAnnotatedMetricStrs(reward v2alpha2.Reward) []string
- func (e *Experiment) GetMetricDec(metric string, version string) *inf.Dec
- func (e *Experiment) GetMetricStr(metric string, version string) string
- func (e *Experiment) GetMetricStrs(metric string) []string
- func (e *Experiment) GetSatisfyStr(objectiveIndex int, version string) string
- func (e *Experiment) GetSatisfyStrs(objectiveIndex int) []string
- func (e *Experiment) GetVersions() []string
- func (e *Experiment) Started() bool
- func (e *Experiment) WinnerFound() bool
Constants ¶
This section is empty.
Variables ¶
var GetClient = func() (rc client.Client, err error) { var restConf *rest.Config restConf, err = GetConfig() if err != nil { return nil, err } var addKnownTypes = func(scheme *runtime.Scheme) error { metav1.AddToGroupVersion(scheme, v2alpha2.GroupVersion) scheme.AddKnownTypes(v2alpha2.GroupVersion, &v2alpha2.Experiment{}) scheme.AddKnownTypes(v2alpha2.GroupVersion, &v2alpha2.ExperimentList{}) return nil } var schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) scheme := runtime.NewScheme() err = schemeBuilder.AddToScheme(scheme) if err == nil { rc, err = client.New(restConf, client.Options{ Scheme: scheme, }) if err == nil { return rc, nil } } return nil, errors.New("cannot get client using rest config") }
GetClient constructs and returns a K8s client. The returned client has experiment types registered.
GetConfig variable is useful for test mocks.
Functions ¶
func ConditionFromObjective ¶ added in v0.1.36
ConditionFromObjective returns a string representation of condition in the objective
func GetMetricNameAndUnits ¶
func GetMetricNameAndUnits(metricInfo v2alpha2.MetricInfo) string
GetMetricNameAndUnits extracts the name, and if specified, units for the given metricInfo object and combines them into a string.
func StringifyReward ¶
StringifyReward returns a string representation of the given reward.
Types ¶
type ConditionType ¶
type ConditionType string
ConditionType is a type for conditions that can be asserted
const ( // Completed implies experiment is complete Completed ConditionType = "completed" // WinnerFound implies experiment has found a winner WinnerFound ConditionType = "winnerFound" )
type Experiment ¶
type Experiment struct {
v2alpha2.Experiment
}
Experiment is an enhancement of v2alpha2.Experiment struct, and supports various methods used in describing an experiment.
func GetExperiment ¶
func GetExperiment(latest bool, name string, namespace string) (*Experiment, error)
GetExperiment gets the experiment from cluster
func (*Experiment) Assert ¶
func (e *Experiment) Assert(conditions []ConditionType) error
Assert verifies a given set of conditions for the experiment.
func (*Experiment) Completed ¶
func (e *Experiment) Completed() bool
Completed indicates if the experiment has completed.
func (*Experiment) GetAnnotatedMetricStrs ¶
func (e *Experiment) GetAnnotatedMetricStrs(reward v2alpha2.Reward) []string
GetAnnotatedMetricStrs returns a slice of values for a reward
func (*Experiment) GetMetricDec ¶
func (e *Experiment) GetMetricDec(metric string, version string) *inf.Dec
GetMetricDec returns the metric value as a string for a given metric and a given version.
func (*Experiment) GetMetricStr ¶
func (e *Experiment) GetMetricStr(metric string, version string) string
GetMetricStr returns the metric value as a string for a given metric and a given version.
func (*Experiment) GetMetricStrs ¶
func (e *Experiment) GetMetricStrs(metric string) []string
GetMetricStrs returns the given metric's value as a slice of strings, whose elements correspond to versions.
func (*Experiment) GetSatisfyStr ¶
func (e *Experiment) GetSatisfyStr(objectiveIndex int, version string) string
GetSatisfyStr returns a true/false/unavailable valued string denotating if a version satisfies the objective.
func (*Experiment) GetSatisfyStrs ¶
func (e *Experiment) GetSatisfyStrs(objectiveIndex int) []string
GetSatisfyStrs returns a slice of true/false/unavailable valued strings for an objective denoting if it is satisfied by versions.
func (*Experiment) GetVersions ¶
func (e *Experiment) GetVersions() []string
GetVersions returns the slice of version name strings. If the VersionInfo section is not present in the experiment's spec, then this slice is empty.
func (*Experiment) Started ¶
func (e *Experiment) Started() bool
Started indicates if at least one iteration of the experiment has completed.
func (*Experiment) WinnerFound ¶
func (e *Experiment) WinnerFound() bool
WinnerFound indicates if the experiment has found a winning version (winner).