-
Notifications
You must be signed in to change notification settings - Fork 4
266 lines (227 loc) · 8.33 KB
/
python.yml
File metadata and controls
266 lines (227 loc) · 8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python
on:
push:
pull_request:
schedule:
# Run daily at 00:00 so we get notified if CI is broken before a pull request is submitted.
# It also notifies us about new Arrow releases for which we need to release a corresponding version of PalletJack.
- cron: '0 0 * * *'
permissions:
contents: read
jobs:
format:
if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Run Black (check only)
run: |
python3 -m pip install black
black --check --diff --color .
- name: Lint with flake8
run: |
python3 -m pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
test:
if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
runs-on: ubuntu-latest
strategy:
matrix:
mode: [None, io_uring, io_uring_odirect]
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Set environment variables
run: |
if [[ "${{ matrix.mode }}" != "None" ]]; then
echo "JJ_READER_BACKEND=${{ matrix.mode }}" >> $GITHUB_ENV
fi
- name: Install dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip
python3 -m pip install torch --index-url https://download.pytorch.org/whl/cpu
python3 -m pip install -r requirements.txt
python3 -m pip install pytest
- name: Test with pytest
run: |
sudo apt-get install liburing-dev
pip install --editable .
pytest
build-wheels:
if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: [ubuntu-24.04-arm, ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install flake8 pytest cibuildwheel build
- name: Build sdist (Linux)
if: runner.os == 'linux'
run: |
python3 -m build --sdist
- name: Build wheels
run: python3 -m cibuildwheel --output-dir dist
env:
CIBW_BUILD_VERBOSITY: 1
- uses: actions/upload-artifact@v7
with:
name: dist-${{ matrix.runner }}
path: ./dist/*
test-binary:
needs: build-wheels
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: [ubuntu-24.04-arm, ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Setup torch
run: |
python3 -m pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Test with pytest
run: |
python3 -m pip install -r requirements.txt
python3 -m pip install pytest
# Keep in mind that if the local and remote versions are the same, the remote version will be installed
python3 -m pip install JollyJack --pre --find-links ./dist --break-system-packages --only-binary=:all:
# So now ensure that the local version is installed
python3 -m pip install JollyJack --pre --find-links ./dist --break-system-packages --only-binary=:all: --force-reinstall --no-index --no-deps
python3 test/test_jollyjack.py
test-binary-manylinux:
needs: build-wheels
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["cp310-cp310", "cp311-cp311", "cp312-cp312", "cp313-cp313", "cp314-cp314"]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Build and Run Docker Container for Tests
run: |
# Build the Docker image with Python version as build arg
docker build \
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \
-t jollyjack-test-py${{ matrix.python-version }} \
--progress plain \
-f Dockerfile.test .
docker run jollyjack-test-py${{ matrix.python-version }}
# Virtual job that can be configured as a required check before a PR can be merged.
# As GitHub considers a check as successful if it is skipped, we need to check its status in
# another workflow (check-required.yml) and create a check there.
all-required-checks-done:
name: All required checks done
needs:
- test
- build-wheels
- test-binary
- test-binary-manylinux
runs-on: ubuntu-latest
steps:
- run: echo "All required checks done"
benchmarks:
needs: build-wheels
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
mode: [CPU, FILE_SYSTEM]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Setup torch
run: |
python3 -m pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Run benchmarks
run: |
python3 -m pip install -r requirements.txt
# Keep in mind that if the local and remote versions are the same, the remote version will be installed
pip install JollyJack --pre --find-links ./dist --break-system-packages --only-binary=:all:
# So now ensure that the local version is installed
pip install JollyJack --pre --find-links ./dist --break-system-packages --only-binary=:all: --force-reinstall --no-index --no-deps
python3 ./benchmarks/benchmark_jollyjack.py
env:
JJB_benchmark_mode: ${{ matrix.mode }}
publish:
if: ${{ !github.event.repository.fork && startsWith(github.ref, 'refs/tags/v') }}
needs: [all-required-checks-done]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R dist
- name: Validate tag
shell: pwsh
run: |
$tag = "${{ github.ref }}".SubString(11)
$expectedFile = "dist/jollyjack-$tag.tar.gz"
# Check whether the tag and the package version match together
if (-not (Test-Path -Path $expectedFile)) {
echo "::error ::Expected file $expectedFile doesn't exist"
Get-ChildItem -Path dist
exit 1
}
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
with:
packages-dir: dist