mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-03 03:59:42 +00:00
monorepo: add script for updating notebook cassettes (#27399)
1. Move dependencies for running notebooks into monorepo poetry test deps; 2. Add script to update cassettes for a single notebook; 3. Add cassettes for some how-to guides. --- To update cassettes for a single notebook, run `docs/scripts/update_cassettes.sh`. For example: ``` ./docs/scripts/update_cassettes.sh docs/docs/how_to/binding.ipynb ``` Requires: 1. monorepo dev and test dependencies installed; 2. env vars required by notebook are set. Note: How-to guides are not currently run in [scheduled job](https://github.com/langchain-ai/langchain/actions/workflows/run_notebooks.yml). Will add cassettes for more how-to guides in subsequent PRs before adding them to scheduled job.
This commit is contained in:
33
docs/scripts/update_cassettes.sh
Executable file
33
docs/scripts/update_cassettes.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the working directory from the input argument, default to 'all' if not provided
|
||||
WORKING_DIRECTORY=${1:-all}
|
||||
|
||||
# Function to delete cassettes
|
||||
delete_cassettes() {
|
||||
local dir=$1
|
||||
if [ "$dir" == "all" ]; then
|
||||
echo "Deleting all cassettes..."
|
||||
rm -f docs/cassettes/*.msgpack.zlib
|
||||
else
|
||||
# Extract the filename from the directory path
|
||||
local filename=$(basename "$dir" .ipynb)
|
||||
echo "Deleting cassettes for $filename..."
|
||||
rm -f docs/cassettes/${filename}_*.msgpack.zlib
|
||||
fi
|
||||
}
|
||||
|
||||
# Delete existing cassettes
|
||||
delete_cassettes "$WORKING_DIRECTORY"
|
||||
|
||||
# Pre-download tiktoken files
|
||||
echo "Pre-downloading tiktoken files..."
|
||||
poetry run python docs/scripts/download_tiktoken.py
|
||||
|
||||
# Prepare notebooks
|
||||
echo "Preparing notebooks for CI..."
|
||||
poetry run python docs/scripts/prepare_notebooks_for_ci.py --comment-install-cells --working-directory "$WORKING_DIRECTORY"
|
||||
|
||||
# Run notebooks
|
||||
echo "Running notebooks..."
|
||||
./docs/scripts/execute_notebooks.sh "$WORKING_DIRECTORY"
|
Reference in New Issue
Block a user