From 4b174b6037c4097a01b99ba80d9d488f7b63250c Mon Sep 17 00:00:00 2001 From: tariq-hasan Date: Sun, 7 Apr 2024 16:07:08 -0400 Subject: [PATCH] Reverted cmp to reflect Signed-off-by: tariq-hasan --- pkg/controller.v1beta1/suggestion/composer/composer_test.go | 6 +++--- pkg/suggestion/v1beta1/goptuna/converter.go | 4 ++-- pkg/suggestion/v1beta1/goptuna/sample.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/controller.v1beta1/suggestion/composer/composer_test.go b/pkg/controller.v1beta1/suggestion/composer/composer_test.go index 41b92b6b60f..9de963030fb 100644 --- a/pkg/controller.v1beta1/suggestion/composer/composer_test.go +++ b/pkg/controller.v1beta1/suggestion/composer/composer_test.go @@ -22,12 +22,12 @@ import ( stdlog "log" "os" "path/filepath" + "reflect" "strings" "sync" "testing" "time" - "github.com/google/go-cmp/cmp" "github.com/onsi/gomega" "github.com/spf13/viper" appsv1 "k8s.io/api/apps/v1" @@ -631,8 +631,8 @@ func TestDesiredRBAC(t *testing.T) { func metaEqual(expected, actual metav1.ObjectMeta) bool { return expected.Name == actual.Name && expected.Namespace == actual.Namespace && - cmp.Equal(expected.Labels, actual.Labels) && - cmp.Equal(expected.Annotations, actual.Annotations) && + reflect.DeepEqual(expected.Labels, actual.Labels) && + reflect.DeepEqual(expected.Annotations, actual.Annotations) && (len(actual.OwnerReferences) > 0 && expected.OwnerReferences[0].APIVersion == actual.OwnerReferences[0].APIVersion && expected.OwnerReferences[0].Kind == actual.OwnerReferences[0].Kind && diff --git a/pkg/suggestion/v1beta1/goptuna/converter.go b/pkg/suggestion/v1beta1/goptuna/converter.go index 6c338efe0a3..b7865b5b307 100644 --- a/pkg/suggestion/v1beta1/goptuna/converter.go +++ b/pkg/suggestion/v1beta1/goptuna/converter.go @@ -311,7 +311,7 @@ func toGoptunaParams( } ir := float64(p) internalParams[name] = ir - // externalParams[name] = p is prohibited because of cmp.Diff() will not be empty + // externalParams[name] = p is prohibited because of reflect.DeepEqual() will be false // at findGoptunaTrialIDByParam() function. externalParams[name] = d.ToExternalRepr(ir) case goptuna.StepIntUniformDistribution: @@ -321,7 +321,7 @@ func toGoptunaParams( } ir := float64(p) internalParams[name] = ir - // externalParams[name] = p is prohibited because of cmp.Diff() will not be empty + // externalParams[name] = p is prohibited because of reflect.DeepEqual() will be false // at findGoptunaTrialIDByParam() function. externalParams[name] = d.ToExternalRepr(ir) case goptuna.CategoricalDistribution: diff --git a/pkg/suggestion/v1beta1/goptuna/sample.go b/pkg/suggestion/v1beta1/goptuna/sample.go index 08f26deab9e..8e484eb8847 100644 --- a/pkg/suggestion/v1beta1/goptuna/sample.go +++ b/pkg/suggestion/v1beta1/goptuna/sample.go @@ -18,10 +18,10 @@ package suggestion_goptuna_v1beta1 import ( "fmt" + "reflect" "strconv" "github.com/c-bata/goptuna" - "github.com/google/go-cmp/cmp" api_v1_beta1 "github.com/kubeflow/katib/pkg/apis/manager/v1beta1" ) @@ -119,9 +119,9 @@ func findGoptunaTrialIDByParam(study *goptuna.Study, trialMapping map[string]int continue } - if diff := cmp.Diff(ktrial.Params, trials[i].Params); diff == "" { + if reflect.DeepEqual(ktrial.Params, trials[i].Params) { return trials[i].ID, nil } } - return -1, fmt.Errorf("same parameter is not found for Trial: %v", ktrial) + return -1, fmt.Errorf("Same parameter is not found for Trial: %v", ktrial) }