Skip to content

Fix Notebook Runs #793

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

Merged
merged 15 commits into from
May 28, 2024
Merged
53 changes: 38 additions & 15 deletions .github/workflows/examples_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,49 @@ jobs:
# 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 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>=1.2.4" jupyter nbconvert cohere==5.3.2;
- name: Check for pypdfium2
run: poetry run pip show pypdfium2
# Legacy run script
# make full;
# poetry add "openai>=1.2.4" jupyter nbconvert cohere==5.3.2;

# Setup Virtual Environment
python3 -m venv ./.venv
source .venv/bin/activate

# Install the current branch
pip install .

# Install extra stuff for notebook runs
pip install "huggingface_hub[cli]" jupyter nbconvert cohere==5.3.2
pip install nltk
echo "which python $(which python)"
echo "which pip $(which pip)"
echo "pip show nltk: $(pip show nltk)"
- name: Huggingface Hub Login
run: poetry run huggingface-cli login --token $HUGGINGFACE_API_KEY
run: |
source .venv/bin/activate
echo "which python: $(which python)"
echo "which pip $(which pip)"
huggingface-cli login --token $HUGGINGFACE_API_KEY
- name: download nltk data
run: |
source .venv/bin/activate
echo "which pip $(which pip)"
echo "pip show nltk: $(pip show nltk)"
mkdir /tmp/nltk_data;
poetry run python -m nltk.downloader -d /tmp/nltk_data punkt;
- name: Use venv
run: source .venv/bin/activate
python -m nltk.downloader -d /tmp/nltk_data punkt;
# - name: Use venv
# run: source .venv/bin/activate
- name: Execute notebooks and check for errors
run: bash ./.github/workflows/scripts/run_notebooks.sh ${{ matrix.notebook }}
# run: bash ./.github/workflows/scripts/run_notebooks.sh ${{ matrix.notebook }}
run: |
source .venv/bin/activate
bash ./.github/workflows/scripts/run_notebooks.sh ${{ matrix.notebook }}

2 changes: 1 addition & 1 deletion .github/workflows/install_from_hub.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Notebook Execution and Error Check
name: Install from Hub

on:
push:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/scripts/run_notebooks.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
export NLTK_DATA=/tmp/nltk_data;

# Remove the local guardrails directory and use the installed version
rm -rf ./guardrails

# Navigate to notebooks
cd docs/examples

# Get the notebook name from the matrix variable
Expand All @@ -10,10 +14,12 @@ notebook="$1"
invalid_notebooks=("valid_chess_moves.ipynb" "llamaindex-output-parsing.ipynb" "competitors_check.ipynb")
if [[ ! " ${invalid_notebooks[@]} " =~ " ${notebook} " ]]; then
echo "Processing $notebook..."
poetry run jupyter nbconvert --to notebook --execute "$notebook"
# poetry run jupyter nbconvert --to notebook --execute "$notebook"
jupyter nbconvert --to notebook --execute "$notebook"
if [ $? -ne 0 ]; then
echo "Error found in $notebook"
echo "Error in $notebook. See logs for details." >> errors.txt
exit 1
fi
fi

Expand Down
Loading