-
Notifications
You must be signed in to change notification settings - Fork 459
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
v1alpha2 api server implementation #456
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
20418f6
add v1-alpha2 api server implementation
YujiOshima d431c1e
add test
YujiOshima 880f4dc
add filter argument to GetTrialList
YujiOshima c064839
rename filter to filter_by_name
YujiOshima 0a1ea5e
revert filter_by_name to filter
YujiOshima File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package main | |
|
||
import ( | ||
"context" | ||
"errors" | ||
"flag" | ||
"log" | ||
"net" | ||
|
@@ -24,93 +25,142 @@ type server struct { | |
} | ||
|
||
// Register a Experiment to DB. | ||
func (s *server) RegisterExperiment(context.Context, *api_pb.RegisterExperimentRequest) (*api_pb.RegisterExperimentReply, error) { | ||
return nil, nil | ||
func (s *server) RegisterExperiment(ctx context.Context, in *api_pb.RegisterExperimentRequest) (*api_pb.RegisterExperimentReply, error) { | ||
err := dbIf.RegisterExperiment(in.Experiment) | ||
return &api_pb.RegisterExperimentReply{}, err | ||
} | ||
|
||
// Delete a Experiment from DB by name. | ||
func (s *server) DeleteExperiment(context.Context, *api_pb.DeleteExperimentRequest) (*api_pb.DeleteExperimentReply, error) { | ||
return nil, nil | ||
func (s *server) DeleteExperiment(ctx context.Context, in *api_pb.DeleteExperimentRequest) (*api_pb.DeleteExperimentReply, error) { | ||
err := dbIf.DeleteExperiment(in.ExperimentName) | ||
return &api_pb.DeleteExperimentReply{}, err | ||
} | ||
|
||
// Get a Experiment from DB by name. | ||
func (s *server) GetExperiment(context.Context, *api_pb.GetExperimentRequest) (*api_pb.GetExperimentReply, error) { | ||
return nil, nil | ||
func (s *server) GetExperiment(ctx context.Context, in *api_pb.GetExperimentRequest) (*api_pb.GetExperimentReply, error) { | ||
exp, err := dbIf.GetExperiment(in.ExperimentName) | ||
return &api_pb.GetExperimentReply{ | ||
Experiment: exp, | ||
}, err | ||
} | ||
|
||
// Get a summary list of Experiment from DB. | ||
// The summary includes name and condition. | ||
func (s *server) GetExperimentList(context.Context, *api_pb.GetExperimentListRequest) (*api_pb.GetExperimentListReply, error) { | ||
return nil, nil | ||
func (s *server) GetExperimentList(ctx context.Context, in *api_pb.GetExperimentListRequest) (*api_pb.GetExperimentListReply, error) { | ||
expList, err := dbIf.GetExperimentList() | ||
return &api_pb.GetExperimentListReply{ | ||
ExperimentSummaries: expList, | ||
}, err | ||
} | ||
|
||
// Update Status of a experiment. | ||
func (s *server) UpdateExperimentStatus(context.Context, *api_pb.UpdateExperimentStatusRequest) (*api_pb.UpdateExperimentStatusReply, error) { | ||
return nil, nil | ||
func (s *server) UpdateExperimentStatus(ctx context.Context, in *api_pb.UpdateExperimentStatusRequest) (*api_pb.UpdateExperimentStatusReply, error) { | ||
err := dbIf.UpdateExperimentStatus(in.ExperimentName, in.NewStatus) | ||
return &api_pb.UpdateExperimentStatusReply{}, err | ||
} | ||
|
||
// Update AlgorithmExtraSettings. | ||
// The ExtraSetting is created if it does not exist, otherwise it is overwrited. | ||
func (s *server) UpdateAlgorithmExtraSettings(context.Context, *api_pb.UpdateAlgorithmExtraSettingsRequest) (*api_pb.UpdateAlgorithmExtraSettingsReply, error) { | ||
return nil, nil | ||
func (s *server) UpdateAlgorithmExtraSettings(ctx context.Context, in *api_pb.UpdateAlgorithmExtraSettingsRequest) (*api_pb.UpdateAlgorithmExtraSettingsReply, error) { | ||
err := dbIf.UpdateAlgorithmExtraSettings(in.ExperimentName, in.ExtraAlgorithmSettings) | ||
return &api_pb.UpdateAlgorithmExtraSettingsReply{}, err | ||
} | ||
|
||
// Get all AlgorithmExtraSettings. | ||
func (s *server) GetAlgorithmExtraSettings(context.Context, *api_pb.GetAlgorithmExtraSettingsRequest) (*api_pb.GetAlgorithmExtraSettingsReply, error) { | ||
return nil, nil | ||
func (s *server) GetAlgorithmExtraSettings(ctx context.Context, in *api_pb.GetAlgorithmExtraSettingsRequest) (*api_pb.GetAlgorithmExtraSettingsReply, error) { | ||
eas, err := dbIf.GetAlgorithmExtraSettings(in.ExperimentName) | ||
return &api_pb.GetAlgorithmExtraSettingsReply{ | ||
ExtraAlgorithmSettings: eas, | ||
}, err | ||
} | ||
|
||
// Register a Trial to DB. | ||
// ID will be filled by manager automatically. | ||
func (s *server) RegisterTrial(context.Context, *api_pb.RegisterTrialRequest) (*api_pb.RegisterTrialReply, error) { | ||
return nil, nil | ||
func (s *server) RegisterTrial(ctx context.Context, in *api_pb.RegisterTrialRequest) (*api_pb.RegisterTrialReply, error) { | ||
err := dbIf.RegisterTrial(in.Trial) | ||
return &api_pb.RegisterTrialReply{}, err | ||
} | ||
|
||
// Delete a Trial from DB by ID. | ||
func (s *server) DeleteTrial(context.Context, *api_pb.DeleteTrialRequest) (*api_pb.DeleteTrialReply, error) { | ||
return nil, nil | ||
func (s *server) DeleteTrial(ctx context.Context, in *api_pb.DeleteTrialRequest) (*api_pb.DeleteTrialReply, error) { | ||
err := dbIf.DeleteTrial(in.TrialName) | ||
return &api_pb.DeleteTrialReply{}, err | ||
} | ||
|
||
// Get a list of Trial from DB by name of a Experiment. | ||
func (s *server) GetTrialList(context.Context, *api_pb.GetTrialListRequest) (*api_pb.GetTrialListReply, error) { | ||
return nil, nil | ||
func (s *server) GetTrialList(ctx context.Context, in *api_pb.GetTrialListRequest) (*api_pb.GetTrialListReply, error) { | ||
trList, err := dbIf.GetTrialList(in.ExperimentName) | ||
return &api_pb.GetTrialListReply{ | ||
Trials: trList, | ||
}, err | ||
} | ||
|
||
// Get a Trial from DB by ID of Trial. | ||
func (s *server) GetTrial(context.Context, *api_pb.GetTrialRequest) (*api_pb.GetTrialReply, error) { | ||
return nil, nil | ||
func (s *server) GetTrial(ctx context.Context, in *api_pb.GetTrialRequest) (*api_pb.GetTrialReply, error) { | ||
tr, err := dbIf.GetTrial(in.TrialName) | ||
return &api_pb.GetTrialReply{ | ||
Trial: tr, | ||
}, err | ||
} | ||
|
||
// Update Status of a trial. | ||
func (s *server) UpdateTrialStatus(context.Context, *api_pb.UpdateTrialStatusRequest) (*api_pb.UpdateTrialStatusReply, error) { | ||
return nil, nil | ||
func (s *server) UpdateTrialStatus(ctx context.Context, in *api_pb.UpdateTrialStatusRequest) (*api_pb.UpdateTrialStatusReply, error) { | ||
err := dbIf.UpdateTrialStatus(in.TrialName, in.NewStatus) | ||
return &api_pb.UpdateTrialStatusReply{}, err | ||
} | ||
|
||
// Report a log of Observations for a Trial. | ||
// The log consists of timestamp and value of metric. | ||
// Katib store every log of metrics. | ||
// You can see accuracy curve or other metric logs on UI. | ||
func (s *server) ReportObservationLog(context.Context, *api_pb.ReportObservationLogRequest) (*api_pb.ReportObservationLogReply, error) { | ||
return nil, nil | ||
func (s *server) ReportObservationLog(ctx context.Context, in *api_pb.ReportObservationLogRequest) (*api_pb.ReportObservationLogReply, error) { | ||
err := dbIf.RegisterObservationLog(in.TrialName, in.ObservationLog) | ||
return &api_pb.ReportObservationLogReply{}, err | ||
} | ||
|
||
// Get all log of Observations for a Trial. | ||
func (s *server) GetObservationLog(context.Context, *api_pb.GetObservationLogRequest) (*api_pb.GetObservationLogReply, error) { | ||
return nil, nil | ||
func (s *server) GetObservationLog(ctx context.Context, in *api_pb.GetObservationLogRequest) (*api_pb.GetObservationLogReply, error) { | ||
ol, err := dbIf.GetObservationLog(in.TrialName, in.StartTime, in.EndTime) | ||
return &api_pb.GetObservationLogReply{ | ||
ObservationLog: ol, | ||
}, err | ||
} | ||
|
||
// Get Suggestions from a Suggestion service. | ||
func (s *server) GetSuggestions(context.Context, *api_pb.GetSuggestionsRequest) (*api_pb.GetSuggestionsReply, error) { | ||
return nil, nil | ||
func (s *server) GetSuggestions(ctx context.Context, in *api_pb.GetSuggestionsRequest) (*api_pb.GetSuggestionsReply, error) { | ||
if in.AlgorithmName == "" { | ||
return &api_pb.GetSuggestionsReply{Trials: []*api_pb.Trial{}}, errors.New("No algorithm name is specified") | ||
} | ||
conn, err := grpc.Dial("vizier-suggestion-"+in.AlgorithmName+":6789", grpc.WithInsecure()) | ||
if err != nil { | ||
return &api_pb.GetSuggestionsReply{Trials: []*api_pb.Trial{}}, err | ||
} | ||
|
||
defer conn.Close() | ||
c := api_pb.NewSuggestionClient(conn) | ||
r, err := c.GetSuggestions(ctx, in) | ||
if err != nil { | ||
return &api_pb.GetSuggestionsReply{Trials: []*api_pb.Trial{}}, err | ||
} | ||
return r, nil | ||
} | ||
|
||
// Validate AlgorithmSettings in an Experiment. | ||
// Suggestion service should return INVALID_ARGUMENT Error when the parameter is invalid | ||
func (s *server) ValidateAlgorithmSettings(context.Context, *api_pb.ValidateAlgorithmSettingsRequest) (*api_pb.ValidateAlgorithmSettingsReply, error) { | ||
return nil, nil | ||
func (s *server) ValidateAlgorithmSettings(ctx context.Context, in *api_pb.ValidateAlgorithmSettingsRequest) (*api_pb.ValidateAlgorithmSettingsReply, error) { | ||
if in.AlgorithmName == "" { | ||
return &api_pb.ValidateAlgorithmSettingsReply{}, errors.New("No algorithm name is specified") | ||
} | ||
conn, err := grpc.Dial("vizier-suggestion-"+in.AlgorithmName+":6789", grpc.WithInsecure()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add a function like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if err != nil { | ||
return &api_pb.ValidateAlgorithmSettingsReply{}, err | ||
} | ||
defer conn.Close() | ||
c := api_pb.NewSuggestionClient(conn) | ||
return c.ValidateAlgorithmSettings(ctx, in) | ||
} | ||
|
||
func (s *server) Check(context.Context, *health_pb.HealthCheckRequest) (*health_pb.HealthCheckResponse, error) { | ||
func (s *server) Check(ctx context.Context, in *health_pb.HealthCheckRequest) (*health_pb.HealthCheckResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question: should we still use vizier-* names internally or should we start renaming them to katib? See #136.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think, we should start renaming to katib. i had renamed studyjobcontroller to katib-controller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree. I will change them.