Skip to content

Commit

Permalink
add working-directory parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ccurme committed Sep 27, 2024
1 parent ffffa7d commit 65f439d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/run_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
description: 'Python version'
required: false
default: '3.11'
working-directory:
description: 'Working directory or specific notebook file'
required: false
default: 'all'
schedule:
- cron: '0 13 * * *'

Expand Down Expand Up @@ -56,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

0 comments on commit 65f439d

Please sign in to comment.