Skip to content

Commit

Permalink
chore: unit test regressors to match estimator results
Browse files Browse the repository at this point in the history
Signed-off-by: Huamin Chen <[email protected]>
  • Loading branch information
rootfs committed Oct 9, 2024
1 parent 6f4ff7e commit 56239d2
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions pkg/model/estimator/local/regressor/local_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package regressor

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/sustainable-computing-io/kepler/pkg/model/types"
)

var _ = Describe("Test Regressor Weight Unit (logarithm model from URL)", func() {
It("Get Node Components Power By Logarithmic Regression with model from URL", func() {
modelURL := "https://raw.githubusercontent.com/sustainable-computing-io/kepler-model-db/refs/heads/main/models/v0.7/ec2-0.7.11/rapl-sysfs/AbsPower/BPFOnly/LogarithmicRegressionTrainer_0.json"

// Initialize the regressor with the URL
r := genRegressor(types.AbsPower, types.ComponentEnergySource, "", modelURL, "", types.LogarithmicTrainer)
err := r.Start()
Expect(err).To(BeNil())

r.ResetSampleIdx()
r.AddNodeFeatureValues(nodeFeatureValues)

powers, err := r.GetComponentsPower(false)
Expect(err).NotTo(HaveOccurred())
Expect(len(powers)).Should(Equal(1))

// Test power calculation. The results should match those from estimator
// Expect(powers[0].Core).Should(BeNumerically("=", 0))
// Expect(powers[0].DRAM).Should(BeNumerically("=", 0))
// Expect(powers[0].Pkg).Should(BeNumerically("=", 0))

idlePowers, err := r.GetComponentsPower(true)
Expect(err).NotTo(HaveOccurred())
Expect(len(idlePowers)).Should(Equal(1))
})
})

0 comments on commit 56239d2

Please sign in to comment.