Skip to content

Commit

Permalink
style: badge renamed to metric value
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneTR committed Dec 19, 2024
1 parent e99d53b commit 13e0473
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def rescale_metric_value(value, unit):
# 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 not in ('uJ', 'ug') and not unit.startswith('ugCO2e/'):
raise ValueError('Unexpected unit occured for energy rescaling: ', unit)
raise ValueError('Unexpected unit occured for metric rescaling: ', unit)

unit_type = unit[1:]

Expand Down
2 changes: 1 addition & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ async def get_badge_single(run_id: str, metric: str = 'ml-estimated'):
data = DB().fetch_one(query, params=params)

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'
badge_value = 'No metric data yet'
else:
[metric_value, energy_unit] = rescale_metric_value(data[0], data[1])
badge_value= f"{metric_value:.2f} {energy_unit} {via}"
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def test_rescale_metric_value():


with pytest.raises(ValueError):
api_helpers.rescale_metric_value(100, 'xJ') # expecting only mJ and uJ
api_helpers.rescale_metric_value(100, 'xJ')

with pytest.raises(ValueError):
api_helpers.rescale_metric_value(100, 'uj') # expecting only mJ and uJ
api_helpers.rescale_metric_value(100, 'uj')



Expand Down

0 comments on commit 13e0473

Please sign in to comment.