Add Python port of the SAS curation pipeline - #77
Open
pendingintent wants to merge 1 commit into
Open
Conversation
Full, faithful port of utilities/*.sas (converters, cross-workbook
validators, reference-data refresh utilities, and the JSON round-trip/
delta-regeneration helpers) to Python under scripts/ and scripts/cosmoslib/.
The SAS files are untouched and still work; both toolchains read the same
curation spreadsheets and were verified to produce byte-for-byte-equivalent
YAML output.
What's included:
- cosmoslib/: shared library - Excel/YAML I/O, manifests, issue reporting,
LinkML enum + NCI EVS + CDISC Library codelist/relations caches, the
BC/SDTM/CRF converters, cross-workbook validators, subset-codelist and
hierarchy helpers, and JSON round-trip flattening.
- scripts/convert_{bc,sdtm,crf}_xlsx2yaml.py + convert_latest_xlsx2yaml.py:
curation-to-YAML converters, driven by utilities/manifests/*.yaml release
manifests (replacing SAS's hand-edited, commented-out per-release blocks).
- scripts/validate_spreadsheet_{sdtm,crf}.py: cross-workbook referential
checks (unresolved BC/DEC/SDTM links, duplicates, retired-BC pointers,
character-coding issues).
- scripts/refresh_{enums,codelists,sdtm_relations}.py: reference-data cache
builders, with added resilience (one failure no longer aborts the run).
- scripts/dump_{bc,sdtm,crf}_from_json.py: ad hoc live-API round-trip
diagnostics.
- tests/: golden-file regression tests (diffed against already-published
YAML) plus unit tests for every converter/validator rule; run with
`pytest`. requirements-dev.txt/pytest.ini added for this.
- how/python-conversion-pipeline.md: usage guide covering setup, pipeline
order, manifests, caveats, best practices, and testing.
- plans/port-sas-utilities-to-python.md: the implementation plan this port
followed.
Notes:
- Two approved fixes applied: the CRF completionIinstructions typo, and the
&folder.2 output-path bug (now yaml/<folder>/crf).
- Every other SAS quirk (comparator auto-clear, group-boundary list-header
printing, asymmetric field quoting, validator asymmetries between SDTM
and CRF) is deliberately preserved for fidelity, not "fixed" - see
`grep -rn "SAS-QUIRK" scripts/` for the full audit trail.
- Two general bugs were found and fixed in excel_reader.py along the way
(case-sensitive sheet lookups; duplicate blank-header columns breaking
pd.concat) - both are real fixes, not quirks, and are covered by tests.
- Emitted YAML never depends on a live API lookup; only the issues/findings
logs do. Golden-file tests run with stub NCI EVS/codelist/relations
clients and no network access.
- No SAS installation is available anywhere in this project's dev or CI
story; fidelity was established by diffing against already-published
YAML and, where practical, against live API data - see how/ for details.
Co-Authored-By: Claude Sonnet 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
Full, faithful port of
utilities/*.sas(converters, cross-workbook validators, reference-datarefresh utilities, and the JSON round-trip/delta-regeneration helpers) to Python under
scripts/and
scripts/cosmoslib/. The SAS files are untouched and still work — both toolchains read thesame curation spreadsheets, and this port was verified to produce byte-for-byte-equivalent YAML
output against already-published data.
scripts/cosmoslib/— shared library: Excel/YAML I/O, release manifests, structured issuereporting, LinkML enum + NCI EVS + CDISC Library codelist/relations caches, the BC/SDTM/CRF
converters, cross-workbook validators, subset-codelist and hierarchy helpers, and JSON
round-trip flattening.
scripts/convert_{bc,sdtm,crf}_xlsx2yaml.py+convert_latest_xlsx2yaml.py—curation-to-YAML converters, driven by
utilities/manifests/*.yamlrelease manifests(replacing SAS's hand-edited, commented-out per-release blocks).
scripts/validate_spreadsheet_{sdtm,crf}.py— cross-workbook referential checks(unresolved BC/DEC/SDTM links, duplicates, retired-BC pointers, character-coding issues).
scripts/refresh_{enums,codelists,sdtm_relations}.py— reference-data cache builders,with added resilience so one failure doesn't abort the whole run.
scripts/dump_{bc,sdtm,crf}_from_json.py— ad hoc live-API round-trip diagnostics.tests/— golden-file regression tests (diffed against already-published YAML) plus unittests for every converter/validator rule.
how/python-conversion-pipeline.md— usage guide: setup, pipeline order, manifests,caveats, best practices, testing.
plans/port-sas-utilities-to-python.md— the implementation plan this port followed.Notes
completionIinstructionstypo, and the&folder.2output-path bug (now
yaml/<folder>/crf).field quoting, validator asymmetries between SDTM and CRF) is deliberately preserved for
fidelity, not "fixed" — see
grep -rn "SAS-QUIRK" scripts/for the full audit trail.excel_reader.pyalong the way (case-sensitive sheetlookups; duplicate blank-header columns breaking
pd.concat) — both are real fixes, notquirks, and are covered by tests.
tests run with stub NCI EVS/codelist/relations clients and no network access.
established by diffing against already-published YAML and, where practical, against live API
data — see
how/for details.Test plan
pytest— full suite (unit + golden-file regression tests) passesflake8— clean acrossscripts/andtests/output under
yaml/20260714_r18/andyaml/20260630_draft/crf/with zero mismatchesreal fixture, confirmed byte-identical to published YAML
traced back to genuine pre-existing curation data issues (not port bugs)
how/python-conversion-pipeline.mdfor the usage flow and caveats beforeapproving
🤖 Generated with Claude Code