Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New UI for Katib #208

Merged
merged 16 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
283 changes: 250 additions & 33 deletions Gopkg.lock

Large diffs are not rendered by default.

38 changes: 29 additions & 9 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ func (s *server) UpdateWorkerState(ctx context.Context, in *pb.UpdateWorkerState
return &pb.UpdateWorkerStateReply{}, err
}

func (s *server) GetWorkerFullInfo(ctx context.Context, in *pb.GetWorkerFullInfoRequest) (*pb.GetWorkerFullInfoReply, error) {
return dbIf.GetWorkerFullInfo(in.StudyId, in.TrialId, in.WorkerId, in.OnlyLatestLog)
}
func (s *server) SetSuggestionParameters(ctx context.Context, in *pb.SetSuggestionParametersRequest) (*pb.SetSuggestionParametersReply, error) {
var err error
var id string
Expand Down Expand Up @@ -238,31 +241,48 @@ func (s *server) GetEarlyStoppingParameterList(ctx context.Context, in *pb.GetEa
}

func (s *server) SaveStudy(ctx context.Context, in *pb.SaveStudyRequest) (*pb.SaveStudyReply, error) {
err := s.msIf.SaveStudy(in)
var err error
if s.msIf != nil {
err = s.msIf.SaveStudy(in)
}
return &pb.SaveStudyReply{}, err
}

func (s *server) SaveModel(ctx context.Context, in *pb.SaveModelRequest) (*pb.SaveModelReply, error) {
err := s.msIf.SaveModel(in)
if err != nil {
log.Printf("Save Model failed %v", err)
return &pb.SaveModelReply{}, err
if s.msIf != nil {
err := s.msIf.SaveModel(in)
if err != nil {
log.Printf("Save Model failed %v", err)
return &pb.SaveModelReply{}, err
}
}
return &pb.SaveModelReply{}, nil
}

func (s *server) GetSavedStudies(ctx context.Context, in *pb.GetSavedStudiesRequest) (*pb.GetSavedStudiesReply, error) {
ret, err := s.msIf.GetSavedStudies()
ret := []*pb.StudyOverview{}
var err error
if s.msIf != nil {
ret, err = s.msIf.GetSavedStudies()
}
return &pb.GetSavedStudiesReply{Studies: ret}, err
}

func (s *server) GetSavedModels(ctx context.Context, in *pb.GetSavedModelsRequest) (*pb.GetSavedModelsReply, error) {
ret, err := s.msIf.GetSavedModels(in)
ret := []*pb.ModelInfo{}
var err error
if s.msIf != nil {
ret, err = s.msIf.GetSavedModels(in)
}
return &pb.GetSavedModelsReply{Models: ret}, err
}

func (s *server) GetSavedModel(ctx context.Context, in *pb.GetSavedModelRequest) (*pb.GetSavedModelReply, error) {
ret, err := s.msIf.GetSavedModel(in)
var ret *pb.ModelInfo = nil
var err error
if s.msIf != nil {
ret, err = s.msIf.GetSavedModel(in)
}
return &pb.GetSavedModelReply{Model: ret}, err
}

Expand All @@ -278,7 +298,7 @@ func main() {
size := 1<<31 - 1
log.Printf("Start Katib manager: %s", port)
s := grpc.NewServer(grpc.MaxRecvMsgSize(size), grpc.MaxSendMsgSize(size))
pb.RegisterManagerServer(s, &server{msIf: modelstore.NewModelDB("modeldb-backend", "6543")})
pb.RegisterManagerServer(s, &server{})
reflection.Register(s)
if err = s.Serve(listener); err != nil {
log.Fatalf("Failed to serve: %v", err)
Expand Down
12 changes: 12 additions & 0 deletions cmd/ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:alpine AS build-env
# The GOPATH in the image is /go.
ADD . /go/src/github.com/kubeflow/katib
WORKDIR /go/src/github.com/kubeflow/katib/cmd/ui
RUN go build -o katib-ui

FROM alpine:3.7
WORKDIR /app
COPY --from=build-env /go/src/github.com/kubeflow/katib/cmd/ui/katib-ui /app/
COPY cmd/ui/static /static
COPY cmd/ui/template /template
ENTRYPOINT ["./katib-ui"]
33 changes: 33 additions & 0 deletions cmd/ui/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"github.com/kubeflow/katib/pkg/ui"
"github.com/pressly/chi"
"net/http"
)

func main() {
r := chi.NewRouter()
kuh := ui.NewKatibUIHandler()
r.Route("/", func(r chi.Router) {
r.Get("/", func(writer http.ResponseWriter, req *http.Request) {
http.Redirect(writer, req, "/katib", http.StatusMovedPermanently)
})
r.Handle("/static/*", http.StripPrefix("/static/", http.FileServer(http.Dir("/static"))))
r.Route("/katib", func(r chi.Router) {
r.Get("/", kuh.Index)
r.Route("/{studyid}", func(r chi.Router) {
r.Get("/", kuh.Study)
r.Get("/csv", kuh.StudyInfoCsv)
r.Route("/TrialID/{trialid}", func(r chi.Router) {
r.Get("/", kuh.Trial)
})
r.Route("/WorkerID/{workerid}", func(r chi.Router) {
r.Get("/", kuh.Worker)
r.Get("/csv", kuh.WorkerInfoCsv)
})
})
})
})
http.ListenAndServe(":80", r)
}
Loading