Skip to content

Commit

Permalink
API for metricCollector (kubeflow#697)
Browse files Browse the repository at this point in the history
* API for metricCollector

* Drop trialmetrics crd
  • Loading branch information
hougangliu authored and k8s-ci-robot committed Aug 1, 2019
1 parent 97e0b32 commit de96a52
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 5 deletions.
5 changes: 4 additions & 1 deletion pkg/api/operators/apis/addtoscheme_katib_v1alpha2.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ import (

func init() {
// Register the types with the Scheme so the components can map objects to GroupVersionKinds and back
AddToSchemes = append(AddToSchemes, experiments.SchemeBuilder.AddToScheme, trials.SchemeBuilder.AddToScheme)
AddToSchemes = append(AddToSchemes,
experiments.SchemeBuilder.AddToScheme,
trials.SchemeBuilder.AddToScheme,
)
}
60 changes: 56 additions & 4 deletions pkg/api/operators/apis/experiment/v1alpha2/experiment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,64 @@ type Operation struct {
Parameters []ParameterSpec `json:"parameters,omitempty"`
}

// Spec for metrics collectors. For v1alpha2 we will keep metrics collection as
// cron jobs. This can be replaced by a push-model when the metadata client lib
// is ready.
type MetricsCollectorSpec struct {
Retain bool `json:"retain,omitempty"`
// Deprecated Retain
Retain bool `json:"retain,omitempty"`
// Deprecated GoTemplate
GoTemplate GoTemplate `json:"goTemplate,omitempty"`

Source *SourceSpec `json:"source,omitempty"`
Collector *CollectorSpec `json:"collector,omitempty"`
}

type SourceSpec struct {
// Model-train source code can expose metrics by http, such as HTTP endpoint in
// prometheus metric format
HttpGet *v1.HTTPGetAction `json:"httpGet,omitempty"`
// During training model, metrics may be persisted into local file in source
// code, such as tfEvent use case
FileSystemPath *FileSystemPath `json:"fileSystemPath,omitempty"`
// Default metric output format is {"metric": "<metric_name>",
// "value": <int_or_float>, "epoch": <int>, "step": <int>}, but if the output doesn't
// follow default format, please extend it here
Filter *FilterSpec `json:"filter,omitempty"`
}

type FilterSpec struct {
// When the metrics output follows format as this field specified, metricsCollector
// collects it and reports to metrics server, it can be "<metric_name>: <float>" or else
MetricsFormat []string `json:"metricsFormat,omitempty"`
}

type FileSystemKind string

const (
DirectoryKind FileSystemKind = "diretory"
FileKind FileSystemKind = "file"
)

type FileSystemPath struct {
Path string `json:"path,omitempty"`
Kind FileSystemKind `json:"kind,omitempty"`
}

type CollectorKind string

const (
StdOutCollector CollectorKind = "stdOutCollector"
FileCollector CollectorKind = "fileCollector"
TfEventCollector CollectorKind = "tfEventCollector"
PrometheusMetricCollector CollectorKind = "prometheusMetricCollector"
CustomCollector CollectorKind = "customCollector"
// When model training source code persists metrics into persistent layer
// directly, metricsCollector isn't in need, and its kind is "noneCollector"
NoneCollector CollectorKind = "noneCollector"
)

type CollectorSpec struct {
Kind CollectorKind `json:"kind"`
// When kind is "customCollector", this field will be used
CustomCollector *v1.Container `json:"customCollector,omitempty"`
}

func init() {
Expand Down
100 changes: 100 additions & 0 deletions pkg/api/operators/apis/experiment/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/api/operators/apis/trial/v1alpha2/trial_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ type TrialSpec struct {
RetainRun bool `json:"retainRun,omitempty"`

// Raw text for the metrics collector spec. This must be a CronJob object.
// Deprecated
MetricsCollectorSpec string `json:"metricsCollectorSpec,omitempty"`
// Whether to retain the trial metrics collector CronJob object after completed.
// Deprecated
RetainMetricsCollector bool `json:"retainMetricsCollector,omitempty"`
}

Expand Down

0 comments on commit de96a52

Please sign in to comment.