Skip to content

refactor: flip default to new AncestryModel + cleave legacy (round 6) - #250

Merged
dvitale199 merged 9 commits into
refactor/mainfrom
refactor/flip-default-cleave-legacy
Jul 21, 2026
Merged

refactor: flip default to new AncestryModel + cleave legacy (round 6)#250
dvitale199 merged 9 commits into
refactor/mainfrom
refactor/flip-default-cleave-legacy

Conversation

@dvitale199

Copy link
Copy Markdown
Owner

Summary

Round 6 of the refactor-hardening effort. Makes refactor/main a legacy-free candidate for the real-data parity gate by flipping the default engine to the new AncestryModel and deleting the dead legacy modules.

  • Flip the default: genotools / run_pipeline now always use the new AncestryModel path. Removed the use_new_ancestry A/B switch, the main_new() entry point + genotools-new console script, the legacy _run_ancestry_prediction method, and the self._ancestry / from ..ancestry.legacy import Ancestry wiring.
  • Delete dead legacy: removed genotools/ancestry/legacy.py (no longer imported after the flip), the orphan genotools/gwas.py (shadowed by the gwas/ package), and the obsolete tests/scripts/test_ancestry_ab.py.
  • Golden-convert the ancestry differential tests: the 4 tests that used legacy as their oracle now compare against committed golden fixtures (reduced chr21+22 panel). Fixtures were captured by one-time uncommitted generators that asserted new == legacy (incl. split genotype content via compare_genotypes); committed tests carry zero legacy imports. Input fixtures are staged into a temp dir per run so the committed golden/ dir stays read-only.
  • Fix the upfront_check skip-gap: re-implemented legacy's data-driven step auto-skips (deferred in round 5) as core/validation.py::validate_input returning a typed ValidationDecisions; the runner applies them (_filter_steps_by_decisions + a filter_controls override). The het-skip quirk (triggers on variant count var.shape[0] < 50 despite the "50 samples" warning text) is preserved intentionally for parity. validate_input takes primitive request flags to keep core/ decoupled from cli/.

Design + plan: docs/superpowers/specs/2026-07-20-flip-default-cleave-legacy-design.md, docs/superpowers/plans/2026-07-20-flip-default-cleave-legacy.md.

Still deferred to Phase 5/6: genotools/utils.py + genotools/imputation.py (kept as a pair — imputation.py imports utils.shell_do) and container/.

Test plan

  • Full unit + regression suite: 404 passed
  • Old-vs-new parity harness: 8/8 passed (.venv-stable baseline; QC + GWAS)
  • Static gate: no genotools-new / use_new_ancestry / ancestry.legacy / legacy _run_ancestry_prediction / gwas.py references remain in genotools/
  • End-to-end default genotools --ancestry on synthetic data trained a new AncestryModel (GridSearchCV + UMAP) → produced split pfiles (AFR/EUR/CAH), JSON, and a saved model dir
  • Whole-branch review: ready to merge (0 Critical, 0 Important, 3 non-blocking Minor)

get_common_snps/get_raw_files write side-effect files (.snplist, _flip.*,
.log) next to the ref_panel/geno_path prefix they receive. The
ref21_22_bfile and geno21_22_pfile fixtures were returning the committed
golden/ prefix directly, so every test run dirtied the committed source
tree with untracked plink byproducts. Copy the golden inputs into a
tmp_path_factory dir and return that prefix instead; golden/ stays
read-only. ref21_22_labels is read-only (no writes next to it) and is
left unchanged.
Replace legacy-oracle tests in test_cohort.py with golden tests that
compare split_cohort_by_ancestry output against committed fixtures
(split_EUR/AFR pfiles, cohort_pruned_samples.parquet) instead of running
genotools.ancestry.legacy.Ancestry at test time. Fixtures were generated
once via a scratchpad script that asserted new==legacy for labels,
pruned samples, and genotype content (compare_genotypes) before being
committed, so the tests no longer import legacy and will survive its
deletion.
@dvitale199
dvitale199 merged commit 275d5ea into refactor/main Jul 21, 2026
0 of 2 checks passed
@dvitale199
dvitale199 deleted the refactor/flip-default-cleave-legacy branch July 21, 2026 14:59
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.

1 participant