Notebook Execution and Error Check #105
Workflow file for this run
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
name: Notebook Execution and Error Check | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: # This enables manual triggering | |
jobs: | |
execute_notebooks: | |
runs-on: ubuntu-latest | |
env: | |
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11.x | |
- name: Poetry cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pypoetry | |
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Install dependencies | |
run: | | |
make full; | |
poetry add openai==0.28.1 jupyter nbconvert cohere; | |
# pip install openai==0.28.1 jupyter nbconvert; | |
# pip install .; | |
- name: Check for pypdfium2 | |
run: poetry run pip show pypdfium2 | |
- name: Execute notebooks and check for errors | |
run: | | |
cd docs/examples | |
# Function to process a notebook | |
process_notebook() { | |
notebook="$1" | |
echo "Processing $notebook..." | |
poetry run jupyter nbconvert --to notebook --execute "$notebook" | |
if [ $? -ne 0 ]; then | |
echo "Error found in $notebook" | |
exit 1 | |
fi | |
} | |
export -f process_notebook # Export the function for parallel execution | |
# Run in parallel | |
ls *.ipynb | parallel process_notebook |