Enrich inferred schemas with canonical data dictionaries (closes #192)#214
Open
amc-corey-cox wants to merge 2 commits into
Open
Enrich inferred schemas with canonical data dictionaries (closes #192)#214amc-corey-cox wants to merge 2 commits into
amc-corey-cox wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the first step of the schema enrichment pipeline by overlaying canonical data dictionary (DD) declarations onto inferred LinkML schemas, exposing this via a new schemauto enrich command and --data-dictionary convenience flags on TSV generalization.
Changes:
- Introduces
schema_automator.enrichers.data_dictionary_enricherwith anEnrichmentReport, metadata overlay rules, permissible-values merging, and an “incomplete DD enum” heuristic driven by observed distinct counts. - Wires repeatable
--data-dictionaryintogeneralize-tsv/generalize-tsvsand adds a standaloneschemauto enrichCLI command. - Adds unit/integration/CLI tests plus realistic dbGaP-like fixtures (JHS) to validate enrichment behavior and discrepancy surfacing.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
schema_automator/enrichers/data_dictionary_enricher.py |
New core enricher implementation + report structure + heuristic logic. |
schema_automator/enrichers/__init__.py |
Exposes enricher/report as package API. |
schema_automator/generalizers/csv_data_generalizer.py |
Records num_distinct_values annotation used by enrichment heuristic. |
schema_automator/cli.py |
Adds --data-dictionary options to generalize commands and new enrich command. |
tests/test_enrichers/test_data_dictionary_enricher.py |
Unit tests covering overlay, type/required handling, PV merge, and heuristic. |
tests/test_enrichers/test_integration_jhs.py |
End-to-end enrichment tests against JHS-shaped fixture. |
tests/test_enrichers/test_cli.py |
CLI integration tests for enrich and generalize convenience flags. |
tests/test_enrichers/__init__.py |
Initializes new test package. |
tests/resources/dbgap/JHS_Subject.dd.yaml |
Canonical DD fixture used in integration/CLI tests. |
tests/resources/dbgap/JHS_Subject.data.tsv |
TSV fixture used for inference + enrichment tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
963318a to
7057d6c
Compare
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.
Closes #192. First step of the schema enrichment pipeline (#190): overlay declared metadata from a canonical DD onto an inferred LinkML schema.
schemauto enrichis the primary surface;--data-dictionary(repeatable) is wired intogeneralize-tsv/generalize-tsvsas a convenience. Matching is global by slot name — class-aware targeting deferred until we have a real use case. Pandera path documented as a known limitation.The count-based heuristic on
num_distinct_valueslets enrichment refuse to upgrade a primitive range to an enum when the DD provably can't cover what inference observed; DD codes get stashed as a slot annotation in that case.Test plan
pytest tests/— 185 passed, 3 skipped, 9 xfailedschemauto generalize-tsv --data-dictionary <jhs.dd.yaml> jhs.tsvround-trips throughyaml_loader.load(..., SchemaDefinition)