Repository navigation
feat: declare Requires-Python >=3.10, warn on PySpark newer than the runtime, and test newer pyspark-client #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dborowitz
wants to merge
3
commits into
main
Choose a base branch
from
dborowitz-new-versions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Statically checks that the code only uses language features and standard | ||
| # library modules, functions and arguments that are available in the oldest | ||
| # Python version setup.py declares. Complements the smoke tests in tests.yaml, | ||
| # which only catch the APIs they run, and are run on CI's Python versions only. | ||
| # vermin only knows the types of names it can resolve statically, so it can | ||
| # miss methods on objects whose types it cannot infer. Silence false positives | ||
| # with a "# novm" comment. | ||
| name: Vermin | ||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| vermin: | ||
| name: Check minimum Python version | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@18d369b23da25a81e9458561248e1aafff6a70fa # v10.3.1 | ||
|
|
||
| - name: Install vermin | ||
| run: uv pip install --system 'vermin~=1.9' | ||
|
|
||
| # The target must match python_requires in setup.py. The trailing "-" fails | ||
| # only if the code needs a newer version, not if it would also run on an | ||
| # older one. | ||
| - name: Run vermin | ||
| run: vermin --no-tips --violations --eval-annotations --target=3.10- google tests setup.py |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """What the Managed Spark runtime versions ship, for client compatibility checks. | ||
|
|
||
| Spark Connect needs the client's PySpark minor version to match the server's | ||
| Spark minor version, and Python UDFs need the client's Python minor version to | ||
| match the server's, since PySpark refuses to run a UDF pickled by a different | ||
| Python minor version. | ||
| """ | ||
|
|
||
| import dataclasses | ||
| from typing import Optional, Tuple | ||
|
|
||
| from packaging.version import InvalidVersion, Version | ||
|
|
||
| MajorMinor = Tuple[int, int] | ||
|
|
||
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
| class RuntimeInfo: | ||
| """The versions a Managed Spark runtime version ships. | ||
|
|
||
| Attributes: | ||
| spark: Apache Spark (major, minor) version. | ||
| python: Python (major, minor) version. | ||
| """ | ||
|
|
||
| spark: MajorMinor | ||
| python: MajorMinor | ||
|
|
||
|
|
||
| # Keyed by runtime (major, minor) version. Runtime versions missing from here | ||
| # are not checked, so a runtime newer than this release still works, just | ||
| # without the compatibility warnings. | ||
| _RUNTIMES = { | ||
| (3, 0): RuntimeInfo(spark=(4, 0), python=(3, 12)), | ||
| } | ||
|
|
||
|
|
||
| def major_minor(version_str: str) -> Optional[MajorMinor]: | ||
| """The (major, minor) of a version string, or None if it has no minor. | ||
|
|
||
| Accepts both runtime versions ("3.0", or subminor versions like "3.0.12") | ||
| and PySpark versions ("4.0.1", "4.1.0.dev1"). | ||
| """ | ||
| try: | ||
| release = Version(version_str).release | ||
| except InvalidVersion: | ||
| return None | ||
| if len(release) < 2: | ||
| return None | ||
| return release[0], release[1] | ||
|
|
||
|
|
||
| def get_runtime_info(runtime_version: str) -> Optional[RuntimeInfo]: | ||
| """What the given runtime version ships, or None if unknown.""" | ||
| key = major_minor(runtime_version) | ||
| return _RUNTIMES.get(key) if key else None | ||
|
|
||
|
|
||
| def format_version(version: MajorMinor) -> str: | ||
| return f"{version[0]}.{version[1]}" | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.