Skip to content

Commit

Permalink
Upload string value as float -1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhao9 committed Feb 6, 2024
1 parent 81b0346 commit 67340e5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/userbenchmark/upload_scribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from collections import defaultdict
from datetime import datetime

DEFAULT_STR_VALUE = -1.0

def get_metrics_date_from_file(fname: str) -> str:
bname = os.path.basename(fname)
dt = datetime.strptime(bname, "metrics-%Y%m%d%H%M%S.json")
Expand All @@ -29,6 +31,10 @@ def format_message(self, field_dict):
elif field in self.schema['int']:
message['int'][field] = int(value)
elif field in self.schema['float']:
# If the metrics value is string
# Assign the float value to be -1.0
if isinstance(value, str):
value = DEFAULT_STR_VALUE
message['float'][field] = float(value)
else:
raise ValueError("Field {} is not currently used, "
Expand Down

0 comments on commit 67340e5

Please sign in to comment.