feat: round output JSON floats to 2dp + unify ensure_ascii for asr/asrx

This commit is contained in:
Accusys
2026-08-16 06:38:39 +08:00
parent 39e9ce4c3b
commit 5e6a7b7d51
18 changed files with 249 additions and 45 deletions
+12 -1
View File
@@ -29,6 +29,17 @@ FACES_COLLECTION = "_faces"
BATCH_SIZE = 1000
def round_json_numbers(obj):
"""Recursively round all float values to 2 decimal places (JSON output only)."""
if isinstance(obj, float):
return round(obj, 2)
if isinstance(obj, dict):
return {k: round_json_numbers(v) for k, v in obj.items()}
if isinstance(obj, list):
return [round_json_numbers(v) for v in obj]
return obj
def qdrant_scroll(filter_dict, limit=BATCH_SIZE, offset=None, with_payload=None):
"""Scroll Qdrant collection with filter."""
body = {"limit": limit, "filter": filter_dict, "with_vector": False}
@@ -261,7 +272,7 @@ def build_trace_profiles(file_uuid=None, dry_run=False):
# Write trace_profile.json
with open(profile_path, "w") as f:
json.dump(profile, f, indent=2, ensure_ascii=False)
json.dump(round_json_numbers(profile), f, indent=2, ensure_ascii=False)
total_profiles += 1