forked from microsoft/responsible-ai-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (146 loc) · 5.95 KB
/
CI-responsibleai-text-vision-pytest.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
name: CI ResponsibleAI Text & Vision pytest
on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- "responsibleai_text/**"
- "responsibleai_vision/**"
- ".github/workflows/CI-responsibleai-text-vision-pytest.yml"
jobs:
ci-responsibleai-text-vision-python:
strategy:
matrix:
packageDirectory: ["responsibleai_text", "responsibleai_vision"]
operatingSystem: [ubuntu-latest, macos-latest, windows-latest]
pythonVersion: ["3.8", "3.9", "3.10"]
# TODO: re-add macos-latest once build timeout issues are resolved
exclude:
- packageDirectory: "responsibleai_text"
operatingSystem: macos-latest
pythonVersion: "3.8"
- packageDirectory: "responsibleai_text"
operatingSystem: macos-latest
pythonVersion: "3.9"
- packageDirectory: "responsibleai_text"
operatingSystem: macos-latest
pythonVersion: "3.10"
- packageDirectory: "responsibleai_vision"
operatingSystem: macos-latest
pythonVersion: "3.8"
- packageDirectory: "responsibleai_vision"
operatingSystem: macos-latest
pythonVersion: "3.9"
- packageDirectory: "responsibleai_vision"
operatingSystem: macos-latest
pythonVersion: "3.10"
runs-on: ${{ matrix.operatingSystem }}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.pythonVersion }}
- if: ${{ matrix.operatingSystem != 'macos-latest' }}
name: Install pytorch on non-MacOS
shell: bash -l {0}
run: |
conda install --yes --quiet pytorch==1.13.1 "torchvision<0.15" cpuonly "numpy<1.24.0" -c pytorch
- if: ${{ matrix.operatingSystem == 'macos-latest' }}
name: Install Anaconda packages on MacOS, which should not include cpuonly according to official docs
shell: bash -l {0}
run: |
conda install --yes --quiet pytorch==1.13.1 "torchvision<0.15" "numpy<1.24.0" -c pytorch
- name: Setup tools
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade "pip-tools<=7.1.0"
- if: ${{ (matrix.operatingSystem == 'windows-latest') && (matrix.packageDirectory == 'responsibleai_vision') }}
name: Install matplotlib
shell: bash -l {0}
run: |
conda install --yes --quiet matplotlib -c conda-forge
- name: Install backwards-compatible keras for transformers
shell: bash -l {0}
run: |
pip install tf-keras
pip install keras==2.15
- name: Install dependencies
shell: bash -l {0}
run: |
pip install captum
pip install -r requirements-dev.txt
pip install .
working-directory: ${{ matrix.packageDirectory }}
- if: ${{ matrix.packageDirectory == 'responsibleai_text' }}
name: Setup spacy
shell: bash -l {0}
run: |
python -m spacy download en_core_web_sm
- if: ${{ (matrix.packageDirectory == 'responsibleai_vision') && (matrix.pythonVersion == '3.8') }}
name: Install automl dependencies
shell: bash -l {0}
run: |
pip install -r ${{ matrix.packageDirectory }}/requirements-automl.txt
- if: ${{ (matrix.packageDirectory == 'responsibleai_vision') }}
name: Install vision package
shell: bash -l {0}
run: |
pip install -v -e .
working-directory: ${{ matrix.packageDirectory }}
- if: ${{ (matrix.packageDirectory == 'responsibleai_text') }}
name: Install text package
shell: bash -l {0}
run: |
pip install -v -e .[qa]
working-directory: ${{ matrix.packageDirectory }}
- name: Run tests
shell: bash -l {0}
run: |
pytest -s -v --durations=10 --doctest-modules --junitxml=junit/test-results.xml --cov=${{ matrix.packageDirectory }} --cov-report=xml --cov-report=html
working-directory: ${{ matrix.packageDirectory }}
- name: Upload code coverage results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.packageDirectory }}-code-coverage-results
path: ${{ matrix.packageDirectory }}/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.8') }}
name: Upload to codecov
id: codecovupload1
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ matrix.packageDirectory }}
env_vars: OS,PYTHON
fail_ci_if_error: false
files: ./${{ matrix.packageDirectory }}/coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
- if: ${{ (steps.codecovupload1.outcome == 'failure') && (matrix.pythonVersion == '3.8') && (matrix.operatingSystem == 'windows-latest') }}
name: Retry upload to codecov
id: codecovupload2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ matrix.packageDirectory }}
env_vars: OS,PYTHON
fail_ci_if_error: false
files: ./${{ matrix.packageDirectory }}/coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
- name: Set codecov status
if: ${{ (matrix.pythonVersion == '3.8') && (matrix.operatingSystem == 'windows-latest') }}
shell: bash
run: |
if ${{ (steps.codecovupload1.outcome == 'success') || (steps.codecovupload2.outcome == 'success') }} ; then
echo fine
else
exit 1
fi