userconfig

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Shared
	UnknownKey = "unknown"
	NameKey    = "name"
	KindKey    = "kind"

	// API
	ModelKey          = "model"
	PathKey           = "path"
	EndpointKey       = "endpoint"
	RequestHandlerKey = "request_handler"
	SignatureKeyKey   = "signature_key"
	TrackerKey        = "tracker"
	ModelTypeKey      = "model_type"
	KeyKey            = "key"
	TensorFlowKey     = "tensorflow"
	ONNXKey           = "onnx"
	PredictorKey      = "predictor"
	MetadataKey       = "metadata"
	PythonPathKey     = "python_path"

	// Compute
	ComputeKey              = "compute"
	MinReplicasKey          = "min_replicas"
	MaxReplicasKey          = "max_replicas"
	InitReplicasKey         = "init_replicas"
	TargetCPUUtilizationKey = "target_cpu_utilization"
	CPUKey                  = "cpu"
	GPUKey                  = "gpu"
	MemKey                  = "mem"
)

Variables

This section is empty.

Functions

func ErrorCannotBeNull

func ErrorCannotBeNull() error

func ErrorDuplicateConfig

func ErrorDuplicateConfig(resourceType resource.Type) error

func ErrorDuplicateEndpoints added in v0.10.0

func ErrorDuplicateEndpoints(endpoint string, apiNames ...string) error

func ErrorDuplicateResourceName

func ErrorDuplicateResourceName(resources ...Resource) error

func ErrorExternalNotFound added in v0.4.1

func ErrorExternalNotFound(path string) error

func ErrorImplDoesNotExist

func ErrorImplDoesNotExist(path string) error

func ErrorInitReplicasGreaterThanMax added in v0.6.0

func ErrorInitReplicasGreaterThanMax(init int32, max int32) error

func ErrorInitReplicasLessThanMin added in v0.6.0

func ErrorInitReplicasLessThanMin(init int32, min int32) error

func ErrorInvalidTensorFlowDir added in v0.9.0

func ErrorInvalidTensorFlowDir(path string) error

func ErrorMalformedConfig

func ErrorMalformedConfig() error

func ErrorMinReplicasGreaterThanMax added in v0.6.0

func ErrorMinReplicasGreaterThanMax(min int32, max int32) error

func ErrorMissingAppDefinition

func ErrorMissingAppDefinition() error

func ErrorONNXDoesntSupportZip added in v0.8.0

func ErrorONNXDoesntSupportZip() error

func ErrorOneOfPrerequisitesNotDefined

func ErrorOneOfPrerequisitesNotDefined(argName string, prerequisites ...string) error

func ErrorSpecifyAllOrNone

func ErrorSpecifyAllOrNone(vals ...string) error

func ErrorSpecifyOneModelFormatFoundMultiple added in v0.10.0

func ErrorSpecifyOneModelFormatFoundMultiple(found []string, vals ...string) error

func ErrorSpecifyOneModelFormatFoundNone added in v0.10.0

func ErrorSpecifyOneModelFormatFoundNone(vals ...string) error

func ErrorUndefinedResource

func ErrorUndefinedResource(resourceName string, resourceTypes ...resource.Type) error

func GetTFServingExportFromS3Path added in v0.8.0

func GetTFServingExportFromS3Path(path string, awsClient *aws.Client) (string, error)

func Identify

func Identify(r Resource) string

func IsValidTensorFlowS3Directory added in v0.8.0

func IsValidTensorFlowS3Directory(path string, awsClient *aws.Client) bool

IsValidTensorFlowS3Directory checks that the path contains a valid S3 directory for TensorFlow models Must contain the following structure: - 1523423423/ (version prefix, usually a timestamp)

  • saved_model.pb
  • variables/
  • variables.index
  • variables.data-00000-of-00001 (there are a variable number of these files)

func ModelTypeStrings added in v0.8.0

func ModelTypeStrings() []string

func QuantityParser

func QuantityParser(v *QuantityValidation) func(string) (interface{}, error)

func QuantityPtrID

func QuantityPtrID(quantity *Quantity) string

func QuantityPtrsEqual

func QuantityPtrsEqual(quantity *Quantity, quantity2 *Quantity) bool

func ValidatePythonPath added in v0.10.0

func ValidatePythonPath(path string, projectFileMap map[string][]byte) error

Types

type API

type API struct {
	ResourceFields
	Endpoint   *string     `json:"endpoint" yaml:"endpoint"`
	TensorFlow *TensorFlow `json:"tensorflow" yaml:"tensorflow"`
	ONNX       *ONNX       `json:"onnx" yaml:"onnx"`
	Predictor  *Predictor  `json:"predictor" yaml:"predictor"`
	Tracker    *Tracker    `json:"tracker" yaml:"tracker"`
	Compute    *APICompute `json:"compute" yaml:"compute"`
}

func (*API) AreProjectFilesRequired added in v0.8.0

func (api *API) AreProjectFilesRequired() bool

func (*API) GetResourceType

func (api *API) GetResourceType() resource.Type

func (*API) UserConfigStr added in v0.5.0

func (api *API) UserConfigStr() string

func (*API) Validate

func (api *API) Validate(deploymentName string, projectFileMap map[string][]byte) error

type APICompute

type APICompute struct {
	MinReplicas          int32     `json:"min_replicas" yaml:"min_replicas"`
	MaxReplicas          int32     `json:"max_replicas" yaml:"max_replicas"`
	InitReplicas         int32     `json:"init_replicas" yaml:"init_replicas"`
	TargetCPUUtilization int32     `json:"target_cpu_utilization" yaml:"target_cpu_utilization"`
	CPU                  Quantity  `json:"cpu" yaml:"cpu"`
	Mem                  *Quantity `json:"mem" yaml:"mem"`
	GPU                  int64     `json:"gpu" yaml:"gpu"`
}

func (*APICompute) ID

func (ac *APICompute) ID() string

func (*APICompute) IDWithoutReplicas

func (ac *APICompute) IDWithoutReplicas() string

Only consider CPU, Mem, GPU

func (*APICompute) UserConfigStr added in v0.5.0

func (ac *APICompute) UserConfigStr() string

func (*APICompute) Validate added in v0.6.0

func (ac *APICompute) Validate() error

type APIs

type APIs []*API

func (APIs) AreProjectFilesRequired added in v0.8.0

func (apis APIs) AreProjectFilesRequired() bool

func (APIs) Names

func (apis APIs) Names() []string

func (APIs) Validate

func (apis APIs) Validate(deploymentName string, projectFileMap map[string][]byte) error

type App

type App struct {
	Name string `json:"name" yaml:"name"`
}

type Config

type Config struct {
	App  *App `json:"app" yaml:"app"`
	APIs APIs `json:"apis" yaml:"apis"`
}

func New

func New(filePath string, configBytes []byte) (*Config, error)

func ReadConfigFile added in v0.8.0

func ReadConfigFile(filePath string, relativePath string) (*Config, error)

func (*Config) AreProjectFilesRequired added in v0.8.0

func (config *Config) AreProjectFilesRequired() bool

func (*Config) Validate

func (config *Config) Validate(projectBytes []byte) error

type Error

type Error struct {
	Kind ErrorKind
	// contains filtered or unexported fields
}

func (Error) Error

func (e Error) Error() string

type ErrorKind

type ErrorKind int
const (
	ErrUnknown ErrorKind = iota
	ErrDuplicateResourceName
	ErrDuplicateConfig
	ErrMalformedConfig
	ErrMissingAppDefinition
	ErrUndefinedResource
	ErrSpecifyAllOrNone
	ErrSpecifyOnlyOne
	ErrOneOfPrerequisitesNotDefined
	ErrCannotBeNull
	ErrMinReplicasGreaterThanMax
	ErrInitReplicasGreaterThanMax
	ErrInitReplicasLessThanMin
	ErrSpecifyOneModelFormatFoundNone
	ErrSpecifyOneModelFormatFoundMultiple
	ErrImplDoesNotExist
	ErrExternalNotFound
	ErrONNXDoesntSupportZip
	ErrInvalidTensorFlowDir
	ErrDuplicateEndpoints
)

func (ErrorKind) MarshalBinary

func (t ErrorKind) MarshalBinary() ([]byte, error)

MarshalBinary satisfies BinaryMarshaler

func (ErrorKind) MarshalText

func (t ErrorKind) MarshalText() ([]byte, error)

MarshalText satisfies TextMarshaler

func (ErrorKind) String

func (t ErrorKind) String() string

func (*ErrorKind) UnmarshalBinary

func (t *ErrorKind) UnmarshalBinary(data []byte) error

UnmarshalBinary satisfies BinaryUnmarshaler Needed for msgpack

func (*ErrorKind) UnmarshalText

func (t *ErrorKind) UnmarshalText(text []byte) error

UnmarshalText satisfies TextUnmarshaler

type ModelType added in v0.8.0

type ModelType int
const (
	UnknownModelType ModelType = iota
	ClassificationModelType
	RegressionModelType
)

func ModelTypeFromString added in v0.8.0

func ModelTypeFromString(s string) ModelType

func (ModelType) MarshalBinary added in v0.8.0

func (t ModelType) MarshalBinary() ([]byte, error)

MarshalBinary satisfies BinaryMarshaler

func (ModelType) MarshalText added in v0.8.0

func (t ModelType) MarshalText() ([]byte, error)

MarshalText satisfies TextMarshaler

func (ModelType) String added in v0.8.0

func (t ModelType) String() string

func (*ModelType) UnmarshalBinary added in v0.8.0

func (t *ModelType) UnmarshalBinary(data []byte) error

UnmarshalBinary satisfies BinaryUnmarshaler Needed for msgpack

func (*ModelType) UnmarshalText added in v0.8.0

func (t *ModelType) UnmarshalText(text []byte) error

UnmarshalText satisfies TextUnmarshaler

type ONNX added in v0.10.0

type ONNX struct {
	Model          string                 `json:"model" yaml:"model"`
	RequestHandler *string                `json:"request_handler" yaml:"request_handler"`
	PythonPath     *string                `json:"python_path" yaml:"python_path"`
	Metadata       map[string]interface{} `json:"metadata" yaml:"metadata"`
}

func (*ONNX) UserConfigStr added in v0.10.0

func (onnx *ONNX) UserConfigStr() string

func (*ONNX) Validate added in v0.10.0

func (onnx *ONNX) Validate(projectFileMap map[string][]byte) error

type Predictor added in v0.10.0

type Predictor struct {
	Path       string                 `json:"path" yaml:"path"`
	Model      *string                `json:"model" yaml:"model"`
	PythonPath *string                `json:"python_path" yaml:"python_path"`
	Metadata   map[string]interface{} `json:"metadata" yaml:"metadata"`
}

func (*Predictor) UserConfigStr added in v0.10.0

func (predictor *Predictor) UserConfigStr() string

func (*Predictor) Validate added in v0.10.0

func (predictor *Predictor) Validate(projectFileMap map[string][]byte) error

type Quantity

type Quantity struct {
	kresource.Quantity
	UserString string
}

func (*Quantity) Equal

func (quantity *Quantity) Equal(quantity2 Quantity) bool

func (*Quantity) ID

func (quantity *Quantity) ID() string

func (Quantity) MarshalBinary

func (quantity Quantity) MarshalBinary() ([]byte, error)

func (Quantity) MarshalJSON

func (quantity Quantity) MarshalJSON() ([]byte, error)

func (Quantity) MarshalText

func (quantity Quantity) MarshalText() ([]byte, error)

func (*Quantity) SplitInTwo

func (quantity *Quantity) SplitInTwo() (*kresource.Quantity, *kresource.Quantity)

SplitInTwo divides the quantity in two and return both halves (ensuring they add up to the original value)

func (*Quantity) String

func (quantity *Quantity) String() string

func (*Quantity) ToFloat32

func (quantity *Quantity) ToFloat32() float32

func (*Quantity) ToKi

func (quantity *Quantity) ToKi() int64

func (*Quantity) UnmarshalBinary

func (quantity *Quantity) UnmarshalBinary(data []byte) error

func (*Quantity) UnmarshalJSON

func (quantity *Quantity) UnmarshalJSON(data []byte) error

func (*Quantity) UnmarshalText

func (quantity *Quantity) UnmarshalText(data []byte) error

type QuantityValidation

type QuantityValidation struct {
	GreaterThan          *kresource.Quantity
	GreaterThanOrEqualTo *kresource.Quantity
	LessThan             *kresource.Quantity
	LessThanOrEqualTo    *kresource.Quantity
}

type Resource

type Resource interface {
	GetName() string
	GetResourceType() resource.Type
	GetIndex() int
	SetIndex(int)
	GetFilePath() string
	SetFilePath(string)
}

func FindDuplicateResourceName

func FindDuplicateResourceName(resources ...Resource) []Resource

type ResourceFields

type ResourceFields struct {
	Name     string `json:"name" yaml:"name"`
	Index    int    `json:"index" yaml:"-"`
	FilePath string `json:"file_path" yaml:"-"`
}

func (*ResourceFields) GetFilePath

func (resourceFields *ResourceFields) GetFilePath() string

func (*ResourceFields) GetIndex

func (resourceFields *ResourceFields) GetIndex() int

func (*ResourceFields) GetName

func (resourceFields *ResourceFields) GetName() string

func (*ResourceFields) SetFilePath

func (resourceFields *ResourceFields) SetFilePath(filePath string)

func (*ResourceFields) SetIndex

func (resourceFields *ResourceFields) SetIndex(index int)

func (*ResourceFields) UserConfigStr added in v0.5.0

func (resourceFields *ResourceFields) UserConfigStr() string

type TensorFlow added in v0.10.0

type TensorFlow struct {
	Model          string                 `json:"model" yaml:"model"`
	RequestHandler *string                `json:"request_handler" yaml:"request_handler"`
	SignatureKey   *string                `json:"signature_key" yaml:"signature_key"`
	PythonPath     *string                `json:"python_path" yaml:"python_path"`
	Metadata       map[string]interface{} `json:"metadata" yaml:"metadata"`
}

func (*TensorFlow) UserConfigStr added in v0.10.0

func (tf *TensorFlow) UserConfigStr() string

func (*TensorFlow) Validate added in v0.10.0

func (tf *TensorFlow) Validate(projectFileMap map[string][]byte) error

type Tracker added in v0.8.0

type Tracker struct {
	Key       *string   `json:"key" yaml:"key"`
	ModelType ModelType `json:"model_type" yaml:"model_type"`
}

func (*Tracker) UserConfigStr added in v0.8.0

func (tracker *Tracker) UserConfigStr() string

Jump to

Keyboard shortcuts

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