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

fix: convert invalid hparam types to json string #9449

Merged
merged 5 commits into from
Jun 5, 2024
Merged
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
12 changes: 10 additions & 2 deletions master/internal/db/postgres_trial.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package db

import (
"context"
"encoding/json"
"fmt"
"math"
"regexp"
Expand Down Expand Up @@ -151,13 +152,20 @@ func BuildRunHParams(runID int, projectID int, hparams map[string]any,
case map[string]any:
nestedHParams, nestedProjHparams, err := BuildRunHParams(runID, projectID, v.(map[string]any), hpName+".")
if err != nil {
return hparamsModel, projHparamsModel, fmt.Errorf("failed to get nested hyperperameters for %s", hpName)
return hparamsModel, projHparamsModel, fmt.Errorf("failed to get nested hyperperameters for %s: %w", hpName, err)
}
hparamsModel = append(hparamsModel, nestedHParams...)
projHparamsModel = append(projHparamsModel, nestedProjHparams...)
continue
default:
return hparamsModel, projHparamsModel, fmt.Errorf("cannot assign hyperparameter %s, received type %T", hpName, val)
valBytes, err := json.Marshal(v)
if err != nil {
return hparamsModel, projHparamsModel,
fmt.Errorf("cannot assign hyperparameter %s, failed to encode type %T: %w", hpName, val, err)
}
valString := string(valBytes)
hp.TextVal = &valString
projHp.Type = MetricTypeString
}
hparamsModel = append(hparamsModel, hp)
projHparamsModel = append(projHparamsModel, projHp)
Expand Down
Loading