-
Notifications
You must be signed in to change notification settings - Fork 346
170 lines (161 loc) · 5.51 KB
/
ci_cpu.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
name: CI_CPU
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '4 4 * * *' # This schedule runs the nightly job every night at 4:04AM
jobs:
########### LINT ##############
lint_py39_torch_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black isort
./scripts/install_via_pip.sh
- name: Lint with flake8
run: flake8 --config ./.github/workflows/flake8_config.ini
- name: Lint with black
run: black --check --diff --color .
- name: Check import order with isort
run: isort -v -l 88 -o opacus --lines-after-imports 2 -m 3 --trailing-comma --check-only .
########### UNIT TESTS ##############
unittest_py38_torch_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coverage coveralls
./scripts/install_via_pip.sh
- name: Run unit tests
run: |
mkdir unittest-py38-release-reports
coverage run -m pytest --doctest-modules -p conftest --junitxml=unittest-py38-release-reports/junit.xml opacus
coverage report -i -m
- name: Store test results
uses: actions/upload-artifact@v2
with:
name: unittest-py38-release-reports
path: unittest-py38-release-reports
unittest_py39_torch_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coverage coveralls
./scripts/install_via_pip.sh
- name: Run unit tests
run: |
mkdir unittest-py39-release-reports
coverage run -m pytest --doctest-modules -p conftest --junitxml=unittest-py39-release-reports/junit.xml opacus
coverage report -i -m
- name: Store test results
uses: actions/upload-artifact@v2
with:
name: unittest-py39-release-reports
path: unittest-py39-release-reports
prv_accountant_values:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
./scripts/install_via_pip.sh
- name: Run prv accountant unit tests
run: |
python -m unittest opacus.tests.prv_accountant
########### NIGHTLY TEST ##############
unittest_py39_torch_nightly:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'schedule' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coverage coveralls
./scripts/install_via_pip.sh -n
- name: Run unit tests
run: |
mkdir unittest-py39-nightly-reports
python -m pytest --doctest-modules -p conftest --junitxml=unittest-py39-nightly-reports/junit.xml opacus
- name: Store test results
uses: actions/upload-artifact@v2
with:
name: unittest-py39-nightly-reports
path: unittest-py39-nightly-reports
########### INTEGRATION TEST ##############
integrationtest_py39_torch_release_cpu:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coverage coveralls
./scripts/install_via_pip.sh
- name: Run MNIST integration test (CPU)
run: |
mkdir -p runs/mnist/data
mkdir -p runs/mnist/test-reports
coverage run examples/mnist.py --lr 0.25 --sigma 0.7 -c 1.5 --batch-size 64 --epochs 1 --data-root runs/mnist/data --n-runs 1 --device cpu
python -c "import torch; accuracy = torch.load('run_results_mnist_0.25_0.7_1.5_64_1.pt'); exit(0) if (accuracy[0]>0.78 and accuracy[0]<0.95) else exit(1)"
coverage report -i -m
- name: Store test results
uses: actions/upload-artifact@v2
with:
name: mnist-cpu-reports
path: runs/mnist/test-reports
######## FINISH COVERALLS ##########
finish_coveralls_parallel:
needs: [unittest_py38_torch_release, unittest_py39_torch_release, integrationtest_py39_torch_release_cpu]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Finish Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true