fix(er): make the clerical review loop round-trip and keep cluster identity - #361
Merged
Merged
Conversation
…entity load_review_decisions (#239): CSV queues were read with type inference, so ids such as "007" came back as 7 and never matched their pair, and a blank decision cell became NaN -> 'nan' and raised ValueError. The CSV is now read as text (dtype=str, keep_default_na=False); _coerce_id maps None, NaN/pd.NA and "" to None, and blank decision cells (in any format) are treated as undecided and skipped. load_review_decisions (#240): the CSV export's formula sanitizer also guards the id columns, so "+4410" is written as "'+4410" and the loaded key never matched. On CSV load only, a leading ' is stripped from left_id/right_id/item_id when the remainder starts with a formula prefix (the read-only _FORMULA_PREFIXES). The export path and the sanitizer are unchanged; JSONL/parquet ids are read verbatim because those formats are never sanitized. apply_review_decisions (#267): decisions carrying only an item_id were silently dropped. A new keyword-only queue= parameter resolves item ids through the ReviewQueueReport the reviewer worked from (item ids are queue positions that depend on the queue config, so they are not re-derived from the report). A decision that cannot be resolved to a pair now raises ValueError naming it. feedback_summary gains n_unmatched, the number of decided pairs absent from the report, and recalibration uses the resolved decisions. _recluster_from_pairs (#268): clusters were renumbered from er_000000 over matched records only and the canonical record reset to the lowest id, even with no decisions. The report's clusters are now passed in: an unchanged component keeps its cluster exactly; otherwise an original cluster's id and canonical record follow its canonical record (a merge keeps the lowest original id); a component with no original canonical gets a fresh id numbered past n_records and every existing er_N id. Closes #239 Closes #240 Closes #267 Closes #268
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the export → review →
load_review_decisions→apply_review_decisionsloop.load_review_decisionsreads CSV queues as text (dtype=str, keep_default_na=False), so ids like"007"keep their spelling._coerce_idtreatsNone/NaN/pd.NA/""as unset, and blankdecisioncells (CSV, JSONL or parquet) are skipped instead of raising.'guard that formula sanitization adds is stripped fromleft_id/right_id/item_idwhen the rest starts with a formula prefix (read-only_FORMULA_PREFIXES). The export path andsanitize_csv_formulasare unchanged; JSONL/parquet ids are read verbatim.apply_review_decisionsgains a keyword-onlyqueue=(theReviewQueueReportthe reviewer worked from) to resolveitem_id-only decisions. A decision that can't be resolved to a pair now raisesValueErrorinstead of being dropped silently.feedback_summary["n_unmatched"]counts decided pairs not in the report, and recalibration uses the resolved decisions._recluster_from_pairskeeps cluster identity. Unchanged clusters are returned as-is (id, canonical, confidence). Otherwise an original cluster's id and canonical record follow its canonical record (a merge keeps the lowest original id). Other new clusters get aner_Nid pastn_recordsand every existing id, so repeated applies never collide.Behaviour changes
queue=parameter and newValueErrorfor unresolvable decisions.n_unmatchedkey infeedback_summary.apply_review_decisions(report, [])is now an identity on clusters. Clusters it creates get ids numbered pastn_records.Tests
New
tests/test_er_review_loop.py(25 test functions, 45 cases):importorskip("pyarrow")).+,-,=,@,=and\t=, including a check that the exported file is still guarded; JSONL ids and free-text notes are not stripped.item_idresolution with a queue; errors without a queue, for unknown item ids and for incomplete pairs;n_unmatched; recalibration with item-id decisions.resolve_entitiesaccept.Verification
ruff check .: all checks passedmypy src/freshdata: no issues in 202 source filesfix/er-blocking-and-link)Closes #239
Closes #240
Closes #267
Closes #268