Skip to content

Refactor generate_category_data: extract finalize_category_output#5422

Open
ludeeus wants to merge 3 commits into
mainfrom
claude/gen-data-refactor-finalize
Open

Refactor generate_category_data: extract finalize_category_output#5422
ludeeus wants to merge 3 commits into
mainfrom
claude/gen-data-refactor-finalize

Conversation

@ludeeus

@ludeeus ludeeus commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

Preparatory refactor of scripts/data/generate_category_data.py with no behavior change.

  • Pulls the summary / validation / diff / output-writing tail of generate_category_data into a reusable finalize_category_output() helper (plus a small _dump_diff helper).
  • Switches the module entrypoint to argparse.

This is the first of a few small PRs that split the sharding work (previously #5419) into reviewable pieces. Extracting the finalization step here lets a later merge step reuse it without duplicating the logic.

No behavior change

Output files are written with the same options as before (data.json/stored.json unsorted; repositories.json keeps its existing dump; diffs and summary unchanged). Existing snapshot tests cover this and are untouched.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NL8ieP9vEVJLTZ51esR6VD


Generated by Claude Code

Pull the summary/validation/diff/output-writing tail of
generate_category_data out into a reusable finalize_category_output helper
(plus a small _dump_diff helper), and switch the module entrypoint to
argparse.

Pure refactor with no behavior change: the output files are written with
the same options as before. This is preparatory groundwork so the
finalization step can later be reused by a merge step.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NL8ieP9vEVJLTZ51esR6VD
Copilot AI review requested due to automatic review settings July 23, 2026 17:04
@ludeeus
ludeeus marked this pull request as draft July 23, 2026 17:06
@ludeeus ludeeus added the pr: action Changes to actions label Jul 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors scripts/data/generate_category_data.py by extracting the “finalization” tail of category generation (summary, validation, diff generation, and output file writes) into a reusable helper, and modernizes the script entrypoint to use argparse. This supports upcoming work to reuse the finalization logic without duplicating it.

Changes:

  • Extract output/validation/diff-writing logic into finalize_category_output() and introduce _dump_diff() to centralize diff JSON formatting.
  • Update generate_category_data() to delegate final output handling to the new helper.
  • Replace manual sys.argv parsing with an argparse-based CLI entrypoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/data/generate_category_data.py
Comment thread scripts/data/generate_category_data.py
Recreate outputdata/<category>/ and outputdata/diff/ up front in
generate_category_data (as before the refactor), so the directories exist
even when data generation fails before finalization. The makedirs calls in
finalize_category_output are kept (idempotent) so the helper stays
self-contained for reuse.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NL8ieP9vEVJLTZ51esR6VD

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread scripts/data/generate_category_data.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ludeeus
ludeeus marked this pull request as ready for review July 23, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: action Changes to actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants