From c84bfd0bbecda576b93d6e7a3ea6d25097d7bcc7 Mon Sep 17 00:00:00 2001 From: Sunil Thaha Date: Wed, 28 Aug 2024 14:02:20 +1000 Subject: [PATCH] feat(models): log model source url Signed-off-by: Sunil Thaha --- pkg/model/node_component_energy.go | 7 +++++-- pkg/model/node_platform_energy.go | 7 +++++-- pkg/model/types/types.go | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/pkg/model/node_component_energy.go b/pkg/model/node_component_energy.go index 8f31cef4f9..b60464dc87 100644 --- a/pkg/model/node_component_energy.go +++ b/pkg/model/node_component_energy.go @@ -55,11 +55,14 @@ func CreateNodeComponentPowerEstimatorModel(nodeFeatureNames, systemMetaDataFeat var err error nodeComponentPowerModel, err = createPowerModelEstimator(modelConfig) if err != nil { - klog.Errorf("Failed to create %s/%s Model to estimate Node Component Power: %v", modelConfig.ModelType, modelConfig.ModelOutputType, err) + klog.Errorf("Failed to create %s/%s Model from %s to estimate Node Component Power: %v", + modelConfig.ModelType, modelConfig.ModelOutputType, + modelConfig.SourceURL(), err) return } - klog.V(1).Infof("Using the %s/%s Model to estimate Node Component Power", modelConfig.ModelType, modelConfig.ModelOutputType) + klog.V(1).Infof("Using the %s/%s Model from %s to estimate Node Component Power", + modelConfig.ModelType, modelConfig.ModelOutputType, modelConfig.SourceURL()) } // IsNodeComponentPowerModelEnabled returns if the estimator has been enabled or not diff --git a/pkg/model/node_platform_energy.go b/pkg/model/node_platform_energy.go index 7d772427f7..363974ada8 100644 --- a/pkg/model/node_platform_energy.go +++ b/pkg/model/node_platform_energy.go @@ -51,10 +51,13 @@ func CreateNodePlatformPowerEstimatorModel(nodeFeatureNames, systemMetaDataFeatu var err error nodePlatformPowerModel, err = createPowerModelEstimator(modelConfig) if err != nil { - klog.Errorf("Failed to create %s/%s Model to estimate Node Platform Power: %v", modelConfig.ModelType, modelConfig.ModelOutputType, err) + klog.Errorf("Failed to create %s/%s Model from %s to estimate Node Platform Power: %v", + modelConfig.ModelType, modelConfig.ModelOutputType, + modelConfig.SourceURL(), err) return } - klog.V(1).Infof("Using the %s/%s Model to estimate Node Platform Power", modelConfig.ModelType, modelConfig.ModelOutputType) + klog.V(1).Infof("Using the %s/%s Model from %s to estimate Node Platform Power", + modelConfig.ModelType, modelConfig.ModelOutputType, modelConfig.SourceURL()) } // IsNodePlatformPowerModelEnabled returns if the estimator has been enabled or not diff --git a/pkg/model/types/types.go b/pkg/model/types/types.go index a74f0053f1..51b5a215ee 100644 --- a/pkg/model/types/types.go +++ b/pkg/model/types/types.go @@ -16,8 +16,10 @@ limitations under the License. package types -type ModelType int -type ModelOutputType int +type ( + ModelType int + ModelOutputType int +) const ( // Power Model types @@ -25,6 +27,7 @@ const ( Regressor // estimation happens within kepler, but pre-trained model parameters are downloaded externally EstimatorSidecar // estimation happens in the sidecar with a loaded pre-trained power model ) + const ( // Power Model Output types // Absolute Power Model (AbsPower): is the power model trained by measured power (including the idle power) @@ -33,6 +36,7 @@ const ( DynPower Unsupported ) + const ( // Define energy source PlatformEnergySource = "acpi" @@ -99,3 +103,11 @@ type ModelConfig struct { SystemMetaDataFeatureNames []string SystemMetaDataFeatureValues []string } + +func (c *ModelConfig) SourceURL() string { + if c.InitModelURL != "" { + return c.InitModelURL + } + + return c.InitModelFilepath +}