Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the GFF strand and phase schema changes.
No open issues 🎉
What changed in this PR
This PR constrains the bundled GFF schema’s strand and phase choices and makes those choices convertible to a PyArrow schema for the XSV pipeline.
Changes:
- Adds
constvalues to each choice, using integers for numeric phases to match qsv’s validation input. - Adds regression tests for accepted and rejected values and conversion to non-nullable Arrow string fields.
| File | Description |
|---|---|
tests/cdm_data_loaders/schemas/test_gff_strand_phase.py |
Tests value constraints and PyArrow conversion. |
tests/cdm_data_loaders/schemas/__init__.py |
Adds the schema test package marker. |
src/cdm_data_loaders/schemas/gff/gff.schema.json |
Constrains strand and phase alternatives with explicit constants. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #393 +/- ##
========================================
Coverage 97.92% 97.92%
========================================
Files 173 173
Lines 12026 12026
========================================
Hits 11776 11776
Misses 250 250 Continue to review full report in Codecov by Harness.
|
Description of PR purpose/changes
The
anyOfchoices understrandandphasein the GFF schema have only atitleand adescription, so they don't restrict values. This PR gives each choice aconstequal to itstitle. Phases 0, 1 and 2 get integer consts because qsv 29.0.0 passes those cells to the validator as numbers. With string consts, qsv rejected all three, with errors such as0 is not valid under any of the schemas listed in the 'anyOf' keyword, where a rejected strand shows as"x"in quotes.Choices with only a
titleand adescriptionalso makeconvert_xsv_schema_to_pyarrowraiseUnconstrainedSchemaError. I saw that on develop and on themodelsbranch of #392.src/cdm_data_loaders/pipelines/xsv/settings.pycallsconvert_xsv_schema_to_pyarrowto build the PyArrow schema unlessdefault_pyarrow_schemais set or the output schema registry has the table.This PR can be merged before or after #392. That PR changes
sequidtoseqidin the same file, and git merges this branch with themodelsbranch without conflicts.Each
constrepeats itstitlebecause JSON Schema treatstitleanddescriptionas annotations that never reject a value (https://json-schema.org/draft/2020-12/json-schema-validation#section-9.1). An alternative is"enum": ["+", "-", ".", "?"]for strand and"enum": [0, 1, 2, "."]for phase. That is shorter and has no repetition, but it drops the per-value descriptions. I choseconstbecause it keeps those descriptions and changes less. I can switch toenumif you prefer.Testing Instructions
uv run pytest tests/cdm_data_loaders/schemas, the new test. With develop's schema (0bf015c), 4 of 12 cases fail: strandx, phase7and phasexare accepted, and the PyArrow conversion raisesUnconstrainedSchemaError. On this branch, all 12 pass.qsv validate(qsv 29.0.0) on a 6-row test file, withsequidchanged toseqidin both schemas so that any row can pass. With develop's schema, all 6 rows pass, including strandxand phase7. On this branch, those 2 rows fail and the other 4 pass.uv run ruff format --checkanduv run ruff checkon the new test, anduv run --group docs zensical build --clean --strict, all pass.uv run pytest -m "not requires_spark and not requires_ceph and not docs"anduv run pytest -m docspass on the schema commit, before the test commit was added.Dev Checklist:
gff.schema.json, wrote the test, wrote most of this description, and ran every check above.