Skip to content

Commit aac002a

Browse files
committed
ci-build.sh: try to fix the nbconvert loop
The error on GitHub Actions was: ci-build.sh: 194: read: Illegal option -d find: ‘standard output’: Broken pipe find: write error Hopefully this updated version will work better.
1 parent 2a6b820 commit aac002a

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

ci-build.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,20 @@ fi
184184
if which jupyter >/dev/null 2>&1; then
185185
echo ::group::"= Jupyter notebooks ="
186186
# NB: This part is fiddly. We want to loop over files even with spaces,
187-
# so we use the "find ... -print0 | while read $'\0' ..." idiom.
187+
# so we use the "find ... | while read ..." idiom.
188188
# However, that runs the piped expression in a subshell, which means
189189
# that any updates to the success variable will not persist outside
190-
# the loop. So we suppress all stdout inside the loop, echoing only
191-
# the final value of success upon completion, and then capture the
192-
# echoed value back into the parent shell's success variable.
193-
success=$(find . -name '*.ipynb' -print0 | {
194-
while read -d $'\0' nbf; do
195-
echo 1>&2
196-
echo "== $nbf ==" 1>&2
197-
jupyter nbconvert --execute --stdout "$nbf" >/dev/null
198-
checkSuccess $?
199-
done
200-
echo $success
201-
})
190+
# the loop. So we store non-zero success values into a temporary file,
191+
# then capture the value back into the parent shell's success variable.
192+
find . -name '*.ipynb' | while read f
193+
do
194+
echo
195+
echo "== $nbf =="
196+
jupyter nbconvert --execute --stdout "$nbf"
197+
checkSuccess $?
198+
test "$success" -eq 0 || echo "$success" > success.tmp
199+
done
200+
test -f success.tmp && success=$(cat success.tmp) && rm success.tmp
202201
echo ::endgroup::
203202
fi
204203

0 commit comments

Comments
 (0)