Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces PySpark version compatibility checks and updates Python version requirements to 3.10 or later. It adds a new _runtimes module to map Managed Spark runtime versions to their respective Spark and Python versions, integrates PySpark version validation into the session builder, and updates the documentation, setup configuration, and unit tests accordingly. The review feedback suggests enhancing robustness by adding a defensive type check for the version string in major_minor and wrapping the import of is_remote_only in a try-except block to gracefully handle older or custom PySpark installations.
dborowitz
force-pushed
the
dborowitz-new-versions
branch
from
October 29, 2026 16:10
eb11204 to
ec4a8ea
Compare
No release has declared Requires-Python, and wheels before 2.1.1 were even tagged py2.py3. The code needs 3.10 (a match statement in session.py), but pip would happily install it on 3.9, where pyspark 4.0 is still available, and then fail on import with a SyntaxError. Keep the full suite on 3.12, the default runtime's Python, across all OSes and extras. Smoke test the other declared versions on Linux only, running all unit tests but those marked slow. Those few take about 80% of the suite's time, mostly sleeping in parametrized timing tests, while covering only a handful of lines the rest do not, so the smoke tests still run nearly every line the full suite does (and import every module), catching standard library APIs missing from older Pythons and removed from newer ones as well as syntax. Also check statically with vermin that nothing needs a newer Python than 3.10, which catches newer syntax and standard library APIs even in lines no test runs.
dborowitz
force-pushed
the
dborowitz-new-versions
branch
from
October 29, 2026 16:51
ec4a8ea to
353562e
Compare
Spark Connect servers support clients with older Spark minor versions, but not newer ones: against runtime 3.0 (Spark 4.0), pyspark-client 4.2 fails createDataFrame() on a SQL config Spark 4.0 lacks, while pyspark-client 4.0 works against Spark 4.2 throughout. Warn about the former only. Keep what each runtime version ships, Spark and Python, in one table, use it for the existing Python UDF check as well, and look runtime versions up by major.minor so that subminor versions such as 3.0.12 are checked too. Runtime versions missing from the table are not checked. A test keeps the default runtime and the [client]/[spark] pins in sync.
The [client] and [spark] extras pin the default runtime's pyspark minor version, but newer runtimes and preinstalled environments can have a newer one. Against pyspark-client 4.2: * LogicalPlan.to_proto() now calls the client's _set_relation_in_plan(), which the instrumentation tests' FakeClient lacked. * pyspark 4.2's check_dependencies() takes a __main__ module without __file__, as running a command-line string leaves it, to mean it is running its own doctests, and exits when it cannot find a Spark distribution. Feed subprocess probes on stdin instead. The same affects pytest-xdist workers, so the new CI job runs serially.
dborowitz
force-pushed
the
dborowitz-new-versions
branch
from
October 29, 2026 21:35
353562e to
cdf4d18
Compare
tim-u
approved these changes
Oct 29, 2026
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
Modernizes Python and PySpark version handling across packaging metadata, runtime session checks, unit tests, and CI:
Declares
Requires-Python: >=3.10and tests non-default Python versions (setup.py,README.md,pyproject.toml,.github/workflows/tests.yaml,.github/workflows/vermin.yaml)Requires-Pythoninsetup.py(and wheels before2.1.1were taggedpy2.py3-none-any). Becausesession.pyusesmatch/casesyntax (Python 3.10+),pipon Python 3.9 (wherepyspark4.0 is still installable) would install the wheel and fail at import time withSyntaxError.python_requires=">=3.10"and adds Python 3 / 3.10–3.14 classifiers insetup.py, and documents supported Python versions (and the UDF Python minor-version matching requirement) inREADME.md.[client]smoke rows for Python 3.10, 3.11, 3.13, and 3.14 runningpytest tests/unit -m "not slow" -n auto(which imports every module undergoogle/).slowpytest marker for the 39 unit tests that take ≥1s each (mostly sleeping): the nonzerobackend_wait/client_waitparams oftest_proxy.py's timing tests (the zero-wait params still cover every socket-timeout combination), plus 3 slow tests intest_session.pyandtest_pypi_artifacts.py. Per-test coverage contexts show these take ~80% of serial suite time while covering only 6 lines nothing else covers, so the smoke subset reaches 99.8% of the lines the full suite covers in ~15–20s under-n 4(vs. ~50–60s for the full suite). This catches standard library APIs missing from older Pythons (e.g.datetime.UTC,itertools.batched) or removed in newer ones, not just syntax.Verminworkflow running vermin--target=3.10-overgoogle,tests, andsetup.py, which statically catches newer-only language features and stdlib modules/functions/kwargs even in lines no test runs.Centralizes runtime version metadata and warns when PySpark is newer than the runtime's Spark (
_runtimes.py,session.py,tests/unit/test_runtimes.py,tests/unit/test_init.py)toPandas/toArrow, Python/pandas UDFs,mapInPandas/applyInPandas, UDTFs, caching, catalog, tables, streaming,interruptAll):pyspark-client4.0.3 → a Spark 4.2 server: everything that works with a matched client works.pyspark-client4.2.0 → Spark 4.0 (runtime 3.0):createDataFrame()from local data (rows, explicit schema, or pandas) fails withSQL_CONF_NOT_FOUNDforspark.sql.session.localRelationSizeLimit, a config Spark 4.0 does not have.google/cloud/managed_spark_connect/_runtimes.py(RuntimeInfo,_RUNTIMES = {(3, 0): RuntimeInfo(spark=(4, 0), python=(3, 12))}) indexed by(major, minor)so subminor runtime strings such as"3.0.12"are checked as well, while unknown runtime versions are skipped gracefully._runtimes.get_runtime_info()in both_check_python_version_compatibility()and a new_check_pyspark_version_compatibility()check that warns (never raises) only when the installedpysparkminor version is newer than the target runtime's Spark version (recommendingpyspark-client~=X.Y.0orpyspark[connect]~=X.Y.0based onis_remote_only()).tests/unit/test_runtimes.pykeeping_DEFAULT_RUNTIME_VERSIONandsetup.py's[client]/[spark]pysparkpins in sync.Fixes unit tests under newer
pyspark-clientand tests them in CI (tests/unit/test_instrumentation.py,tests/unit/test_init.py,.github/workflows/tests.yaml)[client]and[spark]pin~=4.0.0to match the default3.0runtime, newer runtimes and preinstalled environments may have a newerpyspark-client(such as4.2.x)._set_relation_in_plan()onFakeClientintests/unit/test_instrumentation.py(invoked byLogicalPlan.to_proto()inpyspark-client4.2+).stdin(python -) rather than-cintests/unit/test_init.pyto avoidpyspark4.2'scheck_dependencies(), which treats a__main__module without__file__as apysparkdoctest run and exits whenSPARK_HOMEis unset.test-newest-pysparkCI job in.github/workflows/tests.yamlrunning the full unit test suite on Ubuntu + Python 3.13 against the latestpyspark-client(serially, aspytest-xdistworkers also bootstrap without__main__.__file__).Commits in this PR
build: declare Requires-Python >=3.10 and smoke test other Pythonsfeat: warn when installed PySpark is newer than the runtime's Sparktest: fix unit tests under newer pyspark-client and run them in CITesting
Tag: py3-none-any,Requires-Python: >=3.10) and confirmeduv pip installrejects Python 3.9 and succeeds on Python 3.10–3.14.-m "not slow"smoke subset (535 passed) on Python 3.10, 3.11, 3.12, 3.13, and 3.14.vermin --target=3.10-(passes; verified it flagsdatetime.UTC,asyncio.timeout,itertools.batched,shutil.rmtree(onexc=),typing.Self,enum.StrEnum, andPath.walkin a canary file).587 passed) against bothpyspark-client==4.0.3(Python 3.12) andpyspark-client==4.2.0(Python 3.13).