Add Python tooling: uv, ruff, ty, and pytest - #262
Draft
skearnes wants to merge 2 commits into
Draft
Conversation
| echo "Diff range: ${BASE}..${HEAD}" | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| - uses: astral-sh/setup-uv@v7 |
There was a problem hiding this comment.
Mutable setup-uv action reference
The new mirror and test workflows execute astral-sh/setup-uv@v7 through a mutable major-version tag, allowing upstream tag movement to change the code executed by CI without review. Pin both references to a reviewed full commit SHA to make this supply-chain boundary immutable.
How this was verified: Both changed workflows invoke the mutable astral-sh/setup-uv@v7 reference directly.
skearnes
marked this pull request as draft
July 26, 2026 04:07
ord-data had no Python tooling -- no pyproject, no lockfile, no linter, no tests -- while scripts/ is about to receive process_dataset.py, which rewrites contributor submissions, and the derived-views driver. This sets up the harness before that code lands, mirroring ord-schema so the two repositories share one toolchain. pyproject.toml replaces scripts/requirements.txt as the single dependency source, with uv.lock pinning the environment and CI installing via --locked. ord-schema is a dev dependency rather than a runtime one so the mirror job, which only moves bytes, can `uv sync --no-dev` without pulling rdkit and pandas. The ruff select list is copied from ord-schema verbatim, since a shared standard across the two repositories is the point. The ignore list is not: ord-schema's ~40 exemptions are each justified by code this repository does not have, so this lists only rules that actually fire here. Running the toolchain surfaced real fixes rather than noise. Six functions and a class had no docstrings; one manual append loop became list.extend; and ty caught `matches: callable` in convert_to_parquet, a function used where a type belongs. ty also flagged composed_readme.encode() on a `str | None`, which is a false positive because an early return guards it -- but the invariant was implicit, so deriving "there is something to mirror" from the composed card itself makes it structural. Tests sit beside the modules they cover (foo.py / foo_test.py), matching ord-schema. pyproject.toml is added to the addlicense allowlist, since it carries a header like the rest of the code. Note that ruff formats Python code blocks inside Markdown, so a README example is reformatted here. The download instructions change: `pip install -r scripts/requirements.txt` becomes `pip install huggingface_hub`, with a uv alternative alongside. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`uv run` syncs the environment before running, using the default groups, so the bare `uv run python scripts/upload_to_huggingface.py` reinstalled the dev group that `uv sync --no-dev` had just excluded -- including ord-schema and its rdkit/pandas chain. Pass --no-sync so the run uses the environment the sync step built. Co-Authored-By: Claude Opus 5 (1M context) <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.
Stacked on #261 — review that one first; this PR retargets to
mainautomatically when it merges.ord-data has no Python tooling: no pyproject, no lockfile, no linter, no tests. Meanwhile
scripts/is about to receiveprocess_dataset.py— which rewrites contributor submissions — and the derived-views driver. This stands up the harness before that code lands, mirroring ord-schema so the two repositories share one toolchain.Dependencies
pyproject.tomlreplacesscripts/requirements.txtas the single dependency source, withuv.lockpinning the environment and CI installing via--locked.ord-schemais a dev dependency rather than a runtime one, so the mirror job canuv sync --no-devand skip rdkit and pandas. Holding that requiresuv run --no-syncon the run step, which the second commit adds:uv runotherwise syncs with the default groups first and reinstalls precisely what--no-devexcluded.Lint config
The ruff
selectlist is copied from ord-schema verbatim, since a shared standard across the two repositories is the point. Theignorelist deliberately is not: ord-schema's ~40 exemptions are each justified by code this repository does not have, so this lists only rules that actually fire here — formatter conflicts, CLI realities likeprintand shelling out to git, and the handful ord-schema had already settled on style grounds.That paid off immediately. Six functions and a class had no docstrings, one manual append loop became
list.extend, andtycaughtmatches: callableinconvert_to_parquet.py— a function used where a type belongs, nowCallable[[dataset_pb2.Dataset], bool].tyalso flaggedcomposed_readme.encode()on astr | None; that one is a false positive because an early return guards it, but the invariant was implicit, so deriving "there is something to mirror" from the composed card itself makes it structural.Tests sit beside the modules they cover (
foo.py/foo_test.py), matching ord-schema. The ten tests coverparse_name_statusandbuild_configs— including that a rename must split into delete-old plus upload-new, since the mirror has no rename operation and would otherwise orphan the source.Two things worth a look
pip install -r scripts/requirements.txtbecomespip install huggingface_hub, with auv runalternative alongside. It is the one line here that a data consumer sees.What this unblocks
Moving
process_dataset.pyand its 29 KB test suite out of ord-schema, per the logbook entry, and then the derived-views driver.🤖 Generated with Claude Code
Greptile Summary
Adds a shared Python development and CI toolchain for the repository.
pyproject.tomlanduv.lock.Confidence Score: 3/5
The PR should not merge until both setup-uv references are pinned to a reviewed full commit SHA.
The mirror and test workflows still execute a third-party action through a mutable major-version tag, so upstream tag movement can change CI code without repository review.
Files Needing Attention: .github/workflows/huggingface_mirror.yml and .github/workflows/tests.yml
Important Files Changed
Reviews (5): Last reviewed commit: "Keep the mirror job's --no-dev environme..." | Re-trigger Greptile