v1alpha1

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright 2019 GramLabs, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	ErrExperimentNameInvalid  ErrorType = "experiment-name-invalid"
	ErrExperimentNameConflict           = "experiment-name-conflict"
	ErrExperimentInvalid                = "experiment-invalid"
	ErrExperimentNotFound               = "experiment-not-found"
	ErrExperimentStopped                = "experiment-stopped"
	ErrTrialInvalid                     = "trial-invalid"
	ErrTrialUnavailable                 = "trial-unavailable"
	ErrTrialNotFound                    = "trial-not-found"
)
View Source
const (
	TrialStaged    TrialStatus = "staged"
	TrialActive                = "active"
	TrialCompleted             = "completed"
	TrialFailed                = "failed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	GetAllExperiments(context.Context, *ExperimentListQuery) (ExperimentList, error)
	GetAllExperimentsByPage(context.Context, string) (ExperimentList, error)
	GetExperimentByName(context.Context, ExperimentName) (Experiment, error)
	GetExperiment(context.Context, string) (Experiment, error)
	CreateExperiment(context.Context, ExperimentName, Experiment) (Experiment, error)
	DeleteExperiment(context.Context, string) error
	GetAllTrials(context.Context, string) (TrialList, error)
	CreateTrial(context.Context, string, TrialAssignments) (string, error) // TODO Should this return TrialAssignments?
	NextTrial(context.Context, string) (TrialAssignments, error)
	ReportTrial(context.Context, string, TrialValues) error
}

API provides bindings for the supported endpoints

func NewApi

func NewApi(c api.Client) API

NewApi returns a new version specific API for the specified client

func NewForConfig

func NewForConfig(c *api.Config) (API, error)

NewForConfig returns a new version specific API for the specified client configuration

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 json.Number `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 Error

type Error struct {
	Type       ErrorType
	RetryAfter time.Duration
}

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

type Experiment

type Experiment struct {
	ExperimentMeta

	// The display name of the experiment. Do not use for generating URLs!
	DisplayName string `json:"displayName,omitempty"`
	// Controls how the optimizer will generate trials.
	Optimization Optimization `json:"optimization,omitempty"`
	// The metrics been optimized in the experiment.
	Metrics []Metric `json:"metrics"`
	// The search space of the experiment.
	Parameters []Parameter `json:"parameters"`
}

Experiment combines the search space, outcomes and optimization configuration

type ExperimentItem

type ExperimentItem struct {
	Experiment
	// The absolute URL used to reference the individual experiment.
	ItemRef string `json:"itemRef,omitempty"`
}

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
}

func (*ExperimentListQuery) Encode

func (p *ExperimentListQuery) Encode() string

type ExperimentMeta

type ExperimentMeta struct {
	Self      string `json:"-"`
	Trials    string `json:"-"`
	NextTrial string `json:"-"`
}

func (*ExperimentMeta) SetLastModified

func (m *ExperimentMeta) SetLastModified(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

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 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"`
}

type Optimization

type Optimization struct {
	// The estimated number of trial runs to perform for an experiment.
	ExperimentBudget int32 `json:"experimentBudget,omitempty"`
	// The total number of concurrent trial runs supported for an experiment.
	ParallelTrials int32 `json:"parallelTrials,omitempty"`
	// The total number of random trials used to start an experiment.
	BurnIn int32 `json:"burnIn,omitempty"`
}

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"`
}

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

type ParameterType

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

type TrialAssignments

type TrialAssignments struct {
	TrialMeta

	// The list of parameter names and their assigned values.
	Assignments []Assignment `json:"assignments"`
}

type TrialItem

type TrialItem struct {
	TrialAssignments
	TrialValues

	// The current trial status.
	Status TrialStatus `json:"status"`
	// Labels for this trial.
	Labels map[string]string `json:"labels"`
}

type TrialList

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

type TrialMeta

type TrialMeta struct {
	ReportTrial string `json:"-"`
}

func (*TrialMeta) SetLastModified

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

func (*TrialMeta) SetLocation

func (m *TrialMeta) SetLocation(location string)

type TrialStatus

type TrialStatus string

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"`
}

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"`
}

Jump to

Keyboard shortcuts

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