Skip to content

refactor: extract shared row-partitioning helpers#79

Merged
andreatgretel merged 3 commits into
mainfrom
andreatgretel/chore/extract-row-partitioning
Apr 1, 2026
Merged

refactor: extract shared row-partitioning helpers#79
andreatgretel merged 3 commits into
mainfrom
andreatgretel/chore/extract-row-partitioning

Conversation

@andreatgretel
Copy link
Copy Markdown
Collaborator

Summary

  • Extract the duplicated split/reorder/recombine DataFrame pattern into a shared engine/row_partitioning.py module with split_rows() and merge_and_reorder()
  • Refactor rewrite_workflow.py and llm_replace_workflow.py to use the shared helpers instead of inline implementations
  • Net reduction of ~46 lines of duplicated logic

Closes #60

Test plan

  • 10 new unit tests for row_partitioning.py (partitioning, edge cases, roundtrip)
  • All 495 existing tests pass with no changes
  • Lint clean (ruff check)

Move the duplicated split/reorder/recombine pattern into
engine/row_partitioning.py with split_rows() and merge_and_reorder().

Refactor rewrite_workflow.py and llm_replace_workflow.py to use the
shared helpers instead of inline implementations.

Closes #60
@andreatgretel andreatgretel requested a review from a team as a code owner March 31, 2026 12:57
- Make ROW_ORDER_COL public so tests can import it
- Add guard for empty parts in merge_and_reorder
- Add test for empty-parts guard
- Strengthen roundtrip test assertion on val column
Comment thread src/anonymizer/engine/row_partitioning.py Outdated
Comment thread src/anonymizer/engine/row_partitioning.py
Comment thread src/anonymizer/engine/replace/llm_replace_workflow.py
Comment thread tests/engine/test_row_partitioning.py
Comment thread tests/engine/test_row_partitioning.py
Copy link
Copy Markdown
Collaborator

@lipikaramaswamy lipikaramaswamy left a comment

Choose a reason for hiding this comment

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

Looks good, just a few nits and suggestions. e2e test ran without issues.

@andreatgretel andreatgretel merged commit 7193934 into main Apr 1, 2026
6 checks passed
@andreatgretel andreatgretel deleted the andreatgretel/chore/extract-row-partitioning branch April 1, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: extract shared entity-row split/reorder/recombine helper

2 participants