feat: round output JSON floats to 2dp + unify ensure_ascii for asr/asrx
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user