Skip to content

Commit

Permalink
More guard clauses to cater for correct configuration of the XGBoost …
Browse files Browse the repository at this point in the history
…model
  • Loading branch information
ArneTR committed Nov 20, 2022
1 parent 5dcde3f commit bde3b0c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/metric_providers/psu/energy/xgboost/system/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def start_profiling(self, containers=None):

def read_metrics(self, project_id, containers):

if not os.path.isfile("/tmp/green-metrics-tool/cpu_utilization_procfs_system.log"):
raise RuntimeError("could not find the /tmp/green-metrics-tool/cpu_utilization_procfs_system.log file. did you activate the CpuUtilizationProcfsSystemProvider in the config.yml too? This is required to run PsuEnergyXgboostSystemProvider")

with open("/tmp/green-metrics-tool/cpu_utilization_procfs_system.log", 'r') as f:
csv_data = f.read()
csv_data = csv_data[:csv_data.rfind('\n')] # remove the last line from the string, as it may be broken due to the output buffering of the metrics reporter
Expand All @@ -58,6 +61,12 @@ def read_metrics(self, project_id, containers):

provider_config = GlobalConfig().config['measurement']['metric-providers']['psu.energy.xgboost.system.provider.PsuEnergyXgboostSystemProvider']

if not 'HW_CPUFreq' in provider_config: raise RuntimeError("Please set the HW_CPUFreq config option for PsuEnergyXgboostSystemProvider in the config.yml")
if not 'CPUChips' in provider_config: raise RuntimeError("Please set the CPUChips config option for PsuEnergyXgboostSystemProvider in the config.yml")
if not 'CPUCores' in provider_config: raise RuntimeError("Please set the CPUCores config option for PsuEnergyXgboostSystemProvider in the config.yml")
if not 'TDP' in provider_config: raise RuntimeError("Please set the TDP config option for PsuEnergyXgboostSystemProvider in the config.yml")
if not 'HW_MemAmountGB' in provider_config: raise RuntimeError("Please set the HW_MemAmountGB config option for PsuEnergyXgboostSystemProvider in the config.yml")

Z['HW_CPUFreq'] = provider_config['HW_CPUFreq']
Z['CPUCores'] = provider_config['CPUCores']
Z['TDP'] = provider_config['TDP']
Expand Down

0 comments on commit bde3b0c

Please sign in to comment.