REVIEW: [BUG] Make pyspark an optional extra on overture-schema-pyspark - #1
Closed
sethfitz wants to merge 2 commits into
Closed
REVIEW: [BUG] Make pyspark an optional extra on overture-schema-pyspark#1sethfitz wants to merge 2 commits into
sethfitz wants to merge 2 commits into
Conversation
pyspark was a hard dependency, so installing overture-schema-pyspark resolved pyspark on every runtime, including ones (Glue, EMR) that already bundle their own PySpark and don't want this package re-resolving it underneath them. Moved it to a `spark` optional-dependency extra. Standalone environments building their own install overture-schema-pyspark[spark]; runtime-provided-PySpark environments install the bare package. Probe for pyspark in the package's __init__ so a bare install without PySpark raises an actionable ModuleNotFoundError naming the extra rather than "No module named 'pyspark'". __init__ runs on any import of any submodule, generated ones included, so one probe covers every entry path. It catches nothing, so an unrelated missing dependency -- or a pyspark that is present but broken -- still surfaces its own real error from the imports that follow. Supersedes OvertureMaps#660, which is where this change and its changelog wording originated. Refs OvertureMaps#659 Co-authored-by: Adam Lastowka <adamlastowka@gmail.com> Signed-off-by: Seth Fitzsimmons <seth@mojodna.net>
Signed-off-by: Seth Fitzsimmons <seth@mojodna.net>
Owner
Author
|
Submitted upstream as schema#681. Staging complete; review branch kept for provenance. |
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.
The proposed upstream PR body is a file in Files changed —
.pr-review/BODY.md. Comment on it line by line like code. It lives only on this review branch;pyspark-optional-extrais clean and is what gets submitted.Decisions that are yours
Attribution. The commit carries
Co-authored-by: Adam Lastowkaand the body opens by naming OvertureMaps#660 as the origin. If you'd rather this land as a review comment on his PR than as a superseding PR, nothing here is wasted — the branch works either way.The probe vs. the alternatives. Three forms were on the table. Per-site guards at each
from pyspark... import(your first suggestion) — I argued against: 22 sites, 21 unreachable, and the generated tree would need a renderer change. A sentineltry: import pyspark(what OvertureMaps#660 landed on) — works, but misreports an installed-but-broken pyspark as "not installed" unless it inspectse.name, which is the construct you objected to. Thefind_specprobe avoids the branch entirely. Detail is in the body's "It catches nothing" paragraph.The option nobody argued: no guard at all.
No module named 'pyspark'from a package namedoverture-schema-pysparkis not cryptic, and the guard costs ~10 lines, 3 tests, and afind_specon every import. I'd still ship it — the extra is what makes that failure routine — but it was foreclosed by OvertureMaps#660's framing rather than weighed. Easy to drop if you disagree; the extras change stands alone.Tests, stated honestly
Three tests added, one of which is a real RED/GREEN gate. Verified by reverting
__init__.pyalone toorigin/mainand re-running:__init__test_missing_pyspark_names_the_extratest_unrelated_missing_dependency_surfaces_its_own_errortest_package_imports_when_pyspark_is_installedThe second is not idle — it fails against a broad-
exceptimplementation, which is the regression it exists to forbid — but it does not prove this fix. Worth knowing before "three new tests" reads as three proofs.Verification
make check TESTMON=(pre-commit gate)uv sync --locked --all-packages --all-extras[spark]No module named 'shapely', unmaskedpy4jremoved → importNo module named 'py4j', unmaskedpyspark/dir on pathWhat I deliberately left out
The lockfile is hand-edited, not relocked. OvertureMaps#660's
uv.lockcarried unrelated relock churn (exclude-newer, anexceptiongroupmarker); this edits only theoverture-schema-pysparkentry, so the diff is 7 lines.uv sync --lockedaccepts it.No README/docs change. Nothing in the repo documents installing this package, so there was no install line to update. If it's documented somewhere outside this repo,
[spark]needs to reach it.Before submitting
Your fork's
mainwasstale; I fast-forwarded
sethfitz/schema:maintoorigin/mainso this review PR diffs cleanly. Upstream needs exactly one change-type label —change type - minor 🤏fits (non-breaking packaging change).