Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions training/scripts/fix_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
S3DatasetLoader, # noqa: E402
)

logging.getLogger("ai.training.utils.s3_dataset_loader").setLevel(
logging.ERROR
)
logging.getLogger("ai.training.utils.s3_dataset_loader").setLevel(logging.ERROR)

DEFAULT_S3_BUCKET = "pixel-data"
MAX_RETRIES = 3
Expand Down Expand Up @@ -887,10 +885,16 @@ def print_results(results: list[dict[str, Any]], output: OutputHandler) -> None:
output.header("📊 ENCODING FIX RESULTS")
output.separator()

successful = [r for r in results if r.get("success")]
failed = [r for r in results if not r.get("success")]
skipped = [r for r in successful if r.get("skipped")]
fixed = [r for r in successful if not r.get("skipped")]
successful, failed, skipped, fixed = [], [], [], []
for r in results:
if r.get("success"):
successful.append(r)
if r.get("skipped"):
skipped.append(r)
else:
fixed.append(r)
else:
failed.append(r)

output.info(f"\n✅ Fixed: {len(fixed)} files")
output.info(f"⏭️ Skipped (already UTF-8): {len(skipped)} files")
Expand Down Expand Up @@ -919,10 +923,16 @@ def save_results(
results: list[dict[str, Any]],
) -> Path:
"""Save encoding fix results to JSON file"""
successful = [r for r in results if r.get("success")]
failed = [r for r in results if not r.get("success")]
skipped = [r for r in successful if r.get("skipped")]
fixed = [r for r in successful if not r.get("skipped")]
successful, failed, skipped, fixed = [], [], [], []
for r in results:
if r.get("success"):
successful.append(r)
if r.get("skipped"):
skipped.append(r)
else:
fixed.append(r)
else:
failed.append(r)

results_path = project_root / "ai/training_ready/data/encoding_fix_results.json"
with open(results_path, "w") as f:
Expand Down