mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-26 16:43:35 +00:00
infra[patch]: update notebooks workflow (#26956)
Addressing some lingering comments from https://github.com/langchain-ai/langchain/pull/26944, adding parameters for - python version - working directory 
This commit is contained in:
parent
67df944dfb
commit
44eddd39d6
15
.github/workflows/run_notebooks.yml
vendored
15
.github/workflows/run_notebooks.yml
vendored
@ -2,11 +2,19 @@ name: Run notebooks
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
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:
|
schedule:
|
||||||
- cron: '0 13 * * *'
|
- cron: '0 13 * * *'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PYTHON_VERSION: "3.11"
|
|
||||||
POETRY_VERSION: "1.7.1"
|
POETRY_VERSION: "1.7.1"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -20,7 +28,7 @@ jobs:
|
|||||||
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
|
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
|
||||||
uses: "./.github/actions/poetry_setup"
|
uses: "./.github/actions/poetry_setup"
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ github.event.inputs.python_version || '3.11' }}
|
||||||
poetry-version: ${{ env.POETRY_VERSION }}
|
poetry-version: ${{ env.POETRY_VERSION }}
|
||||||
working-directory: ${{ inputs.working-directory }}
|
working-directory: ${{ inputs.working-directory }}
|
||||||
cache-key: run-notebooks
|
cache-key: run-notebooks
|
||||||
@ -43,7 +51,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Prepare notebooks
|
- name: Prepare notebooks
|
||||||
run: |
|
run: |
|
||||||
|
|
||||||
python docs/scripts/prepare_notebooks_for_ci.py --comment-install-cells
|
python docs/scripts/prepare_notebooks_for_ci.py --comment-install-cells
|
||||||
|
|
||||||
- name: Run notebooks
|
- name: Run notebooks
|
||||||
@ -53,4 +60,4 @@ jobs:
|
|||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
|
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
|
||||||
run: |
|
run: |
|
||||||
./docs/scripts/execute_notebooks.sh
|
./docs/scripts/execute_notebooks.sh ${{ github.event.inputs.working-directory || 'all' }}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
# Read the list of notebooks to skip from the JSON file
|
# 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'))))")
|
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
|
# Function to execute a single notebook
|
||||||
execute_notebook() {
|
execute_notebook() {
|
||||||
file="$1"
|
file="$1"
|
||||||
@ -22,8 +25,12 @@ execute_notebook() {
|
|||||||
|
|
||||||
export -f execute_notebook
|
export -f execute_notebook
|
||||||
|
|
||||||
# Find all notebooks and filter out those in the skip list
|
# Determine the list of notebooks to execute
|
||||||
notebooks=$(find docs/docs/tutorials -name "*.ipynb" | grep -v ".ipynb_checkpoints" | grep -vFf <(echo "$SKIP_NOTEBOOKS"))
|
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
|
# Execute notebooks sequentially
|
||||||
for file in $notebooks; do
|
for file in $notebooks; do
|
||||||
|
Loading…
Reference in New Issue
Block a user