Skip to content

Commit c2f1ca8

Browse files
committed
fix minimum polars version detection
1 parent a9152ba commit c2f1ca8

File tree

8 files changed

+207
-20
lines changed

8 files changed

+207
-20
lines changed

bigframes/_importing.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import importlib
1515
from types import ModuleType
1616

17+
import numpy
1718
from packaging import version
1819

1920
# Keep this in sync with setup.py
@@ -22,9 +23,13 @@
2223

2324
def import_polars() -> ModuleType:
2425
polars_module = importlib.import_module("polars")
25-
imported_version = version.Version(polars_module.build_info()["version"])
26-
if imported_version < POLARS_MIN_VERSION:
26+
# Check for necessary methods instead of the version number because we
27+
# can't trust the polars version until
28+
# https://github.com/pola-rs/polars/issues/23940 is fixed.
29+
try:
30+
polars_module.lit(numpy.int64(100), dtype=polars_module.Int64())
31+
except TypeError:
2732
raise ImportError(
28-
f"Imported polars version: {imported_version} is below the minimum version: {POLARS_MIN_VERSION}"
33+
f"Imported polars version is likely below the minimum version: {POLARS_MIN_VERSION}"
2934
)
3035
return polars_module

noxfile.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,20 @@
7878
]
7979
UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = []
8080
UNIT_TEST_DEPENDENCIES: List[str] = []
81-
UNIT_TEST_EXTRAS: List[str] = ["tests", "anywidget"]
81+
UNIT_TEST_EXTRAS: List[str] = ["tests"]
8282
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
83-
"3.12": ["tests", "polars", "scikit-learn", "anywidget"],
83+
"3.10": ["tests", "polars", "scikit-learn", "anywidget"],
84+
"3.11": ["tests", "polars", "scikit-learn", "anywidget"],
85+
# Make sure we leave some versions without "extras" so we know those
86+
# dependencies are actually optional.
87+
"3.13": ["tests", "polars", "scikit-learn", "anywidget"],
8488
}
8589

90+
# 3.11 is used by colab.
8691
# 3.10 is needed for Windows tests as it is the only version installed in the
8792
# bigframes-windows container image. For more information, search
8893
# bigframes/windows-docker, internally.
89-
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.12", "3.13"]
94+
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.13"]
9095
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
9196
"jinja2",
9297
"mock",
@@ -105,12 +110,13 @@
105110
]
106111
SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = []
107112
SYSTEM_TEST_DEPENDENCIES: List[str] = []
108-
SYSTEM_TEST_EXTRAS: List[str] = []
113+
SYSTEM_TEST_EXTRAS: List[str] = ["tests"]
109114
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {
110-
"3.9": ["tests", "anywidget"],
111-
"3.10": ["tests", "polars"],
112-
"3.12": ["tests", "scikit-learn", "polars", "anywidget"],
113-
"3.13": ["tests", "polars"],
115+
# Make sure we leave some versions without "extras" so we know those
116+
# dependencies are actually optional.
117+
"3.10": ["scikit-learn", "polars", "anywidget"],
118+
"3.11": ["scikit-learn", "polars", "anywidget"],
119+
"3.13": ["polars", "anywidget"],
114120
}
115121

116122
LOGGING_NAME_ENV_VAR = "BIGFRAMES_PERFORMANCE_LOG_NAME"
@@ -120,8 +126,8 @@
120126
# Sessions are executed in the order so putting the smaller sessions
121127
# ahead to fail fast at presubmit running.
122128
nox.options.sessions = [
123-
"system-3.9",
124-
"system-3.12",
129+
"system-3.9", # No extras.
130+
"system-3.11",
125131
"cover",
126132
# TODO(b/401609005): remove
127133
"cleanup",

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
"google-cloud-bigtable >=2.24.0",
7777
"google-cloud-pubsub >=2.21.4",
7878
],
79-
# used for local engine, which is only needed for unit tests at present.
80-
"polars": ["polars >= 1.7.0"],
79+
# used for local engine
80+
"polars": ["polars >= 1.21.0"],
8181
"scikit-learn": ["scikit-learn>=1.2.2"],
8282
# Packages required for basic development flow.
8383
"dev": [

testing/constraints-3.10.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Keep in sync with colab/containers/requirements.core.in image
1+
# When we drop Python 3.9,
2+
# please keep these in sync with the minimum versions in setup.py
23
google-auth==2.27.0
34
ipykernel==5.5.6
45
ipython==7.34.0
@@ -15,4 +16,4 @@ matplotlib==3.7.1
1516
psutil==5.9.5
1617
seaborn==0.13.1
1718
traitlets==5.7.1
18-
polars==1.7.0
19+
polars==1.21.0

testing/constraints-3.11.txt

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Keep in sync with colab/containers/requirements.core.in image.
2+
google-auth==2.38.0
3+
ipykernel==6.17.1
4+
ipython==7.34.0
5+
jupyter-server==1.16.0
6+
ipyparallel==8.8.0
7+
pandas==2.2.2
8+
portpicker==1.5.2
9+
requests==2.32.3
10+
tornado==6.4.2
11+
absl-py==1.4.0
12+
debugpy==1.8.15
13+
ipywidgets==7.7.1
14+
matplotlib==3.10.0
15+
psutil==5.9.5
16+
seaborn==0.13.2
17+
traitlets==5.7.1
18+
# Keep in sync with colab/containers/requirements.in image.
19+
Flask==3.1.0
20+
PyDrive2==1.21.1
21+
PyYAML==6.0
22+
Sphinx==8.2.3
23+
albumentations==2.0.0
24+
albucore==0.0.24
25+
arviz==0.22.0
26+
astropy==7.0
27+
autograd==1.7
28+
bigquery-magics==0.10.2
29+
bottleneck==1.4.0
30+
bokeh==3.7.2
31+
cmake==3.31.2
32+
community==1.0.0b1
33+
cufflinks==0.17.0
34+
cuda-python==12.6.0
35+
cuml-cu12==25.6.0
36+
cupy-cuda12x==13.3.0
37+
cvxopt==1.3.0
38+
cvxpy==1.6.0
39+
cyipopt==1.5.0
40+
cython==3.0.11
41+
dask==2025.5.0
42+
dataproc-spark-connect==0.8.1
43+
datasets==4.0
44+
diffusers==0.33
45+
dlib==19.24.6
46+
dopamine-rl==4.1.0
47+
duckdb==1.3.0
48+
earthengine-api==1.5.0
49+
easydict==1.13
50+
editdistance==0.8.0
51+
einops==0.8.0
52+
fastai==2.7.19
53+
firebase-admin==6.7
54+
folium==0.20
55+
future==1.0.0
56+
gcsfs==2025.3
57+
geemap==0.35.1
58+
geopandas==1.1
59+
geopy==2.4.0
60+
glob2==0.7
61+
google-api-core==2.24
62+
google-api-python-client==2.167
63+
google-auth-httplib2==0.2.0
64+
google-cloud-aiplatform==1.85
65+
google-cloud-bigquery==3.31
66+
google-cloud-bigquery-connection==1.18
67+
google-cloud-core==2.4
68+
google-cloud-datastore==2.20
69+
google-cloud-firestore==2.20
70+
google-cloud-functions==1.20
71+
google-cloud-language==2.17
72+
google-cloud-translate==3.20
73+
google-generativeai==0.8
74+
googledrivedownloader==1.1.0
75+
gradio==5.37
76+
graphviz==0.20
77+
gym==0.25.0
78+
h5py==3.13
79+
hdbscan==0.8
80+
highspy==1.10
81+
holidays==0.66
82+
holoviews==1.20
83+
html5lib==1.1
84+
httpimport==1.4
85+
humanize==4.12
86+
hyperopt==0.2
87+
ibis-framework==9.5.0
88+
imageio==2.37
89+
imbalanced-learn==0.13
90+
imutils==0.5
91+
inflect==7.5
92+
ipyleaflet==0.19
93+
ipython-sql==0.5
94+
jieba==0.42
95+
jinja2==3.1
96+
jsonschema==4.23
97+
jupytext==1.17.1
98+
keyrings.google-artifactregistry-auth==1.1.2
99+
langchain==0.3.20
100+
libpysal==4.13.0
101+
lightgbm==4.6.0
102+
lxml==5.4
103+
matplotlib-venn==1.1
104+
missingno==0.5
105+
mizani==0.13.0
106+
mkl==2025.2.0
107+
mlxtend==0.23
108+
more-itertools==10.7
109+
moviepy==1.0.3
110+
music21==9.3.0
111+
natsort==8.4
112+
nbconvert==7.16
113+
nibabel==5.3
114+
numba==0.60.0
115+
oauth2client==4.0
116+
openai==1.94
117+
opencv-contrib-python==4.12
118+
opencv-python==4.12
119+
openpyxl==3.1
120+
pandas-datareader==0.10
121+
pandas-gbq==0.28
122+
peft==0.15
123+
pillow==11.3.0
124+
plotnine==0.14.0
125+
polars==1.25.2
126+
progressbar2==4.5.0
127+
prophet==1.1.6
128+
protobuf==5.29.5
129+
psycopg2==2.9.10
130+
pyarrow==18.1.0
131+
pycocotools==2.0.8
132+
pydotplus==2.0.2
133+
pydot==3.0.0
134+
pygit2==1.17
135+
pygments==2.18
136+
pygobject==3.42
137+
pymc==5.24
138+
pyomo==6.8
139+
pyopengl==3.1.7
140+
pyspark==3.5
141+
python-dateutil==2.8
142+
python-louvain==0.16
143+
pytz==2025.1
144+
regex==2024.11.6
145+
sentence-transformers==5.0
146+
shap==0.47
147+
spanner-graph-notebook==1.1
148+
sqlalchemy==2.0.36
149+
statsmodels==0.14.0
150+
sympy==1.13.0
151+
tables==3.10.1
152+
tabulate==0.9.0
153+
tensorboard==2.19.0
154+
tensorflow==2.19.0
155+
tensorflow-decision-forests==1.12.0
156+
tensorflow-hub==0.16.1
157+
tf-keras==2.19.0
158+
keras==3.10.0
159+
keras-hub==0.21.1
160+
keras-nlp==0.21.1
161+
textblob==0.19.0
162+
timm==1.0.17
163+
torchao==0.10.0
164+
torchsummary==1.5.1
165+
torchtune==0.6.1
166+
tsfresh==0.21.0
167+
tweepy==4.16
168+
umap-learn==0.5.0
169+
wandb==0.21
170+
wordcloud==1.9.0
171+
xarray==2025.7
172+
xgboost==3.0
173+
xlrd==2.0.1
174+
yellowbrick==1.5
175+
yfinance==0.2

tests/system/small/test_polars_execution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import bigframes
1717
from bigframes.testing.utils import assert_pandas_df_equal
1818

19-
polars = pytest.importorskip("polars", minversion="1.7.0")
19+
polars = pytest.importorskip("polars")
2020

2121

2222
@pytest.fixture(scope="module")

tests/unit/test_dataframe_polars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
convert_pandas_dtypes,
3939
)
4040

41-
pytest.importorskip("polars", minversion="1.7.0")
41+
pytest.importorskip("polars")
4242
pytest.importorskip("pandas", minversion="2.0.0")
4343

4444
CURRENT_DIR = pathlib.Path(__file__).parent

tests/unit/test_local_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import bigframes
2121
import bigframes.pandas as bpd
2222

23-
pytest.importorskip("polars", minversion="1.7.0")
23+
pytest.importorskip("polars")
2424
pytest.importorskip("pandas", minversion="2.0.0")
2525

2626

0 commit comments

Comments
 (0)