v1alpha1

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckParameterValue

func CheckParameterValue(p *Parameter, v *numstr.NumberOrString) error

CheckParameterValue validates that the supplied value can be used for a parameter.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized check to see if the error is an "unauthorized" error

Types

type API

API provides bindings for the supported endpoints

func NewAPI

func NewAPI(c api.Client) API

NewAPI returns a new API implementation for the specified client

type Assignment

type Assignment struct {
	// The name of the parameter in the experiment the assignment corresponds to.
	ParameterName string `json:"parameterName"`
	// The assigned value of the parameter.
	Value numstr.NumberOrString `json:"value"`
}

type Bounds

type Bounds struct {
	// The minimum value for a numeric parameter.
	Min json.Number `json:"min"`
	// The maximum value for a numeric parameter.
	Max json.Number `json:"max"`
}

type Constraint

type Constraint struct {
	// Optional name for constraint.
	Name string `json:"name,omitempty"`

	ConstraintType  ConstraintType `json:"constraintType"`
	SumConstraint   `json:",inline"`
	OrderConstraint `json:",inline"`
}

type ConstraintType

type ConstraintType string
const (
	ConstraintSum   ConstraintType = "sum"
	ConstraintOrder ConstraintType = "order"
)

type Error

type Error struct {
	Type       ErrorType     `json:"-"`
	Message    string        `json:"error"`
	RetryAfter time.Duration `json:"-"`
	Location   string        `json:"-"`
}

Error represents the API specific error messages and may be used in response to HTTP status codes

func (*Error) Error

func (e *Error) Error() string

type ErrorType

type ErrorType string
const (
	ErrExperimentNameInvalid  ErrorType = "experiment-name-invalid"
	ErrExperimentNameConflict ErrorType = "experiment-name-conflict"
	ErrExperimentInvalid      ErrorType = "experiment-invalid"
	ErrExperimentNotFound     ErrorType = "experiment-not-found"
	ErrExperimentStopped      ErrorType = "experiment-stopped"
	ErrTrialInvalid           ErrorType = "trial-invalid"
	ErrTrialUnavailable       ErrorType = "trial-unavailable"
	ErrTrialNotFound          ErrorType = "trial-not-found"
	ErrTrialAlreadyReported   ErrorType = "trial-already-reported"
	ErrUnauthorized           ErrorType = "unauthorized"
	ErrUnexpected             ErrorType = "unexpected"
)

type Experiment

type Experiment struct {
	ExperimentMeta

	// The display name of the experiment. Do not use for generating URLs!
	DisplayName string `json:"displayName,omitempty"`
	// The number of observations made for this experiment.
	Observations int64 `json:"observations,omitempty"`
	// The target number of observations for this experiment.
	Budget int64 `json:"budget,omitempty"`
	// Controls how the optimizer will generate trials.
	Optimization []Optimization `json:"optimization,omitempty"`
	// The metrics been optimized in the experiment.
	Metrics []Metric `json:"metrics"`
	// Constraints for the experiment.
	Constraints []Constraint `json:"constraints,omitempty"`
	// The search space of the experiment.
	Parameters []Parameter `json:"parameters"`
	// Labels for this experiment.
	Labels map[string]string `json:"labels,omitempty"`
}

Experiment combines the search space, outcomes and optimization configuration

func (*Experiment) Name

func (e *Experiment) Name() string

Name allows an experiment to be used as an ExperimentName

type ExperimentItem

type ExperimentItem struct {
	Experiment

	// The metadata for an individual experiment.
	Metadata Metadata `json:"_metadata,omitempty"`
}

type ExperimentLabels

type ExperimentLabels struct {
	// New labels for this experiment.
	Labels map[string]string `json:"labels"`
}

type ExperimentList

type ExperimentList struct {
	ExperimentListMeta

	// The list of experiments.
	Experiments []ExperimentItem `json:"experiments,omitempty"`
}

type ExperimentListMeta

type ExperimentListMeta struct {
	Next string `json:"-"`
	Prev string `json:"-"`
}

func (*ExperimentListMeta) SetLastModified

func (m *ExperimentListMeta) SetLastModified(time.Time)
func (m *ExperimentListMeta) SetLink(rel, link string)

func (*ExperimentListMeta) SetLocation

func (m *ExperimentListMeta) SetLocation(string)

type ExperimentListQuery

type ExperimentListQuery struct {
	Offset        int
	Limit         int
	LabelSelector map[string]string
}

func (*ExperimentListQuery) Encode

func (p *ExperimentListQuery) Encode() string

type ExperimentMeta

type ExperimentMeta struct {
	LastModified time.Time `json:"-"`
	SelfURL      string    `json:"-"`
	TrialsURL    string    `json:"-"`
	NextTrialURL string    `json:"-"`
	LabelsURL    string    `json:"-"`
}

func (*ExperimentMeta) Headers

func (m *ExperimentMeta) Headers() http.Header

func (*ExperimentMeta) SetLastModified

func (m *ExperimentMeta) SetLastModified(lastModified time.Time)
func (m *ExperimentMeta) SetLink(rel, link string)

func (*ExperimentMeta) SetLocation

func (m *ExperimentMeta) SetLocation(string)

type ExperimentName

type ExperimentName interface {
	Name() string
}

ExperimentName exists to clearly separate cases where an actual name can be used

func NewExperimentName

func NewExperimentName(n string) ExperimentName

NewExperimentName returns an experiment name for a given string

func SplitTrialName

func SplitTrialName(name string) (ExperimentName, int64)

SplitTrialName provides a consistent experience when trying to split a "trial name" into an experiment name and a trial number. When the provided name does not contain a number, the resulting number will be less then zero.

type Meta

type Meta interface {
	SetLocation(string)
	SetLastModified(time.Time)
	SetLink(rel, link string)
}

Meta is used to collect resource metadata from the response

type Metadata

type Metadata map[string][]string

Metadata is used to hold single or multi-value metadata from list responses

func (*Metadata) UnmarshalJSON

func (m *Metadata) UnmarshalJSON(b []byte) error

type Metric

type Metric struct {
	// The name of the metric.
	Name string `json:"name"`
	// The flag indicating this metric should be minimized.
	Minimize bool `json:"minimize,omitempty"`
	// The flag indicating this metric is optimized (nil defaults to true).
	Optimize *bool `json:"optimize,omitempty"`
}

type Optimization

type Optimization struct {
	// The name of the optimization parameter.
	Name string `json:"name"`
	// The value of the optimization parameter.
	Value string `json:"value"`
}

type OrderConstraint

type OrderConstraint struct {
	// Name of lower parameter.
	LowerParameter string `json:"lowerParameter"`
	// Name of upper parameter.
	UpperParameter string `json:"upperParameter"`
}

type Parameter

type Parameter struct {
	// The name of the parameter.
	Name string `json:"name"`
	// The type of the parameter.
	Type ParameterType `json:"type"`
	// The domain of the parameter.
	Bounds *Bounds `json:"bounds,omitempty"`
	// The discrete values for a categorical parameter.
	Values []string `json:"values,omitempty"`
}

Parameter is a variable that is going to be tuned in an experiment

func (*Parameter) LowerBound

func (p *Parameter) LowerBound() (*numstr.NumberOrString, error)

LowerBound attempts to return the lower bound for this parameter.

func (*Parameter) ParseValue

func (p *Parameter) ParseValue(s string) (*numstr.NumberOrString, error)

ParseValue attempts to parse the supplied value into a NumberOrString based on the type of this parameter.

func (*Parameter) UpperBound

func (p *Parameter) UpperBound() (*numstr.NumberOrString, error)

UpperBound attempts to return the upper bound for this parameter.

type ParameterType

type ParameterType string
const (
	ParameterTypeInteger     ParameterType = "int"
	ParameterTypeDouble      ParameterType = "double"
	ParameterTypeCategorical ParameterType = "categorical"
)

type ServerMeta

type ServerMeta struct {
	Server string `json:"-"`
}

func (*ServerMeta) Unmarshal

func (m *ServerMeta) Unmarshal(header http.Header)

type SumConstraint

type SumConstraint struct {
	// Flag indicating if bound is upper or lower bound.
	IsUpperBound bool `json:"isUpperBound,omitempty"`
	// Bound for inequality constraint.
	Bound float64 `json:"bound"`
	// Parameters and weights for constraint.
	Parameters []SumConstraintParameter `json:"parameters"`
}

type SumConstraintParameter

type SumConstraintParameter struct {
	// Name of parameter to be used in constraint.
	Name string `json:"name"`
	// Weight for parameter in constraint.
	Weight float64 `json:"weight"`
}

type TrialAssignments

type TrialAssignments struct {
	TrialMeta

	// The list of parameter names and their assigned values.
	Assignments []Assignment `json:"assignments"`
	// Labels for this trial.
	Labels map[string]string `json:"labels,omitempty"`
}

type TrialItem

type TrialItem struct {
	TrialAssignments
	TrialValues

	// The current trial status.
	Status TrialStatus `json:"status"`
	// Ordinal number indicating when during an experiment the trail was generated.
	Number int64 `json:"number"`
	// Labels for this trial.
	Labels map[string]string `json:"labels,omitempty"`

	// The metadata for an individual trial.
	Metadata Metadata `json:"_metadata,omitempty"`

	// Experiment is a reference back to the experiment this trial item is associated with. This field is never
	// populated by the API, but may be useful for consumers to maintain a connection between resources.
	Experiment *Experiment `json:"-"`
}

func (*TrialItem) Name

func (t *TrialItem) Name() string

Name returns an effective name for uniquely identifying the trial.

type TrialLabels

type TrialLabels struct {
	// New labels for this trial.
	Labels map[string]string `json:"labels"`
}

type TrialList

type TrialList struct {
	// The list of trials.
	Trials []TrialItem `json:"trials"`

	// Experiment is a reference back to the experiment this trial item is associated with. This field is never
	// populated by the API, but may be useful for consumers to maintain a connection between resources.
	Experiment *Experiment `json:"-"`
}

type TrialListQuery

type TrialListQuery struct {
	// Comma separated list of statuses to fetch.
	Status []TrialStatus
	// Comma separated list of label value pairs to match on.
	LabelSelector map[string]string
}

func (*TrialListQuery) Encode

func (p *TrialListQuery) Encode() string

type TrialMeta

type TrialMeta struct {
	SelfURL   string `json:"-"`
	LabelsURL string `json:"-"`
}

func (*TrialMeta) SetLastModified

func (m *TrialMeta) SetLastModified(time.Time)
func (m *TrialMeta) SetLink(rel, link string)

func (*TrialMeta) SetLocation

func (m *TrialMeta) SetLocation(location string)

type TrialStatus

type TrialStatus string
const (
	TrialStaged    TrialStatus = "staged"
	TrialActive    TrialStatus = "active"
	TrialCompleted TrialStatus = "completed"
	TrialFailed    TrialStatus = "failed"
	TrialAbandoned TrialStatus = "abandoned"
)

type TrialValues

type TrialValues struct {
	// The observed values.
	Values []Value `json:"values,omitempty"`
	// Indicator that the trial failed, Values is ignored when true.
	Failed bool `json:"failed,omitempty"`
	// FailureReason is a the machine-readable reason code for the failure, if Failed is true.
	FailureReason string `json:"failureReason,omitempty"`
	// FailureMessage is a human-readable explanation of the failure, if Failed is true.
	FailureMessage string `json:"failureMessage,omitempty"`
	// StartTime is the time at which the trial was started.
	StartTime *time.Time `json:"startTime,omitempty"`
	// CompletionTime is the time at which the trial was completed.
	CompletionTime *time.Time `json:"completionTime,omitempty"`
}

type Value

type Value struct {
	// The name of the metric in the experiment the value corresponds to.
	MetricName string `json:"metricName"`
	// The observed value of the metric.
	Value float64 `json:"value"`
	// The observed error of the metric.
	Error float64 `json:"error,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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