Skip to content

Commit

Permalink
Merge branch 'main' into enterprise
Browse files Browse the repository at this point in the history
* main:
  Added temporary rescale guard clause
  (fix): energy unit was falsely omitted in badge
  Bump fastapi[standard] from 0.115.4 to 0.115.5 (#978)
  Made cluster accuracy warning more verbose
  Removing duplicate value check in cluster
  Bump tqdm from 4.66.6 to 4.67.0 (#975)
  • Loading branch information
ArneTR committed Nov 14, 2024
2 parents 41356e3 + cb26e2c commit 8540952
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
7 changes: 6 additions & 1 deletion api/api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ def store_artifact(artifact_type: Enum, key:str, data, ex=2592000):
# The same unit for proper comparison!
#
def rescale_energy_value(value, unit):
# We only expect values to be mJ for energy!
if unit == 'mJ':
value = value * 1_000
unit = 'uJ'

# We only expect values to be uJ for energy in the future. Changing values now temporarily.
# TODO: Refactor this once all data in the DB is uJ
if unit != 'uJ' and not unit.startswith('ugCO2e/'):
raise RuntimeError('Unexpected unit occured for energy rescaling: ', unit)

Expand Down
2 changes: 1 addition & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ async def get_badge_single(run_id: str, metric: str = 'ml-estimated'):
if data is None or data == [] or data[1] is None: # special check for data[1] as this is aggregate query which always returns result
badge_value = 'No energy data yet'
else:
[energy_value, energy_unit] = rescale_energy_value(data[0], 'uJ')
[energy_value, energy_unit] = rescale_energy_value(data[0], data[1])
badge_value= f"{energy_value:.2f} {energy_unit} {via}"

badge = anybadge.Badge(
Expand Down
3 changes: 0 additions & 3 deletions config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ cluster:
cpu_energy_rapl_msr_component:
threshold: 0.01 # 1%
type: stddev_rel
cpu_energy_rapl_msr_component:
threshold: 0.01 # 1%
type: stddev_rel
psu_carbon_ac_mcp_machine:
threshold: 0.01 # 1%
type: stddev_rel
Expand Down
2 changes: 1 addition & 1 deletion docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gunicorn==23.0.0
psycopg[binary]==3.2.3
psycopg_pool==3.2.3
fastapi[standard]==0.115.4
fastapi[standard]==0.115.5
starlette>=0.35
uvicorn[standard]==0.32.0
pandas==2.2.3
Expand Down
4 changes: 2 additions & 2 deletions lib/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def validate_workload_stddev(data, metrics):

if metrics[el['metric']]['type'] == 'stddev_rel':
if el['stddev_rel'] > metrics[el['metric']]['threshold']:
print(TerminalColors.FAIL, 'Warning. Threshold exceeded!', TerminalColors.ENDC)
info_string_acc.append(f"=> Warning! Threshold of {metrics[el['metric']]['threshold']} exceeded. Value is: {el['stddev_rel']}. Metric: {el['metric']}")
warning = True
elif metrics[el['metric']]['type'] == 'stddev':
if el['stddev'] > metrics[el['metric']]['threshold']:
print(TerminalColors.FAIL, 'Warning. Threshold exceeded!', TerminalColors.ENDC)
info_string_acc.append(f"=> Warning! Threshold of {metrics[el['metric']]['threshold']} exceeded. Value is: {el['stddev']}. Metric: {el['metric']}")
warning = True
else:
raise ValueError(f"{el['metric']} had unknown threshhold validation type: {metrics[el['metric']]['type']}")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ schema==0.7.7
aiohttp==3.10.10

# calibration script dep
tqdm==4.66.6
tqdm==4.67.0
plotext==5.3.2
docker==7.1.0

0 comments on commit 8540952

Please sign in to comment.