Skip to content

Commit ad7f1a5

Browse files
DrTodd13Todd A. Anderson
andauthored
First attempt at adding Narwhals to test suite. (#918)
Co-authored-by: Todd A. Anderson <toddanderson@bodo.ai>
1 parent 831570f commit ad7f1a5

2 files changed

Lines changed: 96 additions & 36 deletions

File tree

.github/workflows/_test_python_source.yml

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ on:
2323
required: false
2424
default: 'ubuntu-latest'
2525
type: string
26-
# Options: DF_LIB, DF_LIB_NO_JIT, SPAWN, NORMAL
26+
# Options: DF_LIB, DF_LIB_NO_JIT, SPAWN, NORMAL, NARWHALS
2727
test-type:
2828
type: string
2929
description: The kind of tests to run e.g. spawn tests
3030
required: true
31+
bodo-version:
32+
type: string
33+
description: The version string of Bodo.
34+
required: true
3135

3236
jobs:
3337
run:
@@ -43,6 +47,8 @@ jobs:
4347
uses: ./.github/actions/build-source
4448
with:
4549
build-all: true
50+
env:
51+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ inputs.bodo-version }}
4652
- name: Load Hadoop from Cache
4753
if: runner.os != 'Windows'
4854
uses: actions/cache/restore@v4
@@ -66,6 +72,10 @@ jobs:
6672
run: |
6773
pip install transformers
6874
pip install --no-deps 'git+https://github.com/apache/polaris.git@release/1.0.x#subdirectory=client/python'
75+
- name: Install Narwhals Test dependencies
76+
if: ${{ inputs.test-type == 'NARWHALS' }}
77+
run: |
78+
pip install hypothesis polars sqlframe ibis-framework pyarrow-hotfix
6979
7080
# Run Tests
7181
- name: Run Tests
@@ -81,40 +91,50 @@ jobs:
8191
fi
8292
8393
set +eo pipefail
84-
# Bodo Tests: Coverage is collected
85-
pytest -s -v -Wignore \
86-
--cov-report= --cov=bodo \
87-
--splits=${{ inputs.total-batches }} --group=${{ inputs.batch }} \
88-
--store-durations --clean-durations \
89-
--durations-path=buildscripts/github/test_dur_bodo.json \
90-
-m "$PYTEST_MARKER" $PYTEST_IGNORE bodo/tests/
9194
92-
# Save Exit Code for Later
93-
python_test_exit_code=$?
95+
if [[ "${{ inputs.test-type }}" == "NARWHALS" ]]; then
96+
# Checkout narwhals fork
97+
git clone https://github.com/bodo-ai/narwhals.git
98+
cd narwhals
99+
python -c "import bodo; print('Detected Bodo version:', bodo.__version__)"
100+
pytest -s -v -Wignore -k bodo
101+
exit $?
102+
else
103+
# Bodo Tests: Coverage is collected
104+
pytest -s -v -Wignore \
105+
--cov-report= --cov=bodo \
106+
--splits=${{ inputs.total-batches }} --group=${{ inputs.batch }} \
107+
--store-durations --clean-durations \
108+
--durations-path=buildscripts/github/test_dur_bodo.json \
109+
-m "$PYTEST_MARKER" $PYTEST_IGNORE bodo/tests/
94110
95-
# BodoSQL Tests
96-
cd BodoSQL
97-
pytest -s -v -Wignore \
98-
--splits=${{ inputs.total-batches }} --group=${{ inputs.batch }} \
99-
--store-durations --clean-durations \
100-
--durations-path=../buildscripts/github/test_dur_bodosql.json \
101-
-m "$PYTEST_MARKER" bodosql/tests/
102-
sql_test_exit_code=$?
111+
# Save Exit Code for Later
112+
python_test_exit_code=$?
103113
104-
# Pytest exits code 5 if no tests are run. Some markers are only in python or sql
105-
# so we suppress this.
106-
if [ "$python_test_exit_code" -eq 5 ]; then
107-
python_test_exit_code=0
108-
fi
109-
if [ "$sql_test_exit_code" -eq 5 ]; then
110-
sql_test_exit_code=0
111-
fi
114+
# BodoSQL Tests
115+
cd BodoSQL
116+
pytest -s -v -Wignore \
117+
--splits=${{ inputs.total-batches }} --group=${{ inputs.batch }} \
118+
--store-durations --clean-durations \
119+
--durations-path=../buildscripts/github/test_dur_bodosql.json \
120+
-m "$PYTEST_MARKER" bodosql/tests/
121+
sql_test_exit_code=$?
112122
113-
# Merge Exit Codes.
114-
# If neither Bodo nor BodoSQL fails, the exit code will be 0
115-
# If one fails, the exit code will be 1
116-
# If both fail, the exit code will be 2
117-
exit $((python_test_exit_code + sql_test_exit_code))
123+
# Pytest exits code 5 if no tests are run. Some markers are only in python or sql
124+
# so we suppress this.
125+
if [ "$python_test_exit_code" -eq 5 ]; then
126+
python_test_exit_code=0
127+
fi
128+
if [ "$sql_test_exit_code" -eq 5 ]; then
129+
sql_test_exit_code=0
130+
fi
131+
132+
# Merge Exit Codes.
133+
# If neither Bodo nor BodoSQL fails, the exit code will be 0
134+
# If one fails, the exit code will be 1
135+
# If both fail, the exit code will be 2
136+
exit $((python_test_exit_code + sql_test_exit_code))
137+
fi
118138
shell: bash
119139
env:
120140
BODO_TESTING_ONLY_RUN_1D_VAR: true
@@ -128,6 +148,7 @@ jobs:
128148
BODO_TEST_SPAWN_MODE: ${{ inputs.test-type == 'SPAWN' && '1' || '0' }}
129149
# Disabling the DataFrame library for spawn tests since some of the tests
130150
# create Pandas manager states for testing that are not fully functional.
151+
BODO_DATAFRAME_LIBRARY_WARN: ${{ inputs.test-type == 'NARWHALS' && '0' || '1' }}
131152
BODO_ENABLE_DATAFRAME_LIBRARY: ${{ inputs.test-type != 'SPAWN' && '1' || '0' }}
132153
BODO_ENABLE_TEST_DATAFRAME_LIBRARY: ${{ startsWith(inputs.test-type, 'DF_LIB') && '1' || '0' }}
133154
BODOSQL_PY4J_GATEWAY_PORT: "auto"

.github/workflows/pr_ci.yml

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19+
get_version:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@v5
24+
with:
25+
# For setuptools_scm to be able to determine version,
26+
# we need to fetch the entire history
27+
fetch-depth: 0
28+
- name: Get Version
29+
id: get_version
30+
run: |
31+
set -exo pipefail
32+
pip install setuptools_scm
33+
# Print to the logs
34+
echo "bodo_version=$(python -m setuptools_scm)"
35+
echo "bodo_version=$(python -m setuptools_scm)" >> "$GITHUB_OUTPUT"
36+
outputs:
37+
bodo_version: ${{ steps.get_version.outputs.bodo_version }}
1938

2039
# 1) Validate changes and commit message
2140
validate:
@@ -107,7 +126,7 @@ jobs:
107126

108127
# 4) Actually run tests
109128
pr-ci:
110-
needs: [compile-bodo]
129+
needs: [compile-bodo, get_version]
111130
name: Test Compiler
112131
strategy:
113132
matrix:
@@ -122,10 +141,11 @@ jobs:
122141
collect-coverage: true
123142
os: ${{ inputs.runner_os || 'ubuntu-latest' }}
124143
test-type: NORMAL
144+
bodo-version: ${{ needs.get_version.outputs.bodo_version }}
125145
secrets: inherit
126146

127147
spawn-ci:
128-
needs: [compile-bodo]
148+
needs: [compile-bodo, get_version]
129149
name: Test Spawn
130150
uses: ./.github/workflows/_test_python_source.yml
131151
with:
@@ -135,10 +155,11 @@ jobs:
135155
collect-coverage: true
136156
os: ${{ inputs.runner_os || 'ubuntu-latest' }}
137157
test-type: SPAWN
158+
bodo-version: ${{ needs.get_version.outputs.bodo_version }}
138159
secrets: inherit
139160

140161
df-lib-non-jit-ci:
141-
needs: [compile-bodo]
162+
needs: [compile-bodo, get_version]
142163
name: Test DF Library Non-JIT
143164
uses: ./.github/workflows/_test_python_source.yml
144165
with:
@@ -148,10 +169,11 @@ jobs:
148169
collect-coverage: true
149170
os: ${{ inputs.runner_os || 'ubuntu-latest' }}
150171
test-type: "DF_LIB_NO_JIT"
172+
bodo-version: ${{ needs.get_version.outputs.bodo_version }}
151173
secrets: inherit
152174

153175
df-lib-ci:
154-
needs: [compile-bodo]
176+
needs: [compile-bodo, get_version]
155177
name: Test DF Library
156178
strategy:
157179
matrix:
@@ -166,10 +188,25 @@ jobs:
166188
collect-coverage: true
167189
os: ${{ inputs.runner_os || 'ubuntu-latest' }}
168190
test-type: "DF_LIB"
191+
bodo-version: ${{ needs.get_version.outputs.bodo_version }}
192+
secrets: inherit
193+
194+
narwhals-ci:
195+
needs: [compile-bodo, get_version]
196+
name: Test Narwhals Bodo Integration
197+
uses: ./.github/workflows/_test_python_source.yml
198+
with:
199+
batch: 1
200+
total-batches: 1
201+
pytest-marker: ""
202+
collect-coverage: false
203+
os: ${{ inputs.runner_os || 'ubuntu-latest' }}
204+
test-type: NARWHALS
205+
bodo-version: ${{ needs.get_version.outputs.bodo_version }}
169206
secrets: inherit
170207

171208
bodosql-cpp-ci:
172-
needs: [compile-bodo]
209+
needs: [compile-bodo, get_version]
173210
name: Test BodoSQL C++ Backend
174211
uses: ./.github/workflows/_test_python_source.yml
175212
with:
@@ -179,6 +216,7 @@ jobs:
179216
collect-coverage: true
180217
os: ${{ inputs.runner_os || 'ubuntu-latest' }}
181218
test-type: "BODOSQL_CPP"
219+
bodo-version: ${{ needs.get_version.outputs.bodo_version }}
182220
secrets: inherit
183221

184222
java-ci:
@@ -268,6 +306,7 @@ jobs:
268306
- collect-results
269307
- df-lib-ci
270308
- df-lib-non-jit-ci
309+
- narwhals-ci
271310
- bodosql-cpp-ci
272311
- validate
273312
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)