Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions controllers/weightsandbiases_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ func (r *WeightsAndBiasesReconciler) Reconcile(ctx context.Context, req ctrl.Req
log.Info("No changes found")
statusManager.Set(status.Completed)
return ctrlqueue.Requeue(desiredSpec)
} else {
diff := currentActiveSpec.DiffValues(desiredSpec)
log.Info("Changes found", "diff", diff)
}
}

Expand Down
35 changes: 35 additions & 0 deletions pkg/wandb/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,38 @@ func maskValues(values map[string]interface{}) map[string]interface{} {
}
return newValues
}

func (s *Spec) DiffValues(other *Spec) map[string]interface{} {
return diffMaps(s.Values, other.Values)
}

func diffMaps(a, b map[string]interface{}) map[string]interface{} {
diff := make(map[string]interface{})
for key, aValue := range a {
if bValue, ok := b[key]; ok {
if !reflect.DeepEqual(aValue, bValue) {
switch aValue.(type) {
case map[string]interface{}:
if bMap, ok := bValue.(map[string]interface{}); ok {
nestedDiff := diffMaps(aValue.(map[string]interface{}), bMap)
if len(nestedDiff) > 0 {
diff[key] = nestedDiff
}
} else {
diff[key] = aValue
}
default:
diff[key] = aValue
}
}
} else {
diff[key] = aValue
}
}
for key, bValue := range b {
if _, ok := a[key]; !ok {
diff[key] = bValue
}
}
return diff
}