Skip to content

Commit

Permalink
Update checknb.yml
Browse files Browse the repository at this point in the history
Convert nb to .jl and run individually
  • Loading branch information
cpaniaguam authored Oct 19, 2024
1 parent 4c639af commit 3b3c985
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions .github/workflows/checknb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: python -m pip install -U pip

- name: Install Python dependencies
run: python -m pip install -U -r requirements.txt
run: python -m pip install nbconvert

- uses: julia-actions/setup-julia@v2
with:
Expand All @@ -51,16 +51,29 @@ jobs:
env:
PYTHON: python

# Install Papermill for executing notebooks
- name: Install Papermill
run: python -m pip install papermill
# Convert notebooks to .jl files using nbconvert
- name: Convert Notebooks to Julia Scripts
run: |
for notebook in $(find notebooks -name "*.ipynb"); do
echo "Converting $notebook to Julia script"
jupyter nbconvert --to script "$notebook" --output-dir=. --output "$notebook.jl"
done
# Run all Jupyter notebooks using the wildcard, capture errors
- name: Run Jupyter Notebooks
# Update HOME variable in nb => .jl scripts
# HOME = "../.." => "."
- name: Update Paths in Converted Julia Scripts
run: |
for script in $(find converted_notebooks -maxdepth 1 -name "*.jl"); do
echo "Updating paths in $script"
sed -i 's|\.\./\.\.|.|g' "$script"
done
# Run converted .jl files using Julia
- name: Run Julia Scripts
run: |
EXIT_CODE=0
for notebook in $(find notebooks -name "*.ipynb"); do
echo "Running notebook: $notebook"
papermill "$notebook" /dev/null || EXIT_CODE=$?
for script in $(find . -maxdepth 1 -name "*.jl"); do
echo "Running Julia script: $script"
julia --project=. "$script" || EXIT_CODE=$?
done
exit $EXIT_CODE

0 comments on commit 3b3c985

Please sign in to comment.