-
Notifications
You must be signed in to change notification settings - Fork 17
170 lines (149 loc) · 5.87 KB
/
Copy pathCI-python.yml
File metadata and controls
170 lines (149 loc) · 5.87 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
name: CI Python
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '30 5 * * *'
jobs:
ci-python:
strategy:
matrix:
packageDirectory: ["ml_wrappers"]
operatingSystem: [ubuntu-latest, macos-latest, windows-latest]
pythonVersion: ['3.9', '3.10', '3.11']
openaiVersion: ['0.28.1', 'openai-latest']
exclude:
- openaiVersion: '0.28.1'
pythonVersion: '3.9'
- openaiVersion: '0.28.1'
pythonVersion: '3.10'
- openaiVersion: '0.28.1'
operatingSystem: 'macos-latest'
- openaiVersion: '0.28.1'
operatingSystem: 'windows-latest'
# Exclude Windows + Python 3.9 + openai-latest due to blis/spacy/fastai build failures
- openaiVersion: 'openai-latest'
pythonVersion: '3.9'
operatingSystem: 'windows-latest'
# Exclude macOS + Python 3.9 due to gRPC mutex deadlock
- openaiVersion: 'openai-latest'
pythonVersion: '3.9'
operatingSystem: 'macos-latest'
runs-on: ${{ matrix.operatingSystem }}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.pythonVersion }}
channels: conda-forge
- if: ${{ matrix.operatingSystem == 'macos-latest' }}
name: Use Homebrew to install libomp on MacOS
shell: bash -l {0}
run: |
brew install libomp
- if: ${{ matrix.operatingSystem == 'windows-latest' }}
name: Install pytorch on windows for python 3.9 to 3.11
shell: bash -l {0}
run: |
conda install --yes --quiet pytorch torchvision captum cpuonly "libtiff<4.5.0" -c pytorch -c conda-forge --strict-channel-priority
- if: ${{ matrix.operatingSystem == 'ubuntu-latest' }}
name: Install pytorch on ubuntu for python 3.9 to 3.11
shell: bash -l {0}
run: |
conda install --yes --quiet pytorch torchvision captum cpuonly -c pytorch -c conda-forge --strict-channel-priority
- if: ${{ matrix.operatingSystem == 'macos-latest' }}
name: Install pytorch on MacOS for python 3.9 to 3.11
shell: bash -l {0}
run: |
conda install --yes --quiet pytorch torchvision captum -c pytorch -c conda-forge
- if: ${{ matrix.operatingSystem == 'macos-latest' }}
name: Install lightgbm from conda on MacOS
shell: bash -l {0}
run: |
conda install --yes "lightgbm>=4.5.0" -c conda-forge
- name: Install backwards-compatible tf-keras for transformers
shell: bash -l {0}
run: |
pip install tf-keras
- name: Install package
shell: bash -l {0}
run: |
pip install -e ./python
- name: Install dev dependencies
shell: bash -l {0}
run: |
pip install -r requirements-dev.txt
- name: Install test dependencies
shell: bash -l {0}
run: |
pip install -r requirements-test.txt
- name: Upgrade matplotlib for NumPy 2.x compatibility
shell: bash -l {0}
run: |
pip install --upgrade "matplotlib>=3.9.0"
- if: ${{ matrix.openaiVersion != 'openai-latest' }}
name: Install openai version ${{ matrix.openaiVersion }}
shell: bash -l {0}
run: |
pip install openai==${{ matrix.openaiVersion }}
- if: ${{ matrix.operatingSystem == 'macos-latest' }}
name: Set macOS environment variables to prevent hangs
shell: bash -l {0}
run: |
# GRPC_POLL_STRATEGY=poll - Forces gRPC to use the poll strategy instead of
# platform-specific mechanisms that can deadlock on macOS
echo "GRPC_POLL_STRATEGY=poll" >> $GITHUB_ENV
# TF_ENABLE_ONEDNN_OPTS=0 - Disables oneDNN optimizations that can cause issues on macOS
echo "TF_ENABLE_ONEDNN_OPTS=0" >> $GITHUB_ENV
# OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES - Disables the Objective-C fork safety check
# that can cause hangs when Python multiprocessing interacts with certain libraries
echo "OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> $GITHUB_ENV
- name: Test with pytest
shell: bash -l {0}
run: |
pytest ./tests/main -s -v --durations=10 --cov='ml_wrappers' --cov-report=xml --cov-report=html
- name: Upload code coverage results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.packageDirectory }}-${{ matrix.openaiVersion }}-${{ matrix.pythonVersion }}-${{ matrix.operatingSystem }}-code-coverage-results
path: htmlcov
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- if: ${{ (matrix.operatingSystem == 'windows-latest') && (matrix.pythonVersion == '3.9') }}
name: Upload to codecov
id: codecovupload1
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: .
env_vars: OS,PYTHON
fail_ci_if_error: false
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
- if: ${{ (steps.codecovupload1.outcome == 'failure') && (matrix.pythonVersion == '3.9') && (matrix.operatingSystem == 'windows-latest') }}
name: Retry upload to codecov
id: codecovupload2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: .
env_vars: OS,PYTHON
fail_ci_if_error: false
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
- name: Set codecov status
if: ${{ (matrix.pythonVersion == '3.9') && (matrix.operatingSystem == 'windows-latest') }}
shell: bash
run: |
if ${{ (steps.codecovupload1.outcome == 'success') || (steps.codecovupload2.outcome == 'success') }} ; then
echo fine
else
exit 1
fi