mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-11 13:44:38 +00:00
fix: update normalize to search all recordings dirs (#3767)
Updated scripts/normalize_recordings.py to dynamically find and process all 'recordings' directories under tests/ using pathlib.rglob() instead of hardcoding a single path. Signed-off-by: Derek Higgins <derekh@redhat.com>
This commit is contained in:
parent
e039b61d26
commit
6d8f61206e
1 changed files with 25 additions and 10 deletions
|
@ -94,23 +94,38 @@ def main():
|
||||||
parser.add_argument("--dry-run", action="store_true", help="Show what would be changed without modifying files")
|
parser.add_argument("--dry-run", action="store_true", help="Show what would be changed without modifying files")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
recordings_dir = Path(__file__).parent.parent / "tests/integration/recordings/responses"
|
# Find all recordings directories under tests/
|
||||||
|
tests_dir = Path(__file__).parent.parent / "tests"
|
||||||
|
|
||||||
if not recordings_dir.exists():
|
if not tests_dir.exists():
|
||||||
print(f"Recordings directory not found: {recordings_dir}")
|
print(f"Tests directory not found: {tests_dir}")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
# Find all directories named "recordings" under tests/
|
||||||
|
recordings_dirs = sorted([p for p in tests_dir.rglob("recordings") if p.is_dir()])
|
||||||
|
|
||||||
|
if not recordings_dirs:
|
||||||
|
print("No recordings directories found")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
print(f"Found {len(recordings_dirs)} recordings directories:")
|
||||||
|
for d in recordings_dirs:
|
||||||
|
print(f" - {d.relative_to(tests_dir.parent)}")
|
||||||
|
print()
|
||||||
|
|
||||||
modified_count = 0
|
modified_count = 0
|
||||||
total_count = 0
|
total_count = 0
|
||||||
|
|
||||||
for file_path in sorted(recordings_dir.glob("*.json")):
|
# Process all JSON files in all recordings directories
|
||||||
total_count += 1
|
for recordings_dir in recordings_dirs:
|
||||||
was_modified = normalize_recording_file(file_path, dry_run=args.dry_run)
|
for file_path in sorted(recordings_dir.rglob("*.json")):
|
||||||
|
total_count += 1
|
||||||
|
was_modified = normalize_recording_file(file_path, dry_run=args.dry_run)
|
||||||
|
|
||||||
if was_modified:
|
if was_modified:
|
||||||
modified_count += 1
|
modified_count += 1
|
||||||
status = "[DRY RUN] Would normalize" if args.dry_run else "Normalized"
|
status = "[DRY RUN] Would normalize" if args.dry_run else "Normalized"
|
||||||
print(f"{status}: {file_path.name}")
|
print(f"{status}: {file_path.relative_to(tests_dir.parent)}")
|
||||||
|
|
||||||
print(f"\n{'[DRY RUN] ' if args.dry_run else ''}Summary: {modified_count}/{total_count} files modified")
|
print(f"\n{'[DRY RUN] ' if args.dry_run else ''}Summary: {modified_count}/{total_count} files modified")
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue