From 67340e5bedf7970909f49d3c40330f0fcd1c0151 Mon Sep 17 00:00:00 2001 From: Xu Zhao Date: Tue, 6 Feb 2024 09:15:58 -0500 Subject: [PATCH] Upload string value as float -1.0 --- scripts/userbenchmark/upload_scribe.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/userbenchmark/upload_scribe.py b/scripts/userbenchmark/upload_scribe.py index 3e99259585..92dac09d2e 100644 --- a/scripts/userbenchmark/upload_scribe.py +++ b/scripts/userbenchmark/upload_scribe.py @@ -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") @@ -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, "