Skip to content

Commit

Permalink
Reverted cmp to reflect
Browse files Browse the repository at this point in the history
Signed-off-by: tariq-hasan <[email protected]>
  • Loading branch information
tariq-hasan committed Apr 7, 2024
1 parent 7f3cb4a commit 4b174b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pkg/controller.v1beta1/suggestion/composer/composer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 &&
Expand Down
4 changes: 2 additions & 2 deletions pkg/suggestion/v1beta1/goptuna/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions pkg/suggestion/v1beta1/goptuna/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}

0 comments on commit 4b174b6

Please sign in to comment.