-
Notifications
You must be signed in to change notification settings - Fork 1
256 lines (216 loc) · 8.23 KB
/
torsions.yaml
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
# this is adapted from openff-docs/cookbook_preproc.yaml
name: Run torsion benchmarks
on:
workflow_dispatch:
inputs:
pr_number:
description: 'Run the benchmarks for PR#: '
required: true
type: string
path:
description: Path to submission directory
required: true
type: string
env:
description: Path to conda YAML file
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ inputs.pr_number || github.ref || github.run_id }}
cancel-in-progress: true
jobs:
start-aws-runner:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
outputs:
mapping: ${{ steps.aws-start.outputs.mapping }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::649715411074:role/gh-actions-runner-role
aws-region: us-east-1
- name: Create cloud runner
id: aws-start
uses: omsf-eco-infra/[email protected]
with:
provider: "aws"
action: "start"
aws_image_id: ami-0d5079d9be06933e5
aws_instance_type: c6a.8xlarge
aws_region_name: us-east-1
aws_home_dir: /home/ubuntu
env:
GH_PAT: ${{ secrets.GH_PAT }}
benchmark:
permissions: write-all
runs-on: self-hosted
needs:
- start-aws-runner
steps:
- name: Report dispatch to PR
if: github.event_name == 'workflow_dispatch' && inputs.pr_number != ''
uses: thollander/actions-comment-pull-request@v2
with:
pr_number: ${{ inputs.pr_number }}
message: >
A workflow has been dispatched to run the benchmarks for this PR.
- Run ID: [${{ github.run_id }}]
- Triggering actor: ${{ github.triggering_actor }}
- Target branch: ${{ github.ref_name }}
[${{ github.run_id }}]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Create check
if: github.event_name == 'workflow_dispatch' && inputs.pr_number != ''
id: create-check
uses: actions/github-script@v6
with:
script: |
const created_run = await github.request(
'POST /repos/{owner}/{repo}/check-runs',
{
owner: context.repo.owner,
repo: context.repo.repo,
name: '${{ github.job }}',
head_sha: '${{ github.sha }}',
details_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
status: 'in_progress',
started_at: new Date().toISOString(),
output: {
title: 'Run torsion benchmarks',
summary: 'Results and progress: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
text: ''
},
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
}
)
return created_run.data.id
- name: Install git-lfs
run: |
sudo apt update
sudo apt install -y git-lfs
- uses: actions/checkout@v3
with:
lfs: true
- name: Install Conda environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ inputs.env }}
- name: Run torsion benchmarks
env:
LICENSE: ${{ secrets.OE_LICENSE }}
shell: bash -l {0}
run: |
set -e
echo "$LICENSE" > /tmp/oe_license.txt
export OE_LICENSE=/tmp/oe_license.txt
python torsions.py ${{ inputs.path }} $(nproc)
rm $OE_LICENSE
- name: Plot results
shell: bash -l {0}
run: |
set -e
input_file=${{ inputs.path }}
input_dir=$(dirname $input_file)
# python plot.py $input_dir -o $input_dir/output
- name: Commit results
shell: bash -l {0}
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
git config --global init.defaultBranch main
# Commit the benchmark results and push
input_file=${{ inputs.path }} # path to the input YAML file
input_dir=$(dirname $input_file) # parent directory of input YAML file
git add $input_dir/output/rmsd.csv
git add $input_dir/output/een.csv
git add $input_dir/output/minimized.json
git add $input_dir/output/metrics.json
git commit -m "Add benchmark results"
git push
echo input_dir="${input_dir}" >> $GITHUB_ENV
- name: Upload to zenodo
env:
ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }}
ZENODO_URL: "https://zenodo.org"
shell: bash -l {0}
run: |
# TODO: make and bundle plot(s)
bzip2 torsions-dev.sqlite
micromamba env export > env.yaml
input_files=$(python get_files.py ${{ inputs.path }})
python zenodo_upload.py --title "YDS Upload ${{ inputs.pr_number }}" \
torsions-dev.sqlite.bz2 $input_dir/output/rmsd.csv \
torsions-dev.sqlite.bz2 $input_dir/output/een.csv \
env.yaml torsions.py $input_files
- name: Report status to PR
id: reportStatusToPr
if: always() && github.event_name == 'workflow_dispatch' && inputs.pr_number != ''
uses: thollander/actions-comment-pull-request@v2
with:
pr_number: ${{ inputs.pr_number }}
message: >
A workflow dispatched to run torsion benchmarks for this PR has just finished.
- Run ID: [${{ github.run_id }}]
- Triggering actor: ${{ github.triggering_actor }}
- Target branch: ${{ github.ref_name }}
- Job status: **${{ job.status }}**
[${{ github.run_id }}]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Report status to PR on templating failure
if: always() && steps.reportStatusToPr.outcome == 'failure'
uses: thollander/actions-comment-pull-request@v2
with:
pr_number: ${{ inputs.pr_number }}
message: >
A workflow dispatched to run torsion benchmarks for this PR has just failed.
- Run ID: [${{ github.run_id }}]
- Triggering actor: ${{ github.triggering_actor }}
- Target branch: ${{ github.ref_name }}
- Job status: **${{ job.status }}**
[${{ github.run_id }}]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Update check
if: always() && github.event_name == 'workflow_dispatch' && inputs.pr_number != ''
uses: actions/github-script@v6
with:
script: |
await github.request(
'PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}',
{
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: ${{ steps.create-check.outputs.result }},
status: 'completed',
conclusion: '${{ job.status }}',
completed_at: new Date().toISOString(),
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
}
)
stop-aws-runner:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
needs:
- start-aws-runner
- benchmark
if: ${{ always() }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::649715411074:role/gh-actions-runner-role
aws-region: us-east-1
- name: Stop instances
uses: omsf-eco-infra/[email protected]
with:
provider: "aws"
action: "stop"
instance_mapping: ${{ needs.start-aws-runner.outputs.mapping }}
aws_region_name: us-east-1
env:
GH_PAT: ${{ secrets.GH_PAT }}