refactor(parquet): T-CONTEXTS partial — ParquetExportContext#78
Merged
refactor(parquet): T-CONTEXTS partial — ParquetExportContext#78
Conversation
Introduces ``ParquetExportContext`` frozen dataclass in ``parquet_export.py`` bundling the 15 per-call inputs (source shards, dataset identity, publishing options) so ``export_reranker_parquets`` no longer trips flake8-bugbear's parameter ceiling. Signature collapses 16 args → 1 (``ctx``). Body destructures the dataclass once at the top so the rest of the function stays diff-minimal. Both call-sites updated to construct the context inline: - ``protea/core/training_dump_helpers.py`` (production dump path) - ``tests/test_parquet_export_boundary.py`` (the only test that invokes it) Sizes: - parquet_export.py: +35 LOC (dataclass + destructuring header) - Smell baseline: 77 → 75 offenders (params>6: 22 → 20: ``export_reranker_parquets`` retired plus 1 knock-on improvement) Local-first 5 verde (ruff + flake8 + pytest 1163 + check_smells).
4 tasks
frapercan
added a commit
that referenced
this pull request
May 8, 2026
## Acceptance criteria (master plan §24 Fase 1 — T-CONTEXTS partial) Fifth incremental Parameter Object slice. Tackles the remaining 16-arg offender in core training pipeline. ## Changes - `protea/core/training_dump_helpers.py`: - New ``KnnTransferContext`` frozen dataclass bundling the 12 per-call data inputs (queries, references, ontology maps, optional enrichment helpers). - ``_knn_transfer_and_label`` signature collapses 16 args → 5 (``session``, ``p``, ``ctx``, plus existing ``sequence_context`` / ``stream_output``). - Two production call sites updated (train branch + test-stream branch). - `tests/test_knn_streaming_smoke.py`: shared test runner updated. ## Smell budget 77 → 75 offenders. **params>6: 22 → 20** (`_knn_transfer_and_label` retired plus 1 knock-on). ## Test plan - [x] `poetry run ruff check protea scripts` - [x] `poetry run flake8 protea/` - [x] `poetry run pytest tests/ --ignore=tests/test_jobs_pg.py` (1163 passed, 11 skipped) - [x] `poetry run python scripts/check_smells.py` (75 known, none new) ## T-CONTEXTS progress (5 slices total, 4 in flight pending CI) - #73 KnnEnrichmentContext — enrich_v6_features 9 → 4 args - #75 CafaEvalRunContext — evaluate_all_settings 18 → 3 args - #77 _RerankerRegistration — _register_model 10 → 2 args - #78 ParquetExportContext — export_reranker_parquets 16 → 1 arg - this PR KnnTransferContext — _knn_transfer_and_label 16 → 5 args Combined: 69 args → 15 across the 5 entry points.
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.
Acceptance criteria (master plan §24 Fase 1 — T-CONTEXTS partial)
Fourth incremental Parameter Object slice. Tackles the last remaining 16-arg offender in core (after #73, #75, #77).
Changes
protea/core/parquet_export.py:@dataclass(frozen=True) ParquetExportContextbundling 15 per-call inputs grouped into 3 sections (source shards, dataset identity, publishing).export_reranker_parquetssignature collapses 16 args → 1 (ctx).protea/core/training_dump_helpers.py: production caller updated.tests/test_parquet_export_boundary.py: only test that invokes it updated.Smell budget
77 → 75 offenders. params>6: 22 → 20 (
export_reranker_parquetsretired plus 1 knock-on improvement as the dataclass centralises type annotations).Test plan
poetry run ruff check protea scriptspoetry run flake8 protea/poetry run pytest tests/ --ignore=tests/test_jobs_pg.py(1163 passed, 11 skipped)poetry run python scripts/check_smells.py(75 known, none new)T-CONTEXTS progress (4 slices total)
Combined: 53 → 10 args across the four entry points; baseline params>6: 24 → 20 (cumulative drop -4).