From c598e69291f91df6185a7682f7b9351f7c0c74d1 Mon Sep 17 00:00:00 2001 From: AmanuelAaron Date: Wed, 29 May 2024 17:39:11 -0400 Subject: [PATCH 1/4] nested error msg --- master/internal/db/postgres_trial.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/internal/db/postgres_trial.go b/master/internal/db/postgres_trial.go index 8810783a920..7843a233766 100644 --- a/master/internal/db/postgres_trial.go +++ b/master/internal/db/postgres_trial.go @@ -151,7 +151,7 @@ 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...) From b472d2f33f8814ee30ad0918c9b9705412fb533b Mon Sep 17 00:00:00 2001 From: AmanuelAaron Date: Tue, 4 Jun 2024 13:53:44 -0400 Subject: [PATCH 2/4] skip invalid types --- master/internal/db/postgres_trial.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/internal/db/postgres_trial.go b/master/internal/db/postgres_trial.go index 7843a233766..4d7a562270f 100644 --- a/master/internal/db/postgres_trial.go +++ b/master/internal/db/postgres_trial.go @@ -157,7 +157,7 @@ func BuildRunHParams(runID int, projectID int, hparams map[string]any, projHparamsModel = append(projHparamsModel, nestedProjHparams...) continue default: - return hparamsModel, projHparamsModel, fmt.Errorf("cannot assign hyperparameter %s, received type %T", hpName, val) + continue } hparamsModel = append(hparamsModel, hp) projHparamsModel = append(projHparamsModel, projHp) From 9df5e92d5c4c1d2d8a5d611fc3ca153a7bac4b3e Mon Sep 17 00:00:00 2001 From: AmanuelAaron Date: Tue, 4 Jun 2024 15:44:16 -0400 Subject: [PATCH 3/4] to string --- master/internal/db/postgres_trial.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/master/internal/db/postgres_trial.go b/master/internal/db/postgres_trial.go index 4d7a562270f..0be1c47968f 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" @@ -157,7 +158,14 @@ func BuildRunHParams(runID int, projectID int, hparams map[string]any, projHparamsModel = append(projHparamsModel, nestedProjHparams...) continue default: - continue + valBytes, err := json.Marshal(v) + if err != nil { + return hparamsModel, projHparamsModel, + fmt.Errorf("cannot assign hyperparameter %s, failed to encode type %T", hpName, val) + } + valString := string(valBytes) + hp.TextVal = &valString + projHp.Type = MetricTypeString } hparamsModel = append(hparamsModel, hp) projHparamsModel = append(projHparamsModel, projHp) From 152405f91569d1ddf1e5f0e9c96e7b90849c217b Mon Sep 17 00:00:00 2001 From: AmanuelAaron Date: Wed, 5 Jun 2024 13:05:27 -0400 Subject: [PATCH 4/4] add json error --- master/internal/db/postgres_trial.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/internal/db/postgres_trial.go b/master/internal/db/postgres_trial.go index 0be1c47968f..6602a344cfb 100644 --- a/master/internal/db/postgres_trial.go +++ b/master/internal/db/postgres_trial.go @@ -161,7 +161,7 @@ func BuildRunHParams(runID int, projectID int, hparams map[string]any, valBytes, err := json.Marshal(v) if err != nil { return hparamsModel, projHparamsModel, - fmt.Errorf("cannot assign hyperparameter %s, failed to encode type %T", hpName, val) + fmt.Errorf("cannot assign hyperparameter %s, failed to encode type %T: %w", hpName, val, err) } valString := string(valBytes) hp.TextVal = &valString