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

Add Model Management API #48

Merged
merged 4 commits into from
Apr 18, 2018
Merged

Conversation

YujiOshima
Copy link
Contributor

Close #43
Add Model Management API. Katib will provide store, update Model Info in ModelDB.

Signed-off-by: YujiOshima <[email protected]>
Signed-off-by: YujiOshima <[email protected]>
@gaocegege
Copy link
Member

/cc @gaocegege @ddysher

@YujiOshima
Copy link
Contributor Author

@gaocegege
I tried to add Cli for Model management, but the katib-cli code is unrefined.
So I want to merge this PR without cli. Then we will introduce cobra to cli and add Model management command.
WDYT?

I worry about this PR is too big to review.
You can ignore 1st commit (only for vendor pkg) and manager/modelstore_interface/modeldb/ dir.
The files in this dir are generated by Thrift.
Please look

  • api.proto update
  • manager/modelstore_interface/modelstore_interface.go
  • manager/modelstore_interface/modeldb.go.

@YujiOshima YujiOshima changed the title [WIP] Add Model Management API Add Model Management API Apr 17, 2018
Copy link
Member

@gaocegege gaocegege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM. I agree that we could change the code iteratively and no need to implement cli in this PR.

manager/main.go Outdated
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"

pb "github.com/kubeflow/hp-tuning/api"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we group the deps in order?

e.g.

built-in dep

third party

github.com/kubeflow/hp-tuning

manager/main.go Outdated
@@ -109,6 +68,7 @@ func (s *server) trialIteration(conf *pb.StudyConfig, study_id string, sCh study
ei = defaultEarlyStopInterval
}
estm := time.NewTimer(time.Duration(ei) * time.Second)
strtm := time.NewTimer(time.Duration(30) * time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we define 30 as a constant.

}

func (m *ModelDBInterface) GetStoredModel(in *api.GetStoredModelRequest) (*api.ModelInfo, error) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the new line here.

return nil
}

//func main() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove the function if it is not used?

@@ -0,0 +1,13 @@
package modelstore_interface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could name it as interface and name the package modelstore_interface to modelstore, WDYT

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

manager/modelstore_interface/modelstore_interface.go -> manager/modelstore/interface.go

@@ -10,7 +10,7 @@ import (
dclient "github.com/docker/docker/client"
"github.com/kubeflow/hp-tuning/api"
"github.com/kubeflow/hp-tuning/db"
"github.com/kubeflow/hp-tuning/manager/modeldb"
// "github.com/kubeflow/hp-tuning/manager/modeldb"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove the dep?

et, _ := time.Parse(time.RFC3339, t.EvalLogs[len(t.EvalLogs)-1].Time)
mr.Metrics["time-cost-Min"] = et.Sub(st).Minutes()
mif.SendReq(mr)
// mif := modeldb.ModelDbIF{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove the code directly?

Signed-off-by: YujiOshima <[email protected]>
@YujiOshima
Copy link
Contributor Author

YujiOshima commented Apr 18, 2018

@gaocegege Thank you for the review!
I updated it.

Copy link
Member

@gaocegege gaocegege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, only nits.

manager/main.go Outdated
@@ -154,7 +153,7 @@ func (s *server) trialIteration(conf *pb.StudyConfig, study_id string, sCh study
}
}
}
strtm.Reset(30 * time.Second)
strtm.Reset(time.Duration(defaultStoreInterval) * time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use defaultStoreInterval directly here.

Signed-off-by: YujiOshima <[email protected]>
@gaocegege
Copy link
Member

/lgtm

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gaocegege

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gaocegege
Copy link
Member

Thanks for your great work haha

@k8s-ci-robot k8s-ci-robot merged commit 3ca2df0 into kubeflow:master Apr 18, 2018
@@ -12,6 +12,11 @@ service Manager {
rpc GetObjectValue(GetObjectValueRequest) returns (GetObjectValueReply);
rpc AddMeasurementToTrials(AddMeasurementToTrialsRequest) returns (AddMeasurementToTrialsReply);
rpc InitializeSuggestService(InitializeSuggestServiceRequest) returns(InitializeSuggestServiceReply);
rpc StoreStudy(StoreStudyRequest) returns(StoreStudyReply);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we change Store to Save, i.e. SaveStudy, SaveModel, GetSavedStudies, GetSavedModels, etc.

IMO, word store is mostly used as a noun (e.g. StoreInterface),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@@ -214,6 +219,65 @@ message AddMeasurementToTrialsRequest {
message AddMeasurementToTrialsReply {
}

message StudyOverView {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/OverView/Overview?

@@ -214,6 +219,65 @@ message AddMeasurementToTrialsRequest {
message AddMeasurementToTrialsReply {
}

message StudyOverView {
string name = 1;
string author = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

author or owner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will unify owner.

}

message DataSetInfo {
string Name = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this capitalized while others are not?

@@ -12,6 +12,11 @@ service Manager {
rpc GetObjectValue(GetObjectValueRequest) returns (GetObjectValueReply);
rpc AddMeasurementToTrials(AddMeasurementToTrialsRequest) returns (AddMeasurementToTrialsReply);
rpc InitializeSuggestService(InitializeSuggestServiceRequest) returns(InitializeSuggestServiceReply);
rpc StoreStudy(StoreStudyRequest) returns(StoreStudyReply);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little confused here, why do we need to add StoreStudy API here if the PR is about model management API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModelDB has two concepts, Project and Model.
You need to create a Project before to save Models.

A Study in Katib is mapped to a Project.
A Trial in Katib is mapped to a Model.

isin := false
for _, m := range ret.Models {
if m.TrialId == tid {
isin = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we break early here, since you already set isin to true, there is no need to loop through all models.

BTW, what is the mapping between model and trail, is it 1:1 mapping?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the model is 1:1 mapping to a trial.
The trial is a set of hyperparameters.

}
}
met := make([]*pb.Metrics, len(conf.Metrics))
for i, mn := range conf.Metrics {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not put this into isin if block? if isin is false, then operation here is basically no-op.

@@ -0,0 +1,13 @@
package modelstore_interface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

manager/modelstore_interface/modelstore_interface.go -> manager/modelstore/interface.go

return &ModelDBInterface{host: host, port: port}
}

func (m *ModelDBInterface) createSocket() (thrift.TTransport, *modeldb.ModelDBServiceClient, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does model db only supports thrift? Maintaining two messaging format sounds like a painful task ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, ModelDB is only supporting Thrift..


}

func (m *ModelDBInterface) StoreModel(in *api.StoreModelRequest) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add documentation for exported methods :)

@ddysher
Copy link
Member

ddysher commented Apr 18, 2018

@YujiOshima @gaocegege looks like there's a race condition :)

Can you take a look at the comments even though it's merged?

@YujiOshima
Copy link
Contributor Author

@ddysher Thank you for comment.
I will open a new PR for refactoring this PR.

@YujiOshima YujiOshima deleted the modelstoreapi branch April 24, 2018 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants