Skip to content

Commit 0ff1018

Browse files
Merge pull request #15 from etive-io/ci-improvement
Improve the CI workflows
2 parents 910996c + b627a2d commit 0ff1018

File tree

5 files changed

+386
-42
lines changed

5 files changed

+386
-42
lines changed

.github/workflows/htcondor-tests.yml

Lines changed: 182 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,46 @@ jobs:
55
tests:
66
name: "HTCondor Testing"
77
runs-on: ubuntu-latest
8-
container:
8+
container:
99
image: htcondor/mini:latest
1010
options: --privileged
1111
defaults:
1212
run:
1313
shell: bash -el {0}
1414
steps:
1515

16-
1716
- name: Start HTCondor
1817
run: |
1918
condor_master &
2019
sleep 10
2120
condor_status
22-
23-
- run: |
24-
yum install -y sudo
21+
22+
- name: Install base tools
23+
run: |
24+
yum install -y sudo git
25+
26+
- name: Create submit user
27+
run: |
28+
id -u submituser >/dev/null 2>&1 || useradd -m -s /bin/bash submituser
29+
{
30+
echo 'Defaults:submituser !requiretty'
31+
echo 'submituser ALL=(ALL) NOPASSWD:ALL'
32+
} > /etc/sudoers.d/submituser
33+
chmod 0440 /etc/sudoers.d/submituser
34+
chown -R submituser:submituser "$GITHUB_WORKSPACE"
2535
2636
- uses: actions/checkout@v5
2737
with:
2838
fetch-depth: 0
39+
40+
- name: Cache conda packages
41+
uses: actions/cache@v4
42+
with:
43+
path: /usr/share/miniconda/pkgs
44+
key: conda-pkgs-${{ runner.os }}-${{ hashFiles('conda/environment.yaml') }}
45+
restore-keys: |
46+
conda-pkgs-${{ runner.os }}-
47+
2948
- name: Set up conda environment
3049
uses: conda-incubator/setup-miniconda@v2
3150
with:
@@ -36,61 +55,185 @@ jobs:
3655
channels: conda-forge
3756
conda-remove-defaults: "true"
3857

58+
- name: Cache asimov conda env
59+
uses: actions/cache@v4
60+
with:
61+
path: /usr/share/miniconda/envs/asimov
62+
key: conda-env-asimov-${{ runner.os }}-py39-${{ hashFiles('conda/environment.yaml') }}
63+
restore-keys: |
64+
conda-env-asimov-${{ runner.os }}-
65+
3966
- name: Install dependencies & asimov
4067
run: |
4168
conda install -y -n asimov --file conda/environment.yaml
4269
conda install -y -n asimov conda-build
4370
pip install .
71+
# Temporarily use the asimov-gwdata branch
72+
pip install git+https://git.ligo.org/asimov/pipelines/gwdata.git@update-htcondor
4473
4574
- name: Create asimov project
46-
shell: sudo -E -u submituser bash -el {0}
4775
run: |
76+
CONDA_EXE="${CONDA_EXE:-${CONDA:-/usr/share/miniconda}/bin/conda}"
77+
if [ ! -x "$CONDA_EXE" ]; then
78+
echo "Conda not found at $CONDA_EXE" >&2
79+
exit 1
80+
fi
81+
ASIMOV_CMD="$CONDA_EXE run -n asimov"
82+
83+
su - submituser <<EOF
84+
set -euo pipefail
85+
cd "$GITHUB_WORKSPACE"
4886
mkdir -p test_project
49-
chown -R submituser:submituser test_project
5087
cd test_project
51-
5288
git config --global init.defaultBranch master
5389
git config --global user.email "you@example.com"
5490
git config --global user.name "Your Name"
55-
56-
conda run -n asimov asimov init "Test Project"
57-
conda run -n asimov asimov configuration update condor/user submituser
58-
conda run -n asimov asimov configuration update condor/cache_time 30
59-
conda run -n asimov asimov configuration update condor/cron_minute '*/1'
60-
conda run -n asimov asimov apply -f ../tests/test_blueprints/gwosc_quick_test.yaml
91+
$ASIMOV_CMD asimov init "Test Project"
92+
$ASIMOV_CMD asimov configuration update condor/user submituser
93+
$ASIMOV_CMD asimov configuration update condor/cache_time 30
94+
$ASIMOV_CMD asimov configuration update condor/cron_minute '*/1'
95+
$ASIMOV_CMD asimov apply -f "$GITHUB_WORKSPACE/tests/test_blueprints/gwosc_quick_test.yaml"
96+
EOF
6197
6298
- name: Test Event Add
63-
shell: sudo -E -u submituser bash -el {0}
6499
run: |
65-
cd test_project
100+
CONDA_EXE="${CONDA_EXE:-${CONDA:-/usr/share/miniconda}/bin/conda}"
101+
[ -x "$CONDA_EXE" ] || { echo "Conda not found at $CONDA_EXE" >&2; exit 1; }
102+
ASIMOV_CMD="$CONDA_EXE run -n asimov"
103+
su - submituser <<EOF
104+
set -euo pipefail
105+
cd "$GITHUB_WORKSPACE/test_project"
106+
$ASIMOV_CMD asimov apply -f "$GITHUB_WORKSPACE/tests/test_blueprints/gwosc_event.yaml"
107+
EOF
66108
67-
conda run -n asimov asimov apply -f https://git.ligo.org/asimov/data/-/raw/gwosc/events/gwtc-2-1/GW150914_095045.yaml
109+
- name: Test GWData
110+
env:
111+
GWDATAFIND_SERVER: https://datafind.gwosc.org
112+
run: |
113+
CONDA_EXE="${CONDA_EXE:-${CONDA:-/usr/share/miniconda}/bin/conda}"
114+
[ -x "$CONDA_EXE" ] || { echo "Conda not found at $CONDA_EXE" >&2; exit 1; }
115+
ASIMOV_CMD="$CONDA_EXE run -n asimov"
116+
su - submituser <<EOF
117+
set -euo pipefail
118+
cd "$GITHUB_WORKSPACE/test_project"
119+
$ASIMOV_CMD asimov apply -f "$GITHUB_WORKSPACE/tests/test_blueprints/gwosc_get_data.yaml" -e GW150914_095045
120+
$ASIMOV_CMD asimov manage build
121+
$ASIMOV_CMD asimov manage submit
122+
echo 'Waiting for H*.gwf and L*.gwf frame files to appear...'
123+
TIMEOUT=600; ELAPSED=0; INTERVAL=30
124+
while [ \$ELAPSED -lt \$TIMEOUT ]; do
125+
condor_q || true
126+
H_COUNT=0
127+
L_COUNT=0
128+
for f in working/GW150914_095045/get-data/frames/H*.gwf; do
129+
[ -e "\$f" ] && H_COUNT=\$((H_COUNT + 1))
130+
done
131+
for f in working/GW150914_095045/get-data/frames/L*.gwf; do
132+
[ -e "\$f" ] && L_COUNT=\$((L_COUNT + 1))
133+
done
134+
if [ \$H_COUNT -gt 0 ] && [ \$L_COUNT -gt 0 ]; then
135+
echo 'Frame files found!'
136+
ls -lh working/GW150914_095045/get-data/frames/
137+
break
138+
fi
139+
echo "Elapsed: \${ELAPSED}s / \${TIMEOUT}s - H*.gwf and/or L*.gwf not yet present, waiting..."
140+
sleep \$INTERVAL
141+
ELAPSED=\$((ELAPSED + INTERVAL))
142+
done
143+
if [ \$ELAPSED -ge \$TIMEOUT ]; then
144+
echo 'Timeout waiting for H*.gwf and L*.gwf frame files'
145+
ls -R working/GW150914_095045/ || true
146+
exit 1
147+
fi
148+
$ASIMOV_CMD asimov monitor
149+
EOF
68150
69151
- name: Test Bayeswave
70-
shell: sudo -E -u submituser bash -el {0}
71152
env:
72153
GWDATAFIND_SERVER: https://datafind.gwosc.org
73154
run: |
74-
cd test_project
75-
76-
# Submit as submituser
77-
conda run -n asimov asimov apply -f ../tests/test_blueprints/bayeswave_quick_test.yaml -e GW150914_095045
78-
conda run -n asimov asimov manage build
79-
conda run -n asimov asimov manage submit
155+
CONDA_EXE="${CONDA_EXE:-${CONDA:-/usr/share/miniconda}/bin/conda}"
156+
[ -x "$CONDA_EXE" ] || { echo "Conda not found at $CONDA_EXE" >&2; exit 1; }
157+
ASIMOV_CMD="$CONDA_EXE run -n asimov"
158+
su - submituser <<EOF
159+
set -euo pipefail
160+
cd "$GITHUB_WORKSPACE/test_project"
161+
$ASIMOV_CMD asimov apply -f "$GITHUB_WORKSPACE/tests/test_blueprints/bayeswave_quick_test.yaml" -e GW150914_095045
162+
$ASIMOV_CMD asimov manage build
163+
$ASIMOV_CMD asimov manage submit
164+
sleep 60
165+
166+
condor_q || true
167+
echo 'Waiting for PSD files to appear...'
168+
TIMEOUT=600; ELAPSED=0; INTERVAL=30
169+
while [ \$ELAPSED -lt \$TIMEOUT ]; do
170+
condor_q || true
171+
H_COUNT=0
172+
L_COUNT=0
173+
for f in working/GW150914_095045/generate-psd/trigtime_*/post/clean/glitch_median_PSD_forLI_H1.dat; do
174+
[ -e "\$f" ] && H_COUNT=\$((H_COUNT + 1))
175+
done
176+
for f in working/GW150914_095045/generate-psd/trigtime_*/post/clean/glitch_median_PSD_forLI_L1.dat; do
177+
[ -e "\$f" ] && L_COUNT=\$((L_COUNT + 1))
178+
done
179+
if [ \$H_COUNT -gt 0 ] && [ \$L_COUNT -gt 0 ]; then
180+
echo 'PSD files found!'
181+
ls -lh working/GW150914_095045/generate-psd/trigtime_*/post/clean/
182+
break
183+
fi
184+
echo "Elapsed: \${ELAPSED}s / \${TIMEOUT}s - PSD files not yet present, waiting..."
185+
sleep \$INTERVAL
186+
ELAPSED=\$((ELAPSED + INTERVAL))
187+
done
188+
if [ \$ELAPSED -ge \$TIMEOUT ]; then
189+
echo 'Timeout waiting for PSD files'
190+
ls -R working/GW150914_095045/ || true
191+
exit 1
192+
fi
193+
condor_rm 2
194+
rm .asimov/_cache_jobs.yaml
195+
$ASIMOV_CMD asimov monitor
196+
EOF
80197
198+
- name: Test Bilby
199+
env:
200+
GWDATAFIND_SERVER: https://datafind.gwosc.org
201+
run: |
202+
CONDA_EXE="${CONDA_EXE:-${CONDA:-/usr/share/miniconda}/bin/conda}"
203+
[ -x "$CONDA_EXE" ] || { echo "Conda not found at $CONDA_EXE" >&2; exit 1; }
204+
ASIMOV_CMD="$CONDA_EXE run -n asimov"
205+
su - submituser <<EOF
206+
set -euo pipefail
207+
cd "$GITHUB_WORKSPACE/test_project"
208+
$ASIMOV_CMD asimov apply -f "$GITHUB_WORKSPACE/tests/test_blueprints/bilby_quick_test.yaml" -e GW150914_095045
209+
$ASIMOV_CMD asimov manage build
210+
$ASIMOV_CMD asimov manage submit
211+
sleep 10
81212
sleep 60
82-
condor_q
83-
84-
sleep 300
85-
ls working/GW150914_095045/bayeswave/* || true
86-
conda run -n asimov asimov monitor
87-
88-
# - name: Test Analysis get-data
89-
# run: |
90-
# cd test_project
91-
# conda run -n asimov asimov apply -f ../tests/test_blueprints/gwosc_get_data.yaml -e GW150914_095045
92-
# conda run -n asimov asimov manage build
93-
# conda run -n asimov asimov manage submit
94-
# sleep 300
95-
# ls working/GW150914_095045/get-data/*
96-
# asimov monitor
213+
214+
condor_q || true
215+
echo 'Waiting for PSD files to appear...'
216+
TIMEOUT=1200; ELAPSED=0; INTERVAL=30
217+
while [ \$ELAPSED -lt \$TIMEOUT ]; do
218+
condor_q || true
219+
RESULT_COUNT=0
220+
tail -n 20 working/GW150914_095045/bilby-IMRPhenomXPHM/log_*/*.err || true
221+
for f in working/GW150914_095045/bilby-IMRPhenomXPHM/*merge*_result.hdf5; do
222+
[ -e "\$f" ] && RESULT_COUNT=\$((RESULT_COUNT + 1))
223+
done
224+
if [ \$RESULT_COUNT -gt 0 ]; then
225+
echo 'Result files found!'
226+
ls -lh working/GW150914_095045/bilby-IMRPhenomXPHM/
227+
break
228+
fi
229+
echo "Elapsed: \${ELAPSED}s / \${TIMEOUT}s - Result files not yet present, waiting..."
230+
sleep \$INTERVAL
231+
ELAPSED=\$((ELAPSED + INTERVAL))
232+
done
233+
if [ \$ELAPSED -ge \$TIMEOUT ]; then
234+
echo 'Timeout waiting for Result files'
235+
ls -R working/GW150914_095045/ || true
236+
exit 1
237+
fi
238+
$ASIMOV_CMD asimov monitor
239+
EOF

0 commit comments

Comments
 (0)