Skip to content

Commit 9254e89

Browse files
Yicong-HuangHyukjinKwon
authored andcommitted
[SPARK-55263][PYTHON][INFRA] Upgrade Python linter from 3.11 to 3.12 in CI
### What changes were proposed in this pull request? Upgrade Python linter from Python 3.11 to Python 3.12 in CI to match the test environment. ### Why are the changes needed? The CI test environment has been upgraded to use Python 3.12 as the default version, but the Python linter was still using Python 3.11, creating an inconsistency. ### Does this PR introduce _any_ user-facing change? No. This is an internal CI infrastructure change that does not affect end users. ### How was this patch tested? CI. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #54042 from Yicong-Huang/SPARK-55263/feat/upgrade-python-linter-to-3.12. Authored-by: Yicong-Huang <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent 23afba2 commit 9254e89

File tree

6 files changed

+31
-19
lines changed

6 files changed

+31
-19
lines changed

.github/workflows/build_and_test.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,18 @@ jobs:
884884
if [ -f ./dev/structured_logging_style.py ]; then
885885
python3.9 ./dev/structured_logging_style.py
886886
fi
887-
- name: Scala structured logging check
888-
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0'
887+
- name: Scala structured logging check for branch-4.1
888+
if: inputs.branch == 'branch-4.1'
889889
run: |
890890
if [ -f ./dev/structured_logging_style.py ]; then
891891
python3.11 ./dev/structured_logging_style.py
892892
fi
893+
- name: Scala structured logging check
894+
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0' && inputs.branch != 'branch-4.1'
895+
run: |
896+
if [ -f ./dev/structured_logging_style.py ]; then
897+
python3.12 ./dev/structured_logging_style.py
898+
fi
893899
- name: Java linter
894900
run: ./dev/lint-java
895901
- name: Spark connect jvm client mima check
@@ -904,15 +910,21 @@ jobs:
904910
- name: List Python packages for branch-3.5 and branch-4.0
905911
if: inputs.branch == 'branch-3.5' || inputs.branch == 'branch-4.0'
906912
run: python3.9 -m pip list
907-
- name: List Python packages
908-
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0'
913+
- name: List Python packages for branch-4.1
914+
if: inputs.branch == 'branch-4.1'
909915
run: python3.11 -m pip list
916+
- name: List Python packages
917+
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0' && inputs.branch != 'branch-4.1'
918+
run: python3.12 -m pip list
910919
- name: Python linter for branch-3.5 and branch-4.0
911920
if: inputs.branch == 'branch-3.5' || inputs.branch == 'branch-4.0'
912921
run: PYTHON_EXECUTABLE=python3.9 ./dev/lint-python
913-
- name: Python linter
914-
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0'
922+
- name: Python linter for branch-4.1
923+
if: inputs.branch == 'branch-4.1'
915924
run: PYTHON_EXECUTABLE=python3.11 ./dev/lint-python
925+
- name: Python linter
926+
if: inputs.branch != 'branch-3.5' && inputs.branch != 'branch-4.0' && inputs.branch != 'branch-4.1'
927+
run: PYTHON_EXECUTABLE=python3.12 ./dev/lint-python
916928
# Should delete this section after SPARK 3.5 EOL.
917929
- name: Install dependencies for Python code generation check for branch-3.5
918930
if: inputs.branch == 'branch-3.5'

dev/spark-test-image/lint/Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LABEL org.opencontainers.image.ref.name="Apache Spark Infra Image for Linter"
2424
# Overwrite this label to avoid exposing the underlying Ubuntu OS version label
2525
LABEL org.opencontainers.image.version=""
2626

27-
ENV FULL_REFRESH_DATE=20250618
27+
ENV FULL_REFRESH_DATE=20260129
2828

2929
ENV DEBIAN_FRONTEND=noninteractive
3030
ENV DEBCONF_NONINTERACTIVE_SEEN=true
@@ -67,17 +67,17 @@ RUN Rscript -e "install.packages(c('devtools', 'knitr', 'markdown', 'rmarkdown',
6767
# See more in SPARK-39735
6868
ENV R_LIBS_SITE="/usr/local/lib/R/site-library:${R_LIBS_SITE}:/usr/lib/R/library"
6969

70-
# Install Python 3.11
70+
# Install Python 3.12
7171
RUN add-apt-repository ppa:deadsnakes/ppa
7272
RUN apt-get update && apt-get install -y \
73-
python3.11 \
73+
python3.12 \
7474
&& apt-get autoremove --purge -y \
7575
&& apt-get clean \
7676
&& rm -rf /var/lib/apt/lists/*
7777

7878

79-
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
80-
RUN python3.11 -m pip install \
79+
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
80+
RUN python3.12 -m pip install \
8181
'black==23.12.1' \
8282
'flake8==3.9.0' \
8383
'ruff==0.14.8' \
@@ -101,6 +101,6 @@ RUN python3.11 -m pip install \
101101
'pytest==7.1.3' \
102102
'scipy>=1.8.0' \
103103
'scipy-stubs' \
104-
&& python3.11 -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu \
105-
&& python3.11 -m pip install torcheval \
106-
&& python3.11 -m pip cache purge
104+
&& python3.12 -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu \
105+
&& python3.12 -m pip install torcheval \
106+
&& python3.12 -m pip cache purge

python/pyspark/ml/linalg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def dot(self, other: Iterable[float]) -> np.float64:
404404
elif isinstance(other, Vector):
405405
return np.dot(self.toArray(), other.toArray())
406406
else:
407-
return np.dot(self.toArray(), other) # type: ignore[call-overload]
407+
return np.dot(self.toArray(), other)
408408

409409
def squared_distance(self, other: Iterable[float]) -> np.float64:
410410
"""

python/pyspark/mllib/linalg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def dot(self, other: "VectorLike") -> np.float64:
457457
elif isinstance(other, Vector):
458458
return np.dot(self.toArray(), other.toArray())
459459
else:
460-
return np.dot(self.toArray(), cast("ArrayLike", other))
460+
return np.dot(self.toArray(), cast("ArrayLike", other)) # type: ignore[valid-type]
461461

462462
def squared_distance(self, other: "VectorLike") -> np.float64:
463463
"""

python/pyspark/pandas/indexes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def to_numpy(self, dtype: Optional[Union[str, Dtype]] = None, copy: bool = False
547547
"It should only be used if the resulting NumPy ndarray is expected to be small."
548548
)
549549
result = np.asarray(
550-
self._to_internal_pandas()._values, dtype=dtype # type: ignore[arg-type,attr-defined]
550+
self._to_internal_pandas()._values, dtype=dtype # type: ignore[attr-defined]
551551
)
552552
if copy:
553553
result = result.copy()

python/pyspark/pandas/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,9 @@ def cov(self, other: "Series", min_periods: Optional[int] = None, ddof: int = 1)
10821082
"""
10831083
if not isinstance(other, Series):
10841084
raise TypeError("unsupported type: %s" % type(other))
1085-
if not np.issubdtype(self.dtype, np.number): # type: ignore[arg-type]
1085+
if not np.issubdtype(self.dtype, np.number):
10861086
raise TypeError("unsupported dtype: %s" % self.dtype)
1087-
if not np.issubdtype(other.dtype, np.number): # type: ignore[arg-type]
1087+
if not np.issubdtype(other.dtype, np.number):
10881088
raise TypeError("unsupported dtype: %s" % other.dtype)
10891089
if not isinstance(ddof, int):
10901090
raise TypeError("ddof must be integer")

0 commit comments

Comments
 (0)