From 4e512aec8a0954634df872dd64f5b6bed5212fbc Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Fri, 3 Oct 2025 16:35:22 -0700 Subject: [PATCH] pre-commit --- llama_stack/testing/inference_recorder.py | 6 ++++-- scripts/normalize_recordings.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/llama_stack/testing/inference_recorder.py b/llama_stack/testing/inference_recorder.py index b1e2834b5..bd7fe7cfe 100644 --- a/llama_stack/testing/inference_recorder.py +++ b/llama_stack/testing/inference_recorder.py @@ -85,7 +85,7 @@ def _normalize_tool_call_ids(obj: Any, request_hash: str, counter: dict[str, int if isinstance(obj, dict): # Normalize tool_calls array if "tool_calls" in obj and isinstance(obj["tool_calls"], list): - for i, tool_call in enumerate(obj["tool_calls"]): + for tool_call in obj["tool_calls"]: if isinstance(tool_call, dict) and "id" in tool_call: # Generate deterministic tool call ID tool_call["id"] = f"toolcall-{request_hash[:8]}-{counter['count']}" @@ -204,7 +204,9 @@ class ResponseStorage: if "body" in serialized_response: if isinstance(serialized_response["body"], list): # Handle streaming responses (list of chunks) - serialized_response["body"] = [_serialize_response(chunk, request_hash) for chunk in serialized_response["body"]] + serialized_response["body"] = [ + _serialize_response(chunk, request_hash) for chunk in serialized_response["body"] + ] else: # Handle single response serialized_response["body"] = _serialize_response(serialized_response["body"], request_hash) diff --git a/scripts/normalize_recordings.py b/scripts/normalize_recordings.py index d43ce1cbc..09e1ff6ff 100644 --- a/scripts/normalize_recordings.py +++ b/scripts/normalize_recordings.py @@ -1,4 +1,10 @@ #!/usr/bin/env python3 +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the terms described in the LICENSE file in +# the root directory of this source tree. + """ Utility script to re-normalize existing recording files. @@ -9,6 +15,7 @@ git diffs when recordings are re-recorded. Usage: python scripts/normalize_recordings.py [--dry-run] """ + import argparse import json from pathlib import Path