forked from almahmoud/abm-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
191 lines (173 loc) · 6.29 KB
/
action.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
name: 'ABM Benchmarks'
description: 'Run ABM benchmarks on Galaxy servers'
inputs:
org-api-key:
description: 'API key for usegalaxy.org'
required: false
org-au-api-key:
description: 'API key for usegalaxy.org.au'
required: false
eu-api-key:
description: 'API key for usegalaxy.eu'
required: false
custom-server-url:
description: 'URL of a custom Galaxy server'
required: false
custom-server-api-key:
description: 'API key for the custom Galaxy server'
required: false
histories:
description: 'List of history URLs in the format "name: url" (one per line)'
required: false
histories-path:
description: 'Path to the file containing the list of history URLs'
required: false
workflows:
description: 'List of workflow URLs in the format "name: url" (one per line)'
required: false
workflows-path:
description: 'Path to the file containing the list of workflow URLs'
required: false
benchmarks-file:
description: 'Contents of the benchmarks/testwf.yaml file'
required: false
benchmarks-file-path:
description: 'File path of the benchmarks/testwf.yaml file in the repository'
required: false
experiments-file:
description: 'Contents of the experiments/testwf.yaml file'
required: false
experiments-file-path:
description: 'File path of the experiments/testwf.yaml file in the repository'
required: false
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
- name: Run ABM
shell: bash
env:
ORG_API_KEY: ${{ inputs.org-api-key }}
ORG_AU_API_KEY: ${{ inputs.org-au-api-key }}
EU_API_KEY: ${{ inputs.eu-api-key }}
CUSTOM_SERVER_URL: ${{ inputs.custom-server-url }}
CUSTOM_SERVER_API_KEY: ${{ inputs.custom-server-api-key }}
run: |
python3 -m venv .venv
source .venv/bin/activate
pip install gxabm
mkdir -p ~/.abm
servers=()
if [ -n "$ORG_API_KEY" ]; then
servers+=("usa")
cat << EOF >> ~/.abm/profile.yml
usa:
url: https://usegalaxy.org
key: $ORG_API_KEY
EOF
fi
if [ -n "$ORG_AU_API_KEY" ]; then
servers+=("australia")
cat << EOF >> ~/.abm/profile.yml
australia:
url: https://usegalaxy.org.au
key: $ORG_AU_API_KEY
EOF
fi
if [ -n "$EU_API_KEY" ]; then
servers+=("europe")
cat << EOF >> ~/.abm/profile.yml
europe:
url: https://usegalaxy.eu
key: $EU_API_KEY
EOF
fi
if [ -n "$CUSTOM_SERVER_URL" ] && [ -n "$CUSTOM_SERVER_API_KEY" ]; then
servers+=("custom")
cat << EOF >> ~/.abm/profile.yml
custom:
url: $CUSTOM_SERVER_URL
key: $CUSTOM_SERVER_API_KEY
EOF
fi
if [ "${#servers[@]}" -eq 0 ]; then
echo "Error: At least one API key must be provided"
exit 1
fi
if [ -n "${{ inputs.histories }}" ]; then
cat << EOF > ~/.abm/histories.yml
${{ inputs.histories }}
EOF
elif [ -n "${{ inputs.histories-path }}" ]; then
if [[ "${{ inputs.histories-path }}" != .abm/histories.yml ]]; then
cp ${{ inputs.histories-path }} .abm/histories.yml
fi
else
#echo "Error: Either histories or histories-path must be provided"
#exit 1
echo "No histories provided. Expecting a histories.yml file in the repository"
fi
if [ -n "${{ inputs.workflows }}" ]; then
cat << EOF > ~/.abm/workflows.yml
${{ inputs.workflows }}
EOF
elif [ -n "${{ inputs.workflows-path }}" ]; then
if [[ "${{ inputs.workflows-path }}" != .abm/workflows.yml ]]; then
cp ${{ inputs.workflows-path }} .abm/workflows.yml
fi
else
#echo "Error: Either workflows or workflows-path must be provided"
#exit 1
echo "No workflows provided. Expecting a workflows.yml file in the repository"
fi
mkdir -p benchmarks
if [ -n "${{ inputs.benchmarks-file }}" ]; then
cat << EOF > benchmarks/benchmark.yml
${{ inputs.benchmarks-file }}
EOF
elif [ -n "${{ inputs.benchmarks-file-path }}" ]; then
if [[ "${{ inputs.benchmarks-file-path }}" != benchmarks/benchmark.yml ]]; then
cp ${{ inputs.benchmarks-file-path }} benchmarks/benchmark.yml
fi
#cp ${{ inputs.benchmarks-file-path }} benchmark.yml
else
#echo "Error: Either benchmarks-file or benchmarks-file-path must be provided"
#exit 1
echo "No benchmark provided. Expecting a benchmark.yml file in the repository"
fi
mkdir -p experiments
if [ -n "${{ inputs.experiments-file }}" ]; then
cat << EOF > experiment.yml
${{ inputs.experiments-file }}
EOF
elif [ -n "${{ inputs.experiments-file-path }}" ]; then
if [[ "${{ inputs.experiments-file-path }}" != experiments/experiment.yml ]]; then
cp ${{ inputs.experiments-file-path }} experiments/experiment.yml
fi
#cp ${{ inputs.experiments-file-path }} experiments/experiment.yml
else
#echo "Error: Either experiments-file or experiments-file-path must be provided"
#exit 1
echo "No experiment provided. Expecting a experiment.yml file in the repository"
fi
source .venv/bin/activate
HISTORY_NAME=$(cat .abm/histories.yml | head -n 1 | awk -F':' '{print $1}')
WORKFLOW_NAME=$(cat .abm/workflows.yml | head -n 1 | awk -F':' '{print $1}')
for server in "${servers[@]}"; do
abm $server workflow import $WORKFLOW_NAME
abm $server history import $HISTORY_NAME
done
- name: Run experiment
shell: bash
run: |
source .venv/bin/activate
abm experiment run experiment.yml
- name: Summarize results
shell: bash
run: |
source .venv/bin/activate
EXP_NAME=$(cat experiment.yml | grep 'name:' | awk -F':' '{print $1}')
abm experiment summarize metrics/$EXP_NAME