Skip to content

Commit

Permalink
Used klog for katib. (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyliu513 authored and k8s-ci-robot committed May 17, 2019
1 parent d22f8e6 commit ad8fe2b
Show file tree
Hide file tree
Showing 28 changed files with 338 additions and 339 deletions.
8 changes: 4 additions & 4 deletions cmd/earlystopping/medianstopping/v1alpha1/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import (
"log"
"net"

"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"k8s.io/klog"

pb "github.com/kubeflow/katib/pkg/api/v1alpha1"
earlystopping "github.com/kubeflow/katib/pkg/earlystopping/v1alpha1"
Expand All @@ -14,14 +14,14 @@ import (
func main() {
listener, err := net.Listen("tcp", earlystopping.DefaultPort)
if err != nil {
log.Fatalf("Failed to listen: %v", err)
klog.Fatalf("Failed to listen: %v", err)
}
size := 1<<31 - 1
s := grpc.NewServer(grpc.MaxRecvMsgSize(size), grpc.MaxSendMsgSize(size))
pb.RegisterEarlyStoppingServer(s, earlystopping.NewMedianStoppingRule())
reflection.Register(s)
log.Printf("Median Stopping Rule EarlyStopping Service\n")
klog.Info("Median Stopping Rule EarlyStopping Service")
if err = s.Serve(listener); err != nil {
log.Fatalf("Failed to serve: %v", err)
klog.Fatalf("Failed to serve: %v", err)
}
}
24 changes: 12 additions & 12 deletions cmd/katib-controller/v1alpha1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ limitations under the License.
package main

import (
"log"
"k8s.io/klog"

"github.com/kubeflow/katib/pkg/api/operators/apis"
controller "github.com/kubeflow/katib/pkg/controller/v1alpha1"
Expand All @@ -37,33 +37,33 @@ func main() {
// Get a config to talk to the apiserver
cfg, err := config.GetConfig()
if err != nil {
log.Printf("config.GetConfig()")
log.Fatal(err)
klog.Info("config.GetConfig()")
klog.Fatal(err)
}

// Create a new StudyJobController to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{})
if err != nil {
log.Printf("manager.New")
log.Fatal(err)
klog.Info("manager.New")
klog.Fatal(err)
}

log.Printf("Registering Components.")
klog.Info("Registering Components.")

// Setup Scheme for all resources
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
log.Printf("apis.AddToScheme")
log.Fatal(err)
klog.Info("apis.AddToScheme")
klog.Fatal(err)
}

// Setup StudyJobController
if err := controller.AddToManager(mgr); err != nil {
log.Printf("controller.AddToManager(mgr)")
log.Fatal(err)
klog.Info("controller.AddToManager(mgr)")
klog.Fatal(err)
}

log.Printf("Starting the Cmd.")
klog.Info("Starting the Cmd.")

// Starting the StudyJobController
log.Fatal(mgr.Start(signals.SetupSignalHandler()))
klog.Fatal(mgr.Start(signals.SetupSignalHandler()))
}
3 changes: 0 additions & 3 deletions cmd/katib-controller/v1alpha2/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/*
Copyright 2018 The Kubeflow Authors
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.
Expand Down
6 changes: 3 additions & 3 deletions cmd/manager-rest/v1alpha1/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"flag"
"net/http"

"github.com/golang/glog"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"golang.org/x/net/context"
"google.golang.org/grpc"
"k8s.io/klog"

gw "github.com/kubeflow/katib/pkg/api/v1alpha1"
)
Expand Down Expand Up @@ -35,9 +35,9 @@ func run() error {

func main() {
flag.Parse()
defer glog.Flush()
defer klog.Flush()

if err := run(); err != nil {
glog.Fatal(err)
klog.Fatal(err)
}
}
6 changes: 3 additions & 3 deletions cmd/manager-rest/v1alpha2/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"flag"
"net/http"

"github.com/golang/glog"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"golang.org/x/net/context"
"google.golang.org/grpc"
"k8s.io/klog"

gw "github.com/kubeflow/katib/pkg/api/v1alpha2"
)
Expand Down Expand Up @@ -35,9 +35,9 @@ func run() error {

func main() {
flag.Parse()
defer glog.Flush()
defer klog.Flush()

if err := run(); err != nil {
glog.Fatal(err)
klog.Fatal(err)
}
}
14 changes: 7 additions & 7 deletions cmd/manager/v1alpha1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"errors"
"flag"
"fmt"
"log"
"net"
"time"

api_pb "github.com/kubeflow/katib/pkg/api/v1alpha1"
health_pb "github.com/kubeflow/katib/pkg/api/health"
api_pb "github.com/kubeflow/katib/pkg/api/v1alpha1"
kdb "github.com/kubeflow/katib/pkg/db/v1alpha1"
"github.com/kubeflow/katib/pkg/manager/modelstore"
"k8s.io/klog"

"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
Expand Down Expand Up @@ -288,7 +288,7 @@ func (s *server) SaveModel(ctx context.Context, in *api_pb.SaveModelRequest) (*a
if s.msIf != nil {
err := s.msIf.SaveModel(in)
if err != nil {
log.Printf("Save Model failed %v", err)
klog.Fatalf("Save Model failed %v", err)
return &api_pb.SaveModelReply{}, err
}
}
Expand Down Expand Up @@ -349,21 +349,21 @@ func main() {

dbIf, err = kdb.New()
if err != nil {
log.Fatalf("Failed to open db connection: %v", err)
klog.Fatalf("Failed to open db connection: %v", err)
}
dbIf.DBInit()
listener, err := net.Listen("tcp", port)
if err != nil {
log.Fatalf("Failed to listen: %v", err)
klog.Fatalf("Failed to listen: %v", err)
}

size := 1<<31 - 1
log.Printf("Start Katib manager: %s", port)
klog.Infof("Start Katib manager: %s", port)
s := grpc.NewServer(grpc.MaxRecvMsgSize(size), grpc.MaxSendMsgSize(size))
api_pb.RegisterManagerServer(s, &server{})
health_pb.RegisterHealthServer(s, &server{})
reflection.Register(s)
if err = s.Serve(listener); err != nil {
log.Fatalf("Failed to serve: %v", err)
klog.Fatalf("Failed to serve: %v", err)
}
}
10 changes: 5 additions & 5 deletions cmd/manager/v1alpha2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"errors"
"flag"
"fmt"
"log"
"net"

health_pb "github.com/kubeflow/katib/pkg/api/health"
api_pb "github.com/kubeflow/katib/pkg/api/v1alpha2"
kdb "github.com/kubeflow/katib/pkg/db/v1alpha2"
"k8s.io/klog"

"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
Expand Down Expand Up @@ -188,21 +188,21 @@ func main() {

dbIf, err = kdb.New()
if err != nil {
log.Fatalf("Failed to open db connection: %v", err)
klog.Fatalf("Failed to open db connection: %v", err)
}
dbIf.DBInit()
listener, err := net.Listen("tcp", port)
if err != nil {
log.Fatalf("Failed to listen: %v", err)
klog.Fatalf("Failed to listen: %v", err)
}

size := 1<<31 - 1
log.Printf("Start Katib manager: %s", port)
klog.Infof("Start Katib manager: %s", port)
s := grpc.NewServer(grpc.MaxRecvMsgSize(size), grpc.MaxSendMsgSize(size))
api_pb.RegisterManagerServer(s, &server{})
health_pb.RegisterHealthServer(s, &server{})
reflection.Register(s)
if err = s.Serve(listener); err != nil {
log.Fatalf("Failed to serve: %v", err)
klog.Fatalf("Failed to serve: %v", err)
}
}
16 changes: 8 additions & 8 deletions cmd/metricscollector/v1alpha1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ package main
import (
"context"
"flag"
"log"

api "github.com/kubeflow/katib/pkg/api/v1alpha1"
"github.com/kubeflow/katib/pkg/manager/v1alpha1/metricscollector"
"k8s.io/klog"

"google.golang.org/grpc"
)
Expand All @@ -57,37 +57,37 @@ var managerSerivce = flag.String("m", "", "Vizier Manager service")

func main() {
flag.Parse()
log.Printf("Study ID: %s, Trial ID: %s, Worker ID: %s, Worker Kind: %s", *studyID, *trialID, *workerID, *workerKind)
klog.Infof("Study ID: %s, Trial ID: %s, Worker ID: %s, Worker Kind: %s", *studyID, *trialID, *workerID, *workerKind)
conn, err := grpc.Dial(*managerSerivce, grpc.WithInsecure())
if err != nil {
log.Fatalf("could not connect: %v", err)
klog.Fatalf("could not connect: %v", err)
}
defer conn.Close()
c := api.NewManagerClient(conn)
mc, err := metricscollector.NewMetricsCollector()
if err != nil {
log.Fatalf("Failed to create MetricsCollector: %v", err)
klog.Fatalf("Failed to create MetricsCollector: %v", err)
}
ctx := context.Background()
screq := &api.GetStudyRequest{
StudyId: *studyID,
}
screp, err := c.GetStudy(ctx, screq)
if err != nil {
log.Fatalf("Failed to GetStudyConf: %v", err)
klog.Fatalf("Failed to GetStudyConf: %v", err)
}
mls, err := mc.CollectWorkerLog(*workerID, *workerKind, screp.StudyConfig.ObjectiveValueName, screp.StudyConfig.Metrics, *namespace)
if err != nil {
log.Fatalf("Failed to collect logs: %v", err)
klog.Fatalf("Failed to collect logs: %v", err)
}
rmreq := &api.ReportMetricsLogsRequest{
StudyId: *studyID,
MetricsLogSets: []*api.MetricsLogSet{mls},
}
_, err = c.ReportMetricsLogs(ctx, rmreq)
if err != nil {
log.Fatalf("Failed to Report logs: %v", err)
klog.Fatalf("Failed to Report logs: %v", err)
}
log.Printf("Metrics reported. :\n%v", mls)
klog.Infof("Metrics reported. :\n%v", mls)
return
}
18 changes: 9 additions & 9 deletions cmd/metricscollector/v1alpha2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ package main
import (
"context"
"flag"
"log"
"strings"

"google.golang.org/grpc"
"k8s.io/klog"

api "github.com/kubeflow/katib/pkg/api/v1alpha2"
"github.com/kubeflow/katib/pkg/util/v1alpha2/metricscollector"

"google.golang.org/grpc"
)

var experimentName = flag.String("e", "", "Experiment Name")
Expand All @@ -58,30 +58,30 @@ var metricNames = flag.String("mn", "", "Metric names")

func main() {
flag.Parse()
log.Printf("Experiment Name: %s, Trial Name: %s, Job Kind: %s", *experimentName, *trialName, *jobKind)
klog.Infof("Experiment Name: %s, Trial Name: %s, Job Kind: %s", *experimentName, *trialName, *jobKind)
conn, err := grpc.Dial(*managerService, grpc.WithInsecure())
if err != nil {
log.Fatalf("could not connect: %v", err)
klog.Fatalf("could not connect: %v", err)
}
defer conn.Close()
c := api.NewManagerClient(conn)
mc, err := metricscollector.NewMetricsCollector()
if err != nil {
log.Fatalf("Failed to create MetricsCollector: %v", err)
klog.Fatalf("Failed to create MetricsCollector: %v", err)
}
ctx := context.Background()
olog, err := mc.CollectObservationLog(*trialName, *jobKind, strings.Split(*metricNames, ";"), *namespace)
if err != nil {
log.Fatalf("Failed to collect logs: %v", err)
klog.Fatalf("Failed to collect logs: %v", err)
}
reportreq := &api.ReportObservationLogRequest{
TrialName: *trialName,
ObservationLog: olog,
}
_, err = c.ReportObservationLog(ctx, reportreq)
if err != nil {
log.Fatalf("Failed to Report logs: %v", err)
klog.Fatalf("Failed to Report logs: %v", err)
}
log.Printf("Metrics reported. :\n%v", olog)
klog.Infof("Metrics reported. :\n%v", olog)
return
}
10 changes: 5 additions & 5 deletions cmd/suggestion/grid/v1alpha1/main.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
package main

import (
"log"
"net"

"google.golang.org/grpc"
"google.golang.org/grpc/reflection"

pb "github.com/kubeflow/katib/pkg/api/v1alpha1"
"github.com/kubeflow/katib/pkg/suggestion/v1alpha1"
suggestion "github.com/kubeflow/katib/pkg/suggestion/v1alpha1"
"k8s.io/klog"
)

func main() {
listener, err := net.Listen("tcp", suggestion.DefaultPort)
if err != nil {
log.Fatalf("Failed to listen: %v", err)
klog.Fatalf("Failed to listen: %v", err)
}
size := 1<<31 - 1
s := grpc.NewServer(grpc.MaxRecvMsgSize(size), grpc.MaxSendMsgSize(size))
pb.RegisterSuggestionServer(s, suggestion.NewGridSuggestService())
reflection.Register(s)
log.Printf("Grid Search Suggestion Service\n")
klog.Info("Grid Search Suggestion Service")
if err = s.Serve(listener); err != nil {
log.Fatalf("Failed to serve: %v", err)
klog.Fatalf("Failed to serve: %v", err)
}
}
Loading

0 comments on commit ad8fe2b

Please sign in to comment.