Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated directory name for notebooks #630

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
4 changes: 2 additions & 2 deletions example_scripts/README
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
example_scripts
+++++++++++++++

notebooks/
notebook_tutorials/
----------
This folder contains python notebook tutorials that are rendered in the documentation pages, though the use of Git Actions.
Any external data required by these notebooks can be downloaded in the example_files zip bundle.



In addition to notebooks/, the python scripts are user contributions of useful applications, which haven't gone through
In addition to notebook_tutorials/, the python scripts are user contributions of useful applications, which haven't gone through
the rigours of being converted into tutorial material. Some of these are in folders.


Expand Down
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
Loading