|
| 1 | +/* |
| 2 | +Copyright 2021. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package regressor |
| 18 | + |
| 19 | +import ( |
| 20 | + . "github.com/onsi/ginkgo/v2" |
| 21 | + . "github.com/onsi/gomega" |
| 22 | + |
| 23 | + "github.com/sustainable-computing-io/kepler/pkg/model/types" |
| 24 | +) |
| 25 | + |
| 26 | +var _ = Describe("Test Regressor Weight Unit (logarithm model from URL)", func() { |
| 27 | + It("Get Node Components Power By Logarithmic Regression with model from URL", func() { |
| 28 | + 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" |
| 29 | + |
| 30 | + // Initialize the regressor with the URL |
| 31 | + r := genRegressor(types.AbsPower, types.ComponentEnergySource, "", modelURL, "", types.LogarithmicTrainer) |
| 32 | + err := r.Start() |
| 33 | + Expect(err).To(BeNil()) |
| 34 | + |
| 35 | + r.ResetSampleIdx() |
| 36 | + r.AddNodeFeatureValues(nodeFeatureValues) |
| 37 | + |
| 38 | + powers, err := r.GetComponentsPower(false) |
| 39 | + Expect(err).NotTo(HaveOccurred()) |
| 40 | + Expect(len(powers)).Should(Equal(1)) |
| 41 | + |
| 42 | + // Test power calculation. The results should match those from estimator |
| 43 | + // Expect(powers[0].Core).Should(BeNumerically("=", 0)) |
| 44 | + // Expect(powers[0].DRAM).Should(BeNumerically("=", 0)) |
| 45 | + // Expect(powers[0].Pkg).Should(BeNumerically("=", 0)) |
| 46 | + |
| 47 | + idlePowers, err := r.GetComponentsPower(true) |
| 48 | + Expect(err).NotTo(HaveOccurred()) |
| 49 | + Expect(len(idlePowers)).Should(Equal(1)) |
| 50 | + }) |
| 51 | +}) |
0 commit comments