Skip to content

W2D2 Post-Course Update #547

W2D2 Post-Course Update

W2D2 Post-Course Update #547

Workflow file for this run

name: notebook-pr
on:
pull_request:
branches: main
paths: "**/*.ipynb"
env:
NB_KERNEL: python
ORG: neuromatch
NMA_REPO: NeuroAI_Course
NMA_MAIN_BRANCH: main
jobs:
process-notebooks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Get commit message
run: |
readonly local msg=$(git log -1 --pretty=format:"%s")
echo "COMMIT_MESSAGE=$msg" >> $GITHUB_ENV
- name: Set up Python
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install CI tools
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
run: |
BRANCH=`python -c 'import os, re; m = re.search(r"nmaci:([\w-]+)", os.environ["COMMIT_MESSAGE"]); print("main" if m is None else m.group(1))'`
# NOTE: might enventually change this back if we integrate changes
wget https://github.com/neuromatch/nmaci/archive/refs/heads/$BRANCH.tar.gz
tar -xzf $BRANCH.tar.gz
pip install --upgrade pip
pip install -r nmaci-$BRANCH/requirements.txt
mv nmaci-$BRANCH/scripts/ ci/
rm -r nmaci-$BRANCH
echo ci/ >> .gitignore
- name: Install dependencies
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
run: |
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
pip install jupyter_client==7.3.5 # downgrade jupyter-client to fix hangs
pip install jinja2==3.1.2 # to fix pandas dep
- name: Install XKCD fonts
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
run: |
sudo apt-get update -yq
wget http://archive.ubuntu.com/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-4_all.deb
sudo dpkg -i --force-all fonts-humor-sans_1.0-4_all.deb <<< 'yes'
sudo apt install -fy
rm -f $HOME/.matplotlib/fontList.cache
- name: Install backend libs
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
run: |
# required for macrocircuits project
sudo apt-get install -y libglew-dev
sudo apt-get install -y libglfw3
sudo apt install -y ffmpeg
echo "MUJOCO_GL=egl" >> $GITHUB_ENV
- name: Install Graphviz
uses: tlylt/install-graphviz@v1
- name: Get changed files
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
id: changed-files
uses: tj-actions/changed-files@v35
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed."
done
- name: Process notebooks
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
id: process_notebooks
run: |
branch=${{ github.event.pull_request.head.ref }}
nbs=`python ci/select_notebooks.py ${{ steps.changed-files.outputs.all_changed_files }}`
if ${{ contains(env.COMMIT_MESSAGE, 'ci:check') }}; then
execflag="--check-execution";
else
execflag="--execute";
fi
python ci/process_notebooks.py $nbs $execflag
python ci/verify_exercises.py $nbs --c "$COMMIT_MESSAGE"
python ci/make_pr_comment.py $nbs --branch $branch --o comment.txt
# - name: Add PR comment
# if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
# uses: machine-learning-apps/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# path: comment.txt
- name: Update READMEs
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
run: python ci/generate_tutorial_readmes.py
- name: Remove unreferenced derivatives
if: "!contains(env.COMMIT_MESSAGE, 'skip ci') && success()"
run: |
python ci/find_unreferenced_content.py > to_remove.txt
if [ -s to_remove.txt ]; then git rm --pathspec-from-file=to_remove.txt; fi
- name: Commit post-processed files
if: "!contains(env.COMMIT_MESSAGE, 'skip ci') && success()"
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add '**/*.ipynb'
git add '**/static/*.png'
git add '**/solutions/*.py'
git add '**/README.md'
git diff-index --quiet HEAD || git commit -m "Process tutorial notebooks"
- name: Push post-processed files
if: "!contains(env.COMMIT_MESSAGE, 'skip ci') && success()"
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}