Repository navigation
Conversation
…em before writing Ported from #111. Output datasets are declared once as Pydantic models (pts.schemas.dataset); pandera schemas and documentation JSON are derived from them. Models for the GWAS credible-set evidence, ENCORE evidence and biosample outputs live in pts.schemas.outputs. write_dataset and write_evidence take an optional schema and validate the frame against it before writing, so a violation writes nothing. The GWAS credible-set, ENCORE and biosample steps now validate their outputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Addresses an adversarial review of the dataset schemas: - write_evidence with a schema now streams failed evidence and alongside sinks to disk unvalidated in the same pass that collects valid evidence, so only the valid part is held in memory and the input is computed once. - validationReadouts joins evidence_schema, so ENCORE's struct field order and hsaValue dtype are harmonised before validation. - Models overriding model_config, or fields using validate_default, are rejected rather than silently left unenforced. - The agreement test documents the deliberate NaN-as-null deviation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DSuveges
added a commit
that referenced
this pull request
Oct 22, 2026
…here pts writes them Work in progress, stacked on #218. - 63 output dataset models in pts.schemas.outputs, generated from the 26.09 release outputs (run vh/ppp-2609-1) and croissant metadata by pts/scripts/output_schemas (profiler, generator, per-part validator). Rules are strict to that release: dtypes, struct order, nullability, observed numeric/date ranges, enums for low-cardinality strings and identifier shapes. They replace the hand-written biosample, ENCORE and GWAS models. - Every pts polars step writing one of these outputs passes schema=; credible_set, study and enhancer_to_gene validate the accepted output before writing either output. - Framework: datetime.date support, Float32 bounds compared at full precision, a polars panic on multi-row-group parquet avoided in nested checks, the agreement test judging the row as stored, references allowed to point at non-key columns. - End-to-end step tests reading their output back are removed (46), with the helpers they left unused. Not done yet: no model for variant (profiling exceeds the polars out-of-core budget) or colocalisation (generation OOM, since fixed); models not yet validated against full outputs; full test suite not run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Carries over the schema and validation logic from #111, which is otherwise obsolete. Output datasets are declared once as Pydantic models. The pandera schema used for validation, and optional documentation JSON, are derived from them. The JSON dumps themselves are not committed.
Validation is wired into these three steps:
write_dataset(..., schema=Model): checks the destination first, then validates the frame and writes it. A violation writes nothing. This is used bybiosample.EvidenceDatasource(schema=...), passed throughrun_evidencetowrite_evidence. This is used bygwas_credible_setsandencore. Excluded evidence andalongsidesinks are streamed to disk unvalidated, in the same pass that collects the valid evidence. Only the valid part is held in memory and validated, and the input is still computed once. If validation fails,failed_evidenceis written butevidenceis not.Changes compared with #111:
main's transformers write now. GWAS and ENCORE carry over unchanged, apart from module and step references. The quality-flag vocabulary is tested againstEvidenceFlags.validationReadoutsis added toevidence_schema. Harmonisation then fixes its struct field order and itshsaValuedtype, which pandera checks but Pydantic does not.model_config, and fields usingvalidate_default, are rejected. Pydantic would enforce them, but the derived schema would not.pts/docs/schemas/and the test that checked they were up to date are dropped. The generator is kept:uv run python -m pts.schemas.dataset.docs <dir>.New dependency:
pandera[polars].Test run on 26.09 data
All three steps were run end to end on local copies of run
vh/ppp-2609-1's inputs, with validation enabled:The release outputs of all three also pass their models.
* Biosample content differs from the release in ways that predate this PR (
main's port): empty lists instead of nulls forparents/children, 63 labels instead of purl URLs, andchildren/descendantsswapped in column order.Benchmark: with vs without validation
On 3.5M GWAS rows, validation costs about 0.4 s. Peak memory is dominated by the literature look-up table, not by the validated evidence. On synthetic GWAS evidence, validation took 0.09 s for 1M rows and 0.41 s for 5M rows.
Known limits
Test plan
make lint-ptsmake test-pts(2882 passed, 11 skipped)🤖 Generated with Claude Code