-
Notifications
You must be signed in to change notification settings - Fork 279
193 lines (181 loc) · 7.76 KB
/
pythonapp.yml
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "15 21 * * FRI"
workflow_call:
secrets:
codecov_token:
required: true
permissions: read-all
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-14, windows-2022]
python-version: ['3.9', '3.10', '3.11']
env:
TVM_VERSION_TAG: v0.17.0
PYTORCH_VERSION: 2.4.0
LLVM_VERSION: 18
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
run: |
python -m pip install --upgrade pip
python -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
# The GitHub editor is 127 chars wide
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
# PyTorch CPU for Linux has different pip syntax wrt Win and Mac.
- name: Install torch-${{ env.PYTORCH_VERSION }}+cpu if linux
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: python -m pip install torch==${{ env.PYTORCH_VERSION }} --extra-index-url https://download.pytorch.org/whl/cpu
- name: Install torch-${{ env.PYTORCH_VERSION }}+cpu if not linux
if: ${{ !startsWith(matrix.os, 'ubuntu') }}
run: python -m pip install torch==${{ env.PYTORCH_VERSION }}
- name: Install basic dependencies
run: |
python -m pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html
- name: Test with older SKLearn on Linux with py3.9 to check backward compatibility
if: ${{ matrix.python-version == '3.9' && startsWith(matrix.os, 'ubuntu') == true }}
run: python -m pip install scikit-learn==1.2.1 numpy==1.26.4
- name: Pin SKLearn<1.5.0 on not Linux with py3.9
if: ${{ !(matrix.python-version == '3.9' && startsWith(matrix.os, 'ubuntu') == true) }}
run: python -m pip install "scikit-learn<1.5.0" numpy==1.26.4
- name: Run basic tests without extra
run: pytest
- name: Coverage on basic tests without extra
run: coverage run -a -m pytest tests/test_no_extra_install.py
- name: If mac, install libomp to facilitate lgbm install
if: ${{ startsWith(matrix.os, 'macos')}}
run: |
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb
brew install ./libomp.rb
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
export CFLAGS="$CFLAGS -I/usr/local/opt/libomp/include"
export CXXFLAGS="$CXXFLAGS -I/usr/local/opt/libomp/include"
export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib -L/usr/local/opt/libomp/lib -lomp"
- name: Install extra dependencies
run: |
python -m pip install .[extra,onnx,sparkml]
python -m pip install pandas
- uses: actions/cache@v3
# TVM takes forever, we try to cache it.
if: ${{ startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')}}
id: cache
env:
CACHE_NUMBER: 14
with:
path: ~/work/hummingbird/tvm
key: ${{ matrix.os }}-python${{ matrix.python-version }}-tvm-${{ env.TVM_VERSION_TAG }}-${{ env.CACHE_NUMBER }}
# Getting TVM requires: 1) Install LLVM 2) fetching TVM from github, 3) cmake, 4) make, 5) install python dependency.
# 2 to 4 will be retrieved from the cache.
# The pipeline only works for Unix systems. For windows we will have to compile LLVM from source which is a no go.
- name: Install LLVM if Ubuntu
if: ${{ startsWith(matrix.os, 'ubuntu')}}
run: |
sudo apt install llvm-${{ env.LLVM_VERSION }}-dev libpolly-${{ env.LLVM_VERSION }}-dev
- name: Install LLVM if Mac
if: ${{ startsWith(matrix.os, 'macos')}}
run: |
brew install llvm@${{ env.LLVM_VERSION }}
- name: Fetch and prepare TVM for compilation if Ubuntu or Mac
if: ${{ steps.cache.outputs.cache-hit != 'true' && (startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')) }}
run: |
cd ~/work/hummingbird
git clone https://github.com/apache/tvm.git
cd tvm
git checkout tags/${{env.TVM_VERSION_TAG}}
git submodule update --recursive --init
cmake -E make_directory build
- name: CMake TVM if Ubuntu
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') }}
run: |
cd ~/work/hummingbird/tvm
cmake -S . -B build \
-DUSE_RPC=ON \
-DUSE_GRAPH_RUNTIME=ON \
-DUSE_LLVM="llvm-config-${{ env.LLVM_VERSION }} --link-static" \
-DHIDE_PRIVATE_SYMBOLS=ON
- name: CMake TVM if Mac
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.os, 'macos') }}
run: |
cd ~/work/hummingbird/tvm
cmake -S . -B build \
-DUSE_RPC=ON \
-DUSE_GRAPH_RUNTIME=ON \
-DUSE_LLVM="$(brew --prefix llvm@${{ env.LLVM_VERSION }})/bin/llvm-config --link-static" \
-DHIDE_PRIVATE_SYMBOLS=ON
- name: Build TVM if Ubuntu or Mac
if: ${{ steps.cache.outputs.cache-hit != 'true' && (startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')) }}
run: |
cd ~/work/hummingbird/tvm
cmake --build build
- name: Install python TVM if Ubuntu or Mac
if: ${{ (startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')) }}
run: |
cd ~/work/hummingbird/tvm/python
python3 -m pip install -e .
# We don't run pytest for ubuntu py3.9 since we do coverage for that case.
- name: Test with pytest
if: ${{ matrix.python-version != '3.9' || startsWith(matrix.os, 'ubuntu') != true }}
run: pytest
# Run and push coverage only for ubuntu py3.9
- name: Coverage 3.9 ubuntu
if: ${{ matrix.python-version == '3.9' && startsWith(matrix.os, 'ubuntu') }}
run: |
coverage run -a -m pytest tests
coverage xml
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.9' && startsWith(matrix.os, 'ubuntu') }}
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
page-build:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
python-version: ['3.9']
permissions: # here we push documentation
actions: read
contents: write
if: github.ref == 'refs/heads/main' # only run this on main after PR merged
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Generate Documentation
run: |
# We're mocking out the torch. So now we also need to sub this on out
find ../. -type f -exec sed -i 's/{torch.__version__}/1.12.0/g' {} +
find ../. -type f -exec sed -i 's/torch.__version__/"1.12.0"/g' {} +
make sphinx-site -C website/
# now refresh the code
git checkout . && python -m pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html
- name: Deploy to GitHub pages 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: website/public