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

infra[patch]: update notebooks workflow #26956

Merged
merged 3 commits into from
Sep 27, 2024
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
15 changes: 11 additions & 4 deletions .github/workflows/run_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ name: Run notebooks

on:
workflow_dispatch:
inputs:
python_version:
description: 'Python version'
required: false
default: '3.11'
working-directory:
description: 'Working directory or subset (e.g., docs/docs/tutorials/llm_chain.ipynb)'
required: false
default: 'all'
schedule:
- cron: '0 13 * * *'

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.7.1"

jobs:
Expand All @@ -20,7 +28,7 @@ jobs:
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
with:
python-version: ${{ env.PYTHON_VERSION }}
python-version: ${{ github.event.inputs.python_version || '3.11' }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: ${{ inputs.working-directory }}
cache-key: run-notebooks
Expand All @@ -43,7 +51,6 @@ jobs:

- name: Prepare notebooks
run: |

python docs/scripts/prepare_notebooks_for_ci.py --comment-install-cells

- name: Run notebooks
Expand All @@ -53,4 +60,4 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
run: |
./docs/scripts/execute_notebooks.sh
./docs/scripts/execute_notebooks.sh ${{ github.event.inputs.working-directory || 'all' }}
11 changes: 9 additions & 2 deletions docs/scripts/execute_notebooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Read the list of notebooks to skip from the JSON file
SKIP_NOTEBOOKS=$(python -c "import json; print('\n'.join(json.load(open('docs/notebooks_no_execution.json'))))")

# Get the working directory or specific notebook file from the input parameter
WORKING_DIRECTORY=$1

# Function to execute a single notebook
execute_notebook() {
file="$1"
Expand All @@ -22,8 +25,12 @@ execute_notebook() {

export -f execute_notebook

# Find all notebooks and filter out those in the skip list
notebooks=$(find docs/docs/tutorials -name "*.ipynb" | grep -v ".ipynb_checkpoints" | grep -vFf <(echo "$SKIP_NOTEBOOKS"))
# Determine the list of notebooks to execute
if [ "$WORKING_DIRECTORY" == "all" ]; then
notebooks=$(find docs/docs/tutorials -name "*.ipynb" | grep -v ".ipynb_checkpoints" | grep -vFf <(echo "$SKIP_NOTEBOOKS"))
else
notebooks=$(find "$WORKING_DIRECTORY" -name "*.ipynb" | grep -v ".ipynb_checkpoints" | grep -vFf <(echo "$SKIP_NOTEBOOKS"))
fi

# Execute notebooks sequentially
for file in $notebooks; do
Expand Down
Loading