Skip to content

Commit cb456dd

Browse files
committed
review: change api for new feature
1 parent 26f04ef commit cb456dd

File tree

15 files changed

+63
-63
lines changed

15 files changed

+63
-63
lines changed

cmd/metricscollector/v1beta1/file-metricscollector/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func printMetricsFile(mFile string) {
140140
}
141141
}
142142

143-
func watchMetricsFile(mFile string, stopRules stopRulesFlag, filters []string, fileFormat commonv1beta1.FileSystemFileFormat) {
143+
func watchMetricsFile(mFile string, stopRules stopRulesFlag, filters []string, fileFormat commonv1beta1.FileFormat) {
144144

145145
// metricStartStep is the dict where key = metric name, value = start step.
146146
// We should apply early stopping rule only if metric is reported at least "start_step" times.
@@ -398,7 +398,7 @@ func main() {
398398
filters = strings.Split(*metricFilters, ";")
399399
}
400400

401-
fileFormat := commonv1beta1.FileSystemFileFormat(*metricsFileFormat)
401+
fileFormat := commonv1beta1.FileFormat(*metricsFileFormat)
402402

403403
// If stop rule is set we need to parse metrics during run.
404404
if len(stopRules) != 0 {
@@ -425,7 +425,7 @@ func main() {
425425
}
426426
}
427427

428-
func reportMetrics(filters []string, fileFormat commonv1beta1.FileSystemFileFormat) {
428+
func reportMetrics(filters []string, fileFormat commonv1beta1.FileFormat) {
429429

430430
conn, err := grpc.Dial(*dbManagerServiceAddr, grpc.WithInsecure())
431431
if err != nil {

examples/v1beta1/early-stopping/median-stop-with-json-format.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
fileSystemPath:
1818
path: "/katib/mnist.json"
1919
kind: File
20-
fileFormat: JSON
20+
format: JSON
2121
collector:
2222
kind: File
2323
algorithm:

examples/v1beta1/metrics-collector/file-metrics-collector-with-json-format.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
fileSystemPath:
1616
path: "/katib/mnist.json"
1717
kind: File
18-
fileFormat: JSON
18+
format: JSON
1919
collector:
2020
kind: File
2121
algorithm:

pkg/apis/controller/common/v1beta1/common_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,18 @@ const (
188188
InvalidKind FileSystemKind = "Invalid"
189189
)
190190

191-
type FileSystemFileFormat string
191+
type FileFormat string
192192

193193
const (
194-
TextFormat FileSystemFileFormat = "TEXT"
195-
JsonFormat FileSystemFileFormat = "JSON"
194+
TextFormat FileFormat = "TEXT"
195+
JsonFormat FileFormat = "JSON"
196196
)
197197

198198
// +k8s:deepcopy-gen=true
199199
type FileSystemPath struct {
200-
Path string `json:"path,omitempty"`
201-
Kind FileSystemKind `json:"kind,omitempty"`
202-
FileFormat FileSystemFileFormat `json:"fileFormat,omitempty"`
200+
Path string `json:"path,omitempty"`
201+
Kind FileSystemKind `json:"kind,omitempty"`
202+
Format FileFormat `json:"format,omitempty"`
203203
}
204204

205205
type CollectorKind string

pkg/apis/controller/experiments/v1beta1/experiment_defaults.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ func (e *Experiment) setDefaultMetricsCollector() {
158158
if e.Spec.MetricsCollectorSpec.Source.FileSystemPath.Path == "" {
159159
e.Spec.MetricsCollectorSpec.Source.FileSystemPath.Path = common.DefaultFilePath
160160
}
161-
if e.Spec.MetricsCollectorSpec.Source.FileSystemPath.FileFormat == "" {
162-
e.Spec.MetricsCollectorSpec.Source.FileSystemPath.FileFormat = common.TextFormat
161+
if e.Spec.MetricsCollectorSpec.Source.FileSystemPath.Format == "" {
162+
e.Spec.MetricsCollectorSpec.Source.FileSystemPath.Format = common.TextFormat
163163
}
164164
case common.TfEventCollector:
165165
if e.Spec.MetricsCollectorSpec.Source == nil {

pkg/apis/v1beta1/openapi_generated.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/v1beta1/swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@
779779
"v1beta1.FileSystemPath": {
780780
"type": "object",
781781
"properties": {
782-
"fileFormat": {
782+
"format": {
783783
"type": "string"
784784
},
785785
"kind": {

pkg/metricscollector/v1beta1/file-metricscollector/file-metricscollector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"github.com/kubeflow/katib/pkg/metricscollector/v1beta1/common"
3535
)
3636

37-
func CollectObservationLog(fileName string, metrics []string, filters []string, fileFormat commonv1beta1.FileSystemFileFormat) (*v1beta1.ObservationLog, error) {
37+
func CollectObservationLog(fileName string, metrics []string, filters []string, fileFormat commonv1beta1.FileFormat) (*v1beta1.ObservationLog, error) {
3838
file, err := os.Open(fileName)
3939
if err != nil {
4040
return nil, err

pkg/metricscollector/v1beta1/file-metricscollector/file-metricscollector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestCollectObservationLog(t *testing.T) {
4444
filePath string
4545
metrics []string
4646
filters []string
47-
fileFormat commonv1beta1.FileSystemFileFormat
47+
fileFormat commonv1beta1.FileFormat
4848
err bool
4949
expected *v1beta1.ObservationLog
5050
}{

pkg/webhook/v1beta1/experiment/validator/validator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,10 @@ func (g *DefaultValidator) validateMetricsCollector(inst *experimentsv1beta1.Exp
428428
mcSpec.Source.FileSystemPath.Kind != commonapiv1beta1.FileKind || !filepath.IsAbs(mcSpec.Source.FileSystemPath.Path) {
429429
return fmt.Errorf("file path where metrics file exists is required by .spec.metricsCollectorSpec.source.fileSystemPath.path")
430430
}
431-
// FileSystemFileFormat
432-
fileFormat := mcSpec.Source.FileSystemPath.FileFormat
431+
// Format
432+
fileFormat := mcSpec.Source.FileSystemPath.Format
433433
if fileFormat != commonapiv1beta1.TextFormat && fileFormat != commonapiv1beta1.JsonFormat {
434-
return fmt.Errorf("format of metrics file is required by .spec.metricsCollectorSpec.source.fileSystemPath.fileFormat")
434+
return fmt.Errorf("format of metrics file is required by .spec.metricsCollectorSpec.source.fileSystemPath.format")
435435
}
436436
if fileFormat == commonapiv1beta1.JsonFormat && mcSpec.Source.Filter != nil {
437437
return fmt.Errorf(".spec.metricsCollectorSpec.source.filter must be nil when format of metrics file is %v", commonapiv1beta1.JsonFormat)
@@ -441,8 +441,8 @@ func (g *DefaultValidator) validateMetricsCollector(inst *experimentsv1beta1.Exp
441441
mcSpec.Source.FileSystemPath.Kind != commonapiv1beta1.DirectoryKind || !filepath.IsAbs(mcSpec.Source.FileSystemPath.Path) {
442442
return fmt.Errorf("directory path where tensorflow event files exist is required by .spec.metricsCollectorSpec.source.fileSystemPath.path")
443443
}
444-
if mcSpec.Source.FileSystemPath.FileFormat != "" {
445-
return fmt.Errorf(".spec.metricsCollectorSpec.source.fileSystemPath.fileFormat must be empty")
444+
if mcSpec.Source.FileSystemPath.Format != "" {
445+
return fmt.Errorf(".spec.metricsCollectorSpec.source.fileSystemPath.format must be empty")
446446
}
447447
case commonapiv1beta1.PrometheusMetricCollector:
448448
i, err := strconv.Atoi(mcSpec.Source.HttpGet.Port.String())

0 commit comments

Comments
 (0)