Skip to content

Commit f47fdc6

Browse files
committed
Defer kernel detection to runtime and simplify kernel option handling
- Move get_current_kernel() call from script load to notebook_test() runtime - Remove intermediate kernel_opt variable, use kernel directly - Allows jupyter to be installed after script loads
1 parent 38235ee commit f47fdc6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

runtest.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,14 @@ function validate_kernel() {
282282
function notebook_test() {
283283
echo "${separator}${blue}notebook-test${noColor}"
284284

285-
local kernel_opt=""
286-
if [[ -n "$nb_kernel" ]]; then
287-
if ! validate_kernel "$nb_kernel"; then
285+
# Auto-detect kernel at runtime if not specified (allows jupyter to be installed after script load)
286+
local kernel="${nb_kernel:-$(get_current_kernel)}"
287+
288+
if [[ -n "$kernel" ]]; then
289+
if ! validate_kernel "$kernel"; then
288290
exit 1
289291
fi
290-
kernel_opt="--kernel=$nb_kernel"
291-
echo "Using kernel: $nb_kernel"
292+
echo "Using kernel: $kernel"
292293
else
293294
echo "No kernel specified, using notebook's default kernel"
294295
fi
@@ -298,8 +299,8 @@ function notebook_test() {
298299
# Build and print the exact command for debugging
299300
local cmd
300301
cmd=(python3 -m pytest --nbmake --nbmake-timeout="$nb_timeout" --nbmake-clean="$nb_clean")
301-
if [[ -n "$kernel_opt" ]]; then
302-
cmd+=("$kernel_opt")
302+
if [[ -n "$kernel" ]]; then
303+
cmd+=("--kernel=$kernel")
303304
fi
304305
cmd+=("$@")
305306
if [[ "$verbose_flag" == "true" ]]; then
@@ -366,7 +367,7 @@ fresh_deps=false
366367
# notebook test defaults
367368
nb_timeout=1200
368369
nb_clean="on-success"
369-
nb_kernel=$(get_current_kernel)
370+
nb_kernel="" # Auto-detected at runtime if not specified via --kernel=
370371

371372
# parse arguments
372373
cmd=""

0 commit comments

Comments
 (0)