Skip to content

Commit

Permalink
avoid nil pointer
Browse files Browse the repository at this point in the history
Signed-off-by: YujiOshima <yuji.oshima0x3fd@gmail.com>
  • Loading branch information
YujiOshima committed Apr 18, 2018
1 parent 09cfc03 commit b818ac9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ func (s *server) saveCompletedModels(studyId string, conf *pb.StudyConfig) error
met := make([]*pb.Metrics, len(conf.Metrics))
for i, mn := range conf.Metrics {
l, _ := dbIf.GetTrialLogs(tid, &kdb.GetTrialLogOpts{Name: mn})
met[i] = &pb.Metrics{Name: mn, Value: l[len(l)-1].Value}
if len(l) > 0 {
met[i] = &pb.Metrics{Name: mn, Value: l[len(l)-1].Value}
}
}
t, _ := dbIf.GetTrial(tid)
s.SaveModel(context.Background(), &pb.SaveModelRequest{
Expand Down
3 changes: 3 additions & 0 deletions manager/modelstore/modeldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func (m *ModelDB) SaveModel(in *api.SaveModelRequest) error {
}
md.ID = fres.ModelId
for _, met := range in.Model.Metrics {
if met == nil {
continue
}
mv, err := strconv.ParseFloat(met.Value, 64)
if err != nil {
continue
Expand Down

0 comments on commit b818ac9

Please sign in to comment.