Skip to content

Add const values to the GFF schema's strand and phase choices - #393

Open
turbomam wants to merge 2 commits into
developfrom
gff-strand-phase-values
Open

turbomam wants to merge 2 commits into
developfrom
gff-strand-phase-values

Conversation

@turbomam

@turbomam turbomam commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Description of PR purpose/changes

The anyOf choices under strand and phase in the GFF schema have only a title and a description, so they don't restrict values. This PR gives each choice a const equal to its title. 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 as 0 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 title and a description also make convert_xsv_schema_to_pyarrow raise UnconstrainedSchemaError. I saw that on develop and on the models branch of #392. src/cdm_data_loaders/pipelines/xsv/settings.py calls convert_xsv_schema_to_pyarrow to build the PyArrow schema unless default_pyarrow_schema is set or the output schema registry has the table.

This PR can be merged before or after #392. That PR changes sequid to seqid in the same file, and git merges this branch with the models branch without conflicts.

Each const repeats its title because JSON Schema treats title and description as 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 chose const because it keeps those descriptions and changes less. I can switch to enum if 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: strand x, phase 7 and phase x are accepted, and the PyArrow conversion raises UnconstrainedSchemaError. On this branch, all 12 pass.
  • qsv validate (qsv 29.0.0) on a 6-row test file, with sequid changed to seqid in both schemas so that any row can pass. With develop's schema, all 6 rows pass, including strand x and phase 7. On this branch, those 2 rows fail and the other 4 pass.
  • On this branch: uv run ruff format --check and uv run ruff check on the new test, and uv run --group docs zensical build --clean --strict, all pass. uv run pytest -m "not requires_spark and not requires_ceph and not docs" and uv run pytest -m docs pass on the schema commit, before the test commit was added.

Dev Checklist:

  • My submission follows the AI Covenant principles
    • Claude made the edit to gff.schema.json, wrote the test, wrote most of this description, and ran every check above.
  • I have performed a self-review of my own code

Copilot AI balanced review requested due to automatic review settings November 23, 2026 23:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 const values 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

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.92%. Comparing base (1f9fdf6) to head (944fda7).
⚠️ Report is 1 commits behind head on develop.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0bf015c...944fda7. Read the comment docs.

This branch has not been deployed

No deployments
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.

2 participants