diff --git a/master/internal/db/postgres_trial.go b/master/internal/db/postgres_trial.go index 8810783a920..6602a344cfb 100644 --- a/master/internal/db/postgres_trial.go +++ b/master/internal/db/postgres_trial.go @@ -2,6 +2,7 @@ package db import ( "context" + "encoding/json" "fmt" "math" "regexp" @@ -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)