Skip to content

Commit

Permalink
fix base image to support relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
samos123 committed Oct 1, 2023
1 parent 3e15283 commit d13d2c2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 14 additions & 2 deletions base/scripts/run-notebook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

import argparse
import sys
from pathlib import Path
import logging
Expand All @@ -9,6 +10,16 @@
from papermill.utils import merge_kwargs, remove_args
from nbconvert import HTMLExporter


parser = argparse.ArgumentParser(
prog='run-notebook.py',
description='Run a notebook and converts it to HTML while it is running')

parser.add_argument('notebook_path', help="The path to the .ipynb notebook file")
parser.add_argument('notebook_output_path', help="The path where the .ipynb notebook file should be written")
parser.add_argument('-c', '--cwd', help="Change the working directory")
args = parser.parse_args()

logging.basicConfig(level=logging.INFO, format="%(message)s")
logger.setLevel(logging.INFO)

Expand Down Expand Up @@ -68,8 +79,9 @@ def execute_notebook(

# Execute the notebook with papermill as usual
papermill.execute_notebook(
sys.argv[1],
sys.argv[2],
args.notebook_path,
args.notebook_output_path,
cwd=args.cwd,
log_output=True,
engine_name="htmlengine",
)
9 changes: 3 additions & 6 deletions base/scripts/run-notebook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ if [[ -z "$NOTEBOOK" ]]; then
for nb in /content/*.ipynb; do
[ -e "$nb" ] || continue
echo "Executing notebook $nb"
run-notebook.py "$nb" "/content/artifacts/$(basename ${nb})"
# jupyter nbconvert --to html /content/artifacts/$(basename "$nb")
run-notebook.py "$nb" "/content/artifacts/$(basename ${nb})" --cwd "$(dirname ${nb})"
done
for nb in /content/src/*.ipynb; do
[ -e "$nb" ] || continue
mkdir -p /content/artifacts/src
echo "Executing notebook $nb"
run-notebook.py "$nb" "/content/artifacts/src/$(basename ${nb})"
# jupyter nbconvert --to html /content/artifacts//src/$(basename "$nb")
run-notebook.py "$nb" "/content/artifacts/src/$(basename ${nb})" --cwd "$(dirname ${nb})"
done
else
for nb in $NOTEBOOK; do
[ -e "$nb" ] || continue
echo "Executing notebook $nb"
run-notebook.py "$nb" "/content/artifacts/$(basename ${nb})"
# jupyter nbconvert --to html /content/artifacts/$(basename "$nb")
run-notebook.py "$nb" "/content/artifacts/$(basename ${nb})" --cwd "$(dirname ${nb})"
done
fi

0 comments on commit d13d2c2

Please sign in to comment.