Skip to content

Commit

Permalink
Prepare notebooks repository to integrate into documentation (openvin…
Browse files Browse the repository at this point in the history
…otoolkit#562)

* Apply rebase

* Make comments clear

* Update 213

* Fix metadata 213

Co-authored-by: Paula Ramos <[email protected]>
  • Loading branch information
Jakub Debski and paularamo authored Jul 13, 2022
1 parent 07404c8 commit bc3c8c5
Show file tree
Hide file tree
Showing 6 changed files with 326 additions and 144 deletions.
9 changes: 7 additions & 2 deletions .ci/convert_notebooks.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

rstdir=$PWD"/rst_files"
binderlist=$rstdir"/notebooks_with_buttons.txt"
tagslist=$rstdir"/notebooks_tags.json"
htmldir=$PWD"/html_files"
markdowndir=$PWD"/markdown_files"
mkdir -p $rstdir
Expand All @@ -11,13 +12,17 @@ mkdir -p $markdowndir

# List all notebooks that contain binder buttons based on readme
cat README.md | cut -d'|' --output-delimiter=$'\n' -f2- | grep -E ".*mybinder.*[0-9]{3}.*" | cut -f1 -d] | cut -f2 -d[ | sort | uniq > $binderlist
taggerpath=$(git ls-files "*tagger.py")
notebookspath=$(git ls-files "*.ipynb"| head -n 1)
keywordspath=$(git ls-files "*keywords.json")
python $taggerpath $notebookspath $keywordspath> $tagslist

git ls-files "*.ipynb" | while read notebook; do
executed_notebook=${notebook/.ipynb/-with-output.ipynb}
echo $executed_notebook
jupyter nbconvert --log-level=INFO --execute --to notebook --output $executed_notebook --output-dir . --ExecutePreprocessor.kernel_name="python3" $notebook
jupyter nbconvert --to markdown $executed_notebook --output-dir $markdowndir --TagRemovePreprocessor.remove_all_outputs_tags=hide_output --TagRemovePreprocessor.enabled=True
jupyter nbconvert --to html $executed_notebook --output-dir $htmldir --TagRemovePreprocessor.remove_all_outputs_tags=hide_output --TagRemovePreprocessor.enabled=True
# jupyter nbconvert --to markdown $executed_notebook --output-dir $markdowndir --TagRemovePreprocessor.remove_all_outputs_tags=hide_output --TagRemovePreprocessor.enabled=True
# jupyter nbconvert --to html $executed_notebook --output-dir $htmldir --TagRemovePreprocessor.remove_all_outputs_tags=hide_output --TagRemovePreprocessor.enabled=True
jupyter nbconvert --to rst $executed_notebook --output-dir $rstdir --TagRemovePreprocessor.remove_all_outputs_tags=hide_output --TagRemovePreprocessor.enabled=True
done

Expand Down
16 changes: 10 additions & 6 deletions .ci/tagger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import glob
import mmap

import sys

def get_notebooks(path: str):
return glob.glob(f"{path}/*/[0-9]*.ipynb")
Expand All @@ -28,8 +28,12 @@ def find_tags_for_all_notebooks(notebooks: list, tags: dict):
notebooks_tags[notebook.split('/')[-1].split('.')[0]] = nb_tags
return notebooks_tags

notebooks_paths = sorted(get_notebooks("notebooks"))
tags = get_tags(".ci/keywords.json")['tags']
all_notebooks_tags = find_tags_for_all_notebooks(notebooks_paths, tags)

print(json.dumps(all_notebooks_tags, indent=4))
if __name__ == "__main__":
if len(sys.argv) == 1:
notebooks_paths = sorted(get_notebooks("notebooks"))
tags = get_tags(".ci/keywords.json")['tags']
else:
notebooks_paths = sorted(get_notebooks('/'.join(sys.argv[1].split('/')[:-2])))
tags = get_tags(sys.argv[2])['tags']
all_notebooks_tags = find_tags_for_all_notebooks(notebooks_paths, tags)
print(json.dumps(all_notebooks_tags, indent=4))
6 changes: 5 additions & 1 deletion .github/workflows/convert_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ jobs:

steps:
- name: Install required packages for rst converstion
run: sudo apt-get update && sudo apt-get install texlive texlive-latex-extra pandoc -y
run: |
sudo apt-get update && sudo apt-get install texlive texlive-latex-extra pandoc -y
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
shell: bash

#### Installation/preparation ####
#
Expand Down
Loading

0 comments on commit bc3c8c5

Please sign in to comment.