Skip to content

Commit b7abaf9

Browse files
authored
ci: Make it a bit greener (#3241)
* ci: Make it a bit greener * skip scan parquet sqlframe+windows case * change get_categories from elementwise to filtration, change fixture name * more pinning
1 parent 0989acc commit b7abaf9

File tree

11 files changed

+56
-31
lines changed

11 files changed

+56
-31
lines changed

.github/workflows/downstream_tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ jobs:
187187
run: |
188188
cd py-shiny
189189
. .venv/bin/activate
190+
# temporary pin to get CI green
191+
uv pip install "flake8-bugbear<25.10.21"
190192
make narwhals-install-shiny
191193
- name: install-narwhals-dev
192194
run: |

.github/workflows/pytest-pyspark.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ jobs:
7474
java-version: 17
7575

7676
- name: install-reqs
77-
run: uv pip install -e . --group core-tests --group extra --system
77+
# temporary pin to get CI green
78+
run: uv pip install -e . --group core-tests --group extra "pyarrow<22.0" --system
7879
- name: install pyspark
7980
run: echo "setuptools<78" | uv pip install -e . "pyspark[connect]==${SPARK_VERSION}" --system
8081
- name: show-deps

.github/workflows/pytest.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,9 @@ jobs:
141141
enable-cache: "true"
142142
cache-suffix: python-314-${{ matrix.python-version }}
143143
cache-dependency-glob: "pyproject.toml"
144-
- name: install pyarrow nightly
145-
run: |
146-
uv pip uninstall pyarrow --system
147-
uv pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pyarrow -U --system
148144
- name: install-reqs
149145
# Use `--pre` as duckdb stable not compatible with 3.14
150-
run: uv pip install -e . --group tests --pre pandas polars duckdb sqlframe --system
146+
run: uv pip install -e . --group tests --pre pandas polars pyarrow duckdb sqlframe --system
151147
- name: show-deps
152148
run: uv pip freeze
153149
- name: Run pytest
@@ -172,12 +168,8 @@ jobs:
172168
enable-cache: "true"
173169
cache-suffix: python-314t-${{ matrix.python-version }}
174170
cache-dependency-glob: "pyproject.toml"
175-
- name: install pyarrow nightly
176-
run: |
177-
uv pip uninstall pyarrow --system
178-
uv pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pyarrow -U --system
179171
- name: install-reqs
180-
run: uv pip install -e . --group tests --pre pandas --system
172+
run: uv pip install -e . --group tests --pre pandas pyarrow --system
181173
- name: show-deps
182174
run: uv pip freeze
183175
- name: Run pytest

narwhals/expr_cat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ def get_categories(self) -> ExprT:
3434
│ mango │
3535
└────────┘
3636
"""
37-
return self._expr._with_elementwise(
37+
return self._expr._with_filtration(
3838
lambda plx: self._expr._to_compliant_expr(plx).cat.get_categories()
3939
)

tests/expr_and_series/cat/get_categories_test.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import pytest
44

55
import narwhals as nw
6+
from narwhals.exceptions import InvalidOperationError
67
from tests.utils import PYARROW_VERSION, ConstructorEager, assert_equal_data
78

89
data = {"a": ["one", "two", "two"]}
910

1011

11-
def test_get_categories(constructor_eager: ConstructorEager) -> None:
12+
def test_get_categories_eager(constructor_eager: ConstructorEager) -> None:
1213
if "pyarrow_table" in str(constructor_eager) and PYARROW_VERSION < (15, 0, 0):
1314
pytest.skip()
1415

@@ -23,6 +24,21 @@ def test_get_categories(constructor_eager: ConstructorEager) -> None:
2324
assert_equal_data({"a": result_series}, expected)
2425

2526

27+
def test_get_categories_lazy(constructor_eager: ConstructorEager) -> None:
28+
if "pyarrow_table" in str(constructor_eager) and PYARROW_VERSION < (15, 0, 0):
29+
pytest.skip()
30+
31+
df = nw.from_native(constructor_eager(data)).lazy()
32+
expr = nw.col("a").cast(nw.Categorical).cat.get_categories()
33+
msg = "Length-changing expressions are not supported for use in LazyFrame"
34+
with pytest.raises(InvalidOperationError, match=msg):
35+
df.select(expr).collect()
36+
37+
result = df.select(expr.min())
38+
expected = {"a": ["one"]}
39+
assert_equal_data(result, expected)
40+
41+
2642
def test_get_categories_pyarrow() -> None:
2743
pytest.importorskip("pyarrow")
2844
import pyarrow as pa

tests/expr_and_series/cum_min_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
DUCKDB_VERSION,
88
PANDAS_VERSION,
99
POLARS_VERSION,
10+
PYARROW_VERSION,
1011
Constructor,
1112
ConstructorEager,
1213
assert_equal_data,
@@ -97,7 +98,7 @@ def test_lazy_cum_min_ordered_by_nulls(
9798
if "cudf" in str(constructor):
9899
# https://github.com/rapidsai/cudf/issues/18159
99100
request.applymarker(pytest.mark.xfail)
100-
if "pyarrow" in str(constructor) and is_windows():
101+
if "pyarrow" in str(constructor) and is_windows() and PYARROW_VERSION < (22, 0):
101102
# https://github.com/pandas-dev/pandas/issues/62477
102103
request.applymarker(pytest.mark.xfail)
103104

tests/expr_and_series/cum_sum_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from tests.utils import (
77
DUCKDB_VERSION,
88
POLARS_VERSION,
9+
PYARROW_VERSION,
910
Constructor,
1011
ConstructorEager,
1112
assert_equal_data,
@@ -98,7 +99,7 @@ def test_lazy_cum_sum_ordered_by_nulls(
9899
if "cudf" in str(constructor):
99100
# https://github.com/rapidsai/cudf/issues/18159
100101
request.applymarker(pytest.mark.xfail)
101-
if "pyarrow" in str(constructor) and is_windows():
102+
if "pyarrow" in str(constructor) and is_windows() and PYARROW_VERSION < (22, 0):
102103
# https://github.com/pandas-dev/pandas/issues/62477
103104
request.applymarker(pytest.mark.xfail)
104105

tests/expr_and_series/dt/truncate_test.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
import narwhals as nw
10-
from tests.utils import Constructor, ConstructorEager, assert_equal_data
10+
from tests.utils import POLARS_VERSION, Constructor, ConstructorEager, assert_equal_data
1111

1212
data = {
1313
"a": [datetime(2021, 3, 1, 12, 34, 56, 49012), datetime(2020, 1, 2, 2, 4, 14, 715123)]
@@ -54,9 +54,13 @@ def test_truncate(
5454
expected: list[datetime],
5555
) -> None:
5656
if every.endswith("ns") and any(
57-
x in str(constructor) for x in ("polars", "duckdb", "pyspark", "ibis")
57+
x in str(constructor) for x in ("duckdb", "pyspark", "ibis")
5858
):
5959
request.applymarker(pytest.mark.xfail())
60+
61+
if every.endswith("ns") and "polars" in str(constructor) and POLARS_VERSION < (1, 35):
62+
request.applymarker(pytest.mark.xfail())
63+
6064
if any(every.endswith(x) for x in ("mo", "q", "y")) and any(
6165
x in str(constructor) for x in ("dask", "cudf")
6266
):
@@ -109,14 +113,16 @@ def test_truncate_multiples(
109113
# - cudf: https://github.com/rapidsai/cudf/issues/18654
110114
# - pyspark/sqlframe: Only multiple 1 is currently supported
111115
request.applymarker(pytest.mark.xfail())
112-
if every.endswith("ns") and any(
113-
x in str(constructor) for x in ("polars", "duckdb", "ibis")
114-
):
116+
117+
if every.endswith("ns") and any(x in str(constructor) for x in ("duckdb", "ibis")):
115118
request.applymarker(pytest.mark.xfail())
116-
if any(every.endswith(x) for x in ("mo", "q", "y")) and any(
117-
x in str(constructor) for x in ("dask",)
118-
):
119+
120+
if every.endswith("ns") and "polars" in str(constructor) and POLARS_VERSION < (1, 35):
121+
request.applymarker(pytest.mark.xfail())
122+
123+
if any(every.endswith(x) for x in ("mo", "q", "y")) and "dask" in str(constructor):
119124
request.applymarker(pytest.mark.xfail(reason="Not implemented"))
125+
120126
df = nw.from_native(constructor(data))
121127
result = df.select(nw.col("a").dt.truncate(every))
122128
assert_equal_data(result, {"a": expected})

tests/read_scan_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PANDAS_VERSION,
1212
Constructor,
1313
assert_equal_data,
14+
is_windows,
1415
pyspark_session,
1516
sqlframe_session,
1617
)
@@ -141,6 +142,10 @@ def test_read_parquet_raise_with_lazy(backend: _LazyOnly) -> None:
141142
@skipif_pandas_lt_1_5
142143
def test_scan_parquet(parquet_path: FileSource, constructor: Constructor) -> None:
143144
kwargs: dict[str, Any]
145+
if "sqlframe" in str(constructor) and is_windows():
146+
reason = "_duckdb.IOException: IO Error: No files found that match the pattern"
147+
pytest.skip(reason)
148+
144149
if "sqlframe" in str(constructor):
145150
kwargs = {"session": sqlframe_session(), "inferSchema": True}
146151
elif "pyspark" in str(constructor):

tests/testing/assert_series_equal_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def series_from_native(native: IntoSeriesT) -> nw.Series[IntoSeriesT]:
3131

3232

3333
def test_self_equal(
34-
constructor_eager: ConstructorEager, data: Data, schema: IntoSchema
34+
constructor_eager: ConstructorEager, testing_data: Data, testing_schema: IntoSchema
3535
) -> None:
3636
"""Test that a series is equal to itself, including nested dtypes with nulls."""
3737
if "pandas" in str(constructor_eager):
@@ -52,9 +52,10 @@ def test_self_equal(
5252

5353
if "pyarrow_table" in str(constructor_eager):
5454
# Replace Enum with Categorical, since Pyarrow does not support Enum
55-
schema = {**schema, "enum": nw.Categorical()}
56-
57-
df = nw.from_native(constructor_eager(data), eager_only=True)
55+
schema = {**testing_schema, "enum": nw.Categorical()}
56+
else:
57+
schema = dict(testing_schema) # make a copy
58+
df = nw.from_native(constructor_eager(testing_data), eager_only=True)
5859
for name, dtype in schema.items():
5960
assert_series_equal(df[name].cast(dtype), df[name].cast(dtype))
6061

0 commit comments

Comments
 (0)