Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ jobs:
- name: Test
shell: bash
run: ci/scripts/python_test.sh $(pwd) $(pwd)/build
- name: Test annotations
shell: bash
env:
PYARROW_TEST_ANNOTATIONS: "ON"
run: ci/scripts/python_test_type_annotations.sh $(pwd)/python

windows:
name: AMD64 Windows 2022 Python 3.13
Expand Down Expand Up @@ -296,3 +301,9 @@ jobs:
shell: cmd
run: |
call "ci\scripts\python_test.bat" %cd%
- name: Test annotations
shell: cmd
env:
PYARROW_TEST_ANNOTATIONS: "ON"
run: |
call "ci\scripts\python_test_type_annotations.bat" %cd%\python
40 changes: 40 additions & 0 deletions ci/scripts/python_test_type_annotations.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@rem Licensed to the Apache Software Foundation (ASF) under one
@rem or more contributor license agreements. See the NOTICE file
@rem distributed with this work for additional information
@rem regarding copyright ownership. The ASF licenses this file
@rem to you under the Apache License, Version 2.0 (the
@rem "License"); you may not use this file except in compliance
@rem with the License. You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing,
@rem software distributed under the License is distributed on an
@rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@rem KIND, either express or implied. See the License for the
@rem specific language governing permissions and limitations
@rem under the License.

@echo on

set PYARROW_DIR=%1

if "%PYARROW_TEST_ANNOTATIONS%"=="ON" (
echo Annotation testing on Windows ...

@REM Install library stubs. Note some libraries contain their own type hints so they need to be installed.
%PYTHON_CMD% -m pip install fsspec pandas-stubs scipy-stubs types-cffi types-psutil types-requests types-python-dateutil || exit /B 1

@REM Install type checkers
%PYTHON_CMD% -m pip install mypy pyright ty || exit /B 1

@REM Run type checkers
pushd %PYARROW_DIR%

mypy || exit /B 1
pyright || exit /B 1
ty check || exit /B 1
popd
) else (
echo Annotation testing skipped on Windows ...
)
42 changes: 42 additions & 0 deletions ci/scripts/python_test_type_annotations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

set -ex
pyarrow_dir=${1}

if [ "${PYARROW_TEST_ANNOTATIONS}" == "ON" ]; then
if [ -n "${ARROW_PYTHON_VENV:-}" ]; then
. "${ARROW_PYTHON_VENV}/bin/activate"
fi

# Install library stubs. Note some libraries contain their own type hints so they need to be installed.
pip install fsspec pandas-stubs scipy-stubs types-cffi types-psutil types-requests types-python-dateutil

# Install type checkers
pip install mypy pyright ty

# Run type checkers
pushd ${pyarrow_dir}
mypy
pyright
ty check;
popd
else
echo "Skipping type annotation tests";
fi
5 changes: 5 additions & 0 deletions ci/scripts/python_wheel_macos_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ export CMAKE_PREFIX_PATH=${build_dir}/install
export SETUPTOOLS_SCM_PRETEND_VERSION=${PYARROW_VERSION}

pushd ${source_dir}/python
# We first populate stub docstrings and then build the wheel
python setup.py build_ext --inplace
python -m pip install libcst
python ../dev/update_stub_docstrings.py pyarrow-stubs

python setup.py bdist_wheel
popd

Expand Down
2 changes: 1 addition & 1 deletion ci/scripts/python_wheel_validate_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def validate_wheel(path):
]
assert not outliers, f"Unexpected contents in wheel: {sorted(outliers)}"
print(f"The wheel: {wheels[0]} seems valid.")

# TODO(GH-32609): Validate some docstrings were generated and added.

def main():
parser = argparse.ArgumentParser()
Expand Down
5 changes: 5 additions & 0 deletions ci/scripts/python_wheel_windows_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ set CMAKE_PREFIX_PATH=C:\arrow-dist

pushd C:\arrow\python

@REM We first populate stub docstrings and then build the wheel
%PYTHON_CMD% setup.py build_ext --inplace
%PYTHON_CMD% -m pip install libcst
%PYTHON_CMD% ..\dev\update_stub_docstrings.py pyarrow-stubs

@REM Build wheel
%PYTHON_CMD% setup.py bdist_wheel || exit /B 1

Expand Down
5 changes: 5 additions & 0 deletions ci/scripts/python_wheel_xlinux_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ export ARROW_HOME=/tmp/arrow-dist
export CMAKE_PREFIX_PATH=/tmp/arrow-dist

pushd /arrow/python
# We first populate stub docstrings and then build the wheel
python setup.py build_ext --inplace
python -m pip install libcst
python ../dev/update_stub_docstrings.py pyarrow-stubs

python setup.py bdist_wheel

echo "=== Strip symbols from wheel ==="
Expand Down
16 changes: 12 additions & 4 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,14 @@ services:
environment:
<<: [*common, *ccache, *sccache]
PYTEST_ARGS: # inherit
PYARROW_TEST_ANNOTATIONS: "ON"
volumes: *conda-volumes
command: &python-conda-command
["
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
/arrow/ci/scripts/python_test.sh /arrow"]
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"]

conda-python-emscripten:
# Usage:
Expand Down Expand Up @@ -1001,14 +1003,16 @@ services:
ARROW_S3: "OFF"
ARROW_SUBSTRAIT: "OFF"
ARROW_WITH_OPENTELEMETRY: "OFF"
PYARROW_TEST_ANNOTATIONS: "ON"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raulcd do you think we actually want to be able to toggle these? I'm thinking we don't really need them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is worth it if instead of using a separate ci/scripts/python_test_type_annotations.sh we use ci/scripts/python_test.sh and we use the PYARROW_TEST_ANNOTATIONS variable to manage whether we want annotations to be tested or not as part of python testing.
If we decide we want to have two separate scripts I think this env var should be removed.
I lean towards having a single python test script that can allow us to also test annotations but I can find arguments for both so not an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, agreed with your reasoning. I also introduced PYARROW_TEST_ANNOTATIONS to the windows script.

SETUPTOOLS_SCM_PRETEND_VERSION:
volumes: *ubuntu-volumes
deploy: *cuda-deploy
command: &python-command >
/bin/bash -c "
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
/arrow/ci/scripts/python_test.sh /arrow"
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"

debian-python:
# Usage:
Expand Down Expand Up @@ -1500,6 +1504,7 @@ services:
python: ${PYTHON}
shm_size: *shm-size
environment:
PYARROW_TEST_ANNOTATIONS: "ON"
<<: [*common, *ccache, *sccache]
PARQUET_REQUIRE_ENCRYPTION: # inherit
HYPOTHESIS_PROFILE: # inherit
Expand All @@ -1510,7 +1515,8 @@ services:
/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
mamba uninstall -y numpy &&
/arrow/ci/scripts/python_test.sh /arrow"]
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"]

conda-python-docs:
# Usage:
Expand All @@ -1530,13 +1536,15 @@ services:
BUILD_DOCS_CPP: "ON"
BUILD_DOCS_PYTHON: "ON"
PYTEST_ARGS: "--doctest-modules --doctest-cython"
PYARROW_TEST_ANNOTATIONS: "ON"
volumes: *conda-volumes
command:
["/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
pip install -e /arrow/dev/archery[numpydoc] &&
archery numpydoc --allow-rule GL10,PR01,PR03,PR04,PR05,PR10,RT03,YD01 &&
/arrow/ci/scripts/python_test.sh /arrow"]
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"]

conda-python-dask:
# Possible $DASK parameters:
Expand Down
Loading
Loading