Move ord-data's pipeline scripts in from ord-schema - #263
Conversation
process_dataset.py, pb_to_parquet_dataset.py, and parse_uspto.py are pipeline and one-off ingestion code for this repository rather than schema use cases; they arrive here with their tests. The matching removal is open-reaction-database/ord-schema#908. Test imports become bare `import X`, matching the co-located convention upload_to_huggingface_test.py already uses, and pb_to_parquet_dataset_test.py's caplog logger name follows __name__ to its new value. process_dataset.py's docstring called it "a one-stop shop for preparing submissions"; it is the submission workflow's machinery, and now says so. A `pipeline` dependency group holds what the dataset-touching scripts need -- ord-schema and pygithub -- and `dev` includes it, so the mirror job's `uv sync --no-dev` still skips the rdkit/pandas chain. submission.yml drops its pinned ord-schema checkout and pip install for `uv sync --only-group pipeline`, which also takes ORD_SCHEMA_TAG out of that workflow: the moved script imports ord_schema.datasets, which does not exist in v0.6.3, so the submission path necessarily validates at the locked 0.8. Full-corpus validation in validation.yml stays on the pinned tag. process_submission gains `needs: check_file_types`, because it runs process_dataset.py from the pull request's own checkout -- a fork could otherwise edit that script while the job rejecting non-dataset files was still running. Ruff's ignore list picks up the rules the incoming code trips (G004, PLR2004, RUF001, S101, PTH207, TD003, FIX002), each already ignored in ord-schema, and the test per-file ignore widens from D103 to D. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| added, removed, changed = get_change_stats( | ||
| datasets, [file_status], base=args.base | ||
| ) |
There was a problem hiding this comment.
Cross-file moves corrupt statistics
When a reaction moves between two dataset files modified in the same pull request, get_change_stats() compares each file independently and the later unions classify the reaction as both added and removed instead of reconciling it across the submission, producing incorrect totals in the submission comment.
| echo "Pulling LFS objects for changed datasets: ${INCLUDE}" | ||
| git lfs pull --include="${INCLUDE}" | ||
| - uses: actions/setup-python@v5 | ||
| - uses: astral-sh/setup-uv@v7 |
There was a problem hiding this comment.
The new submission job executes astral-sh/setup-uv@v7 before processing datasets and performing token-backed repository operations, so repointing this mutable tag changes the code executed with access to the job checkout and available workflow token; pin the action to a reviewed full commit SHA. How this was verified: The workflow runs the mutable action before its GITHUB_TOKEN-backed processing and push steps.
convert_to_parquet.py reached ord_schema.parquet through the parquet_dataset alias module and called write_dataset; the README's conversion example used message_helpers.write_message. All three are deprecated shims that open-reaction-database/ord-schema#909 removes. The README's JSON example imported write_message without using it, so that import goes rather than changing name. ty could not have caught the alias: parquet_dataset is a real module whose __getattr__ returns Any, so every attribute through it -- including ones that do not exist -- type-checks clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Companion to ord-schema#908, which removes these same files.
process_dataset.py,pb_to_parquet_dataset.py, andparse_uspto.pyare this repository's pipeline and one-off ingestion code rather than schema use cases, so they land here with their tests. That is 25 tests arriving on top of the 10 from #262 — the point of standing up the harness first was thatprocess_dataset_test.pyis the best-covered thing inord_schema/scripts/and moving it into a repository with nowhere to run it would have quietly dropped that coverage.Background: ord-logbook: Where ord-schema ends.
What changed beyond the copy
Imports. Test imports become bare
import process_dataset, matching the co-located conventionupload_to_huggingface_test.pyalready uses, andpb_to_parquet_dataset_test.py'scaploglogger name follows__name__to its new value.The
process_dataset.pydocstring. It called itself "a one-stop shop for preparing submissions," which reads as contributor-facing and is exactly what made the earlier read of this boundary wrong. It is the submission workflow's machinery, and now says so — including a pointer tovalidate_dataset.pyfor contributors who do want a pre-submission check.A
pipelinedependency group holds what the dataset-touching scripts need (ord-schema,pygithub);devincludes it, so the mirror job'suv sync --no-devstill skips the rdkit/pandas chain.submission.ymldrops its pinned ord-schema checkout and pip install foruv sync --only-group pipeline.ORD_SCHEMA_TAGleaves that workflow entirely.Ruff's ignore list picks up the rules the incoming code trips —
G004,PLR2004,RUF001,S101,PTH207,TD003,FIX002— each already ignored in ord-schema for the same reason, and the test per-file ignore widens fromD103toD.Two things worth a close look
The submission path now validates at ord-schema 0.8, not v0.6.3. This is forced, not chosen: the moved
process_dataset.pyimportsord_schema.datasets, which does not exist in v0.6.3. Full-corpus validation invalidation.ymlstill runs at the pinned tag, so the two paths now disagree about which schema version they validate against. Reconciling them means bumpingvalidation.ymltoo, which deserves its own trial run against the whole corpus rather than riding along here.process_submissiongainsneeds: check_file_types. The job now runsscripts/process_dataset.pyout of the pull request's own checkout, where previously the script came from a pinned ord-schema tag a fork could not touch.check_file_typesalready rejects fork submissions containing anything but dataset files, but it is a parallel job, so without the dependency a fork could edit the script and have it executed while that check was still running. Forkpull_requestruns get no secrets and a read-only token, so the exposure was bounded either way — but the ordering should be explicit.Verification
ruff check,ruff format --check,ty check, and all four pre-commit hooks pass; 35 tests pass underpytest -n auto.Stacked on #262 and will retarget to
mainwhen that merges.🤖 Generated with Claude Code
Greptile Summary
This PR relocates ORD dataset-processing and ingestion tooling into ord-data.
Confidence Score: 3/5
The PR is not yet safe to merge because cross-file reaction moves still produce incorrect submission statistics and the token-backed workflow still invokes a mutable third-party action reference.
The processing code computes and unions statistics independently per file, so moving one reaction between files remains visible as an addition and removal; the submission workflow also continues to execute
astral-sh/setup-uv@v7before processing and pushing with repository credentials.Files Needing Attention: scripts/process_dataset.py; .github/workflows/submission.yml
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR PR[Dataset pull request] --> Types[Check changed file types] Types --> Checkout[Checkout PR revision] Checkout --> LFS[Fetch changed LFS objects] LFS --> Deps[Install pipeline dependency group] Deps --> Process[Run scripts/process_dataset.py] Process --> Comment[Post submission summary] Process --> Update[Update and push datasets]Reviews (2): Last reviewed commit: "Drop deprecated ord-schema API from scri..." | Re-trigger Greptile