Skip to content

Commit

Permalink
Updated directory name for notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
roje-bodc committed Oct 31, 2023
1 parent a916dc5 commit aaa01c6
Show file tree
Hide file tree
Showing 22 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: develop
paths:
- example_scripts/notebooks/**
- example_scripts/notebook_tutorials/**
jobs:
push-notebooks:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ docs/source/generated/

docstring2md.log

example_scripts/notebooks/markdown/*
example_scripts/notebook_tutorials/markdown/*

markdown/
14 changes: 7 additions & 7 deletions notebook_to_md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ directory=$1

# Convert ipynb files to markdown.
echo "starting notebook execute for ${directory}"
jupyter nbconvert --to notebook --execute example_scripts/notebooks/runnable_notebooks/${directory}/*.ipynb --allow-errors --output-dir example_scripts/notebooks/runnable_notebooks/executed/${directory}/
jupyter nbconvert --to notebook --execute example_scripts/notebook_tutorials/runnable_notebooks/${directory}/*.ipynb --allow-errors --output-dir example_scripts/notebook_tutorials/runnable_notebooks/executed/${directory}/
echo "starting notebook convert"
jupyter nbconvert --to markdown example_scripts/notebooks/runnable_notebooks/executed/${directory}/*.ipynb --output-dir example_scripts/notebooks/markdown/${directory}/
jupyter nbconvert --to markdown example_scripts/notebook_tutorials/runnable_notebooks/executed/${directory}/*.ipynb --output-dir example_scripts/notebook_tutorials/markdown/${directory}/
echo "starting clean up (rm)"
#rm -rf example_scripts/notebooks/runnable_notebooks/executed/${directory} # Delete temp executed notebook dir.
#rm -rf example_scripts/notebooks/runnable_notebooks/${directory}/*.nc # Delete output nc files.
#rm -rf example_scripts/notebook_tutorials/runnable_notebooks/executed/${directory} # Delete temp executed notebook dir.
#rm -rf example_scripts/notebook_tutorials/runnable_notebooks/${directory}/*.nc # Delete output nc files.

mkdir -p example_scripts/notebooks/markdown_images/${directory}/ # image folder
mkdir -p example_scripts/notebook_tutorials/markdown_images/${directory}/ # image folder

echo "starting loop"
# Loop through generated markdown files.
for FILE in $(find example_scripts/notebooks/markdown/${directory} -name '*.md'); do
for FILE in $(find example_scripts/notebook_tutorials/markdown/${directory} -name '*.md'); do
# Get filename information.
fullname=$(basename $FILE)
filename=${fullname%.*}
Expand All @@ -37,7 +37,7 @@ EOM
# Echo hugo header to beginning of generated md file.
echo "$VAR" | cat - $FILE > temp && mv temp $FILE
sed -i "s+${filename}_files/+/COAsT/${filename}_files/+g" $FILE
[ -d example_scripts/notebooks/markdown/${directory}/${filename}_files ] && mv example_scripts/notebooks/markdown/${directory}/${filename}_files example_scripts/notebooks/markdown_images/${directory}/
[ -d example_scripts/notebook_tutorials/markdown/${directory}/${filename}_files ] && mv example_scripts/notebook_tutorials/markdown/${directory}/${filename}_files example_scripts/notebook_tutorials/markdown_images/${directory}/
echo "script is all done"
done

4 changes: 2 additions & 2 deletions notebooks.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ COPY setup.py .
COPY notebook_to_md.sh .
RUN python -m pip install .
COPY example_scripts ./example_scripts
COPY config ./example_scripts/notebooks/runnable_notebooks/config
RUN unzip COAsT_example_files.zip && mv COAsT_example_files ./example_scripts/notebooks/runnable_notebooks/example_files
COPY config ./example_scripts/notebook_tutorials/runnable_notebooks/config
RUN unzip COAsT_example_files.zip && mv COAsT_example_files ./example_scripts/notebook_tutorials/runnable_notebooks/example_files
RUN bash notebook_to_md.sh

0 comments on commit aaa01c6

Please sign in to comment.