-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #258 from lettlini/notebook_workflow
Actions for Generating and Checking Jupyter Notebooks
- Loading branch information
Showing
3 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Jupyter Notebooks CI | ||
on: [push, pull_request] | ||
jobs: | ||
Check-Notebooks: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -el {0} | ||
steps: | ||
- name: check out repository code | ||
uses: actions/checkout@v3 | ||
- name: set up conda environment | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
auto-update-conda: true | ||
auto-activate-base: false | ||
activate-environment: notebook-env | ||
- name: Install tobac dependencies | ||
run: | | ||
conda install -c conda-forge --yes ffmpeg gcc jupyter pytables | ||
conda install -c conda-forge --yes --file requirements.txt | ||
- name: Install tobac | ||
run: | | ||
pip install . | ||
- name: Find all notebook files | ||
run: | | ||
find . -type f -name '*.ipynb' > nbfiles.txt | ||
cat nbfiles.txt | ||
- name: Execute all notebook files | ||
run: | | ||
while IFS= read -r nbpath; do | ||
jupyter nbconvert --inplace --ClearMetadataPreprocessor.enabled=True --clear-output $nbpath | ||
jupyter nbconvert --to notebook --inplace --execute $nbpath | ||
done < nbfiles.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Generate Jupyter Notebooks | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
workflow_dispatch: | ||
jobs: | ||
Generate-Notebooks: | ||
if: (github.event.pull_request.merged == true) || (github.event_name == 'workflow_dispatch') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
defaults: | ||
run: | ||
shell: bash -el {0} | ||
steps: | ||
- name: check out repository code | ||
uses: actions/checkout@v3 | ||
- name: set up conda environment | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
auto-update-conda: true | ||
auto-activate-base: false | ||
activate-environment: notebook-env | ||
- name: Install tobac dependencies | ||
run: | | ||
conda install -c conda-forge --yes ffmpeg gcc jupyter pytables | ||
conda install -c conda-forge --yes --file requirements.txt | ||
- name: Install tobac | ||
run: | | ||
pip install . | ||
- name: Find all notebook files | ||
run: | | ||
find . -type f -name '*.ipynb' > nbfiles.txt | ||
cat nbfiles.txt | ||
- name: Execute all notebook files | ||
run: | | ||
while IFS= read -r nbpath; do | ||
jupyter nbconvert --inplace --ClearMetadataPreprocessor.enabled=True --clear-output $nbpath | ||
jupyter nbconvert --to notebook --inplace --execute $nbpath | ||
done < nbfiles.txt | ||
- name: Commit changed notebooks | ||
run: | | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
find . -type f -name "*.ipynb" -exec git add {} + | ||
git commit -m "Generated Notebooks" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters