Skip to content

Commit 72f69b0

Browse files
authored
ci: Run PySpark selectively (#2366)
* ci: Run PySpark selectively * pragma no cover for --all-cpu-constructors flag * run py3.10 instead of 3.12 for pyspark
1 parent b204669 commit 72f69b0

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: PyTest PySpark constructor
2+
3+
on:
4+
pull_request:
5+
types: [opened, labeled, synchronize] # Triggers on PR creation, updates, and label changes
6+
7+
env:
8+
PY_COLORS: 1
9+
10+
jobs:
11+
12+
pytest-pyspark-constructor:
13+
if: ${{ contains(github.event.pull_request.labels.*.name, 'pyspark') || contains(github.event.pull_request.labels.*.name, 'release') }}
14+
strategy:
15+
matrix:
16+
python-version: ["3.10", "3.11"]
17+
os: [ubuntu-latest]
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
enable-cache: "true"
28+
cache-suffix: ${{ matrix.python-version }}
29+
cache-dependency-glob: "pyproject.toml"
30+
- name: install-reqs
31+
run: uv pip install -e . --group core-tests --group extra --system
32+
- name: install pyspark
33+
run: echo "setuptools<78" | uv pip install -b - -e ".[pyspark]" --system
34+
- name: show-deps
35+
run: uv pip freeze
36+
- name: Run pytest
37+
run: pytest tests --cov=narwhals/_spark_like --cov-fail-under=95 --runslow --constructors pyspark

.github/workflows/pytest.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ jobs:
8686
run: uv pip install -e ".[modin, dask]" --group core-tests --group extra --system
8787
- name: install duckdb nightly
8888
run: uv pip install -U --pre duckdb --system
89-
- name: install pyspark
90-
run: echo "setuptools<78" | uv pip install -b - -e ".[pyspark]" --system
91-
# PySpark is not yet available on Python3.12+
92-
if: matrix.python-version != '3.13'
9389
- name: install ibis
9490
run: uv pip install -e ".[ibis]" --system
9591
# Ibis puts upper bounds on dependencies, and requires Python3.10+,
@@ -98,7 +94,7 @@ jobs:
9894
- name: show-deps
9995
run: uv pip freeze
10096
- name: Run pytest
101-
run: pytest tests --cov=narwhals --cov=tests --cov-fail-under=100 --runslow --all-cpu-constructors
97+
run: pytest tests --cov=narwhals --cov=tests --cov-fail-under=100 --runslow --constructors=pandas,pandas[nullable],pandas[pyarrow],pyarrow,modin[pyarrow],polars[eager],polars[lazy],dask,duckdb,sqlframe
10298
- name: Run doctests
10399
# reprs differ between versions, so we only run doctests on the latest Python
104100
if: matrix.python-version == '3.13'

tests/conftest.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def sqlframe_pyspark_lazy_constructor(obj: Data) -> SQLFrameDataFrame: # pragma
229229

230230

231231
def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
232-
if metafunc.config.getoption("all_cpu_constructors"):
232+
if metafunc.config.getoption("all_cpu_constructors"): # pragma: no cover
233233
selected_constructors: list[str] = [
234234
*iter(EAGER_CONSTRUCTORS.keys()),
235235
*iter(LAZY_CONSTRUCTORS.keys()),
@@ -250,13 +250,9 @@ def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
250250

251251
for constructor in selected_constructors:
252252
if (
253-
(
254-
constructor in {"pandas[nullable]", "pandas[pyarrow]"}
255-
and MIN_PANDAS_NULLABLE_VERSION > PANDAS_VERSION
256-
)
257-
or (constructor == "sqlframe" and sys.version_info < (3, 9))
258-
or (constructor == "pyspark" and sys.version_info >= (3, 12))
259-
):
253+
constructor in {"pandas[nullable]", "pandas[pyarrow]"}
254+
and MIN_PANDAS_NULLABLE_VERSION > PANDAS_VERSION
255+
) or (constructor == "sqlframe" and sys.version_info < (3, 9)):
260256
continue # pragma: no cover
261257

262258
if constructor in EAGER_CONSTRUCTORS:

0 commit comments

Comments
 (0)