Skip to content

Merge pull request #981 from guardrails-ai/hub-contribution-doc #545

Merge pull request #981 from guardrails-ai/hub-contribution-doc

Merge pull request #981 from guardrails-ai/hub-contribution-doc #545

name: Notebook Execution and Error Check
on:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
- dev
workflow_dispatch: # This enables manual triggering
jobs:
execute_notebooks:
runs-on: ubuntu-latest
strategy:
matrix:
# this line is automatically generated by the script in .github/workflows/scripts/update_notebook_matrix.sh
notebook: ["bug_free_python_code.ipynb","check_for_pii.ipynb","competitors_check.ipynb","extracting_entities.ipynb","generate_structured_data.ipynb","generate_structured_data_cohere.ipynb","guardrails_with_chat_models.ipynb","input_validation.ipynb","llamaindex-output-parsing.ipynb","no_secrets_in_generated_text.ipynb","provenance.ipynb","recipe_generation.ipynb","regex_validation.ipynb","response_is_on_topic.ipynb","secrets_detection.ipynb","select_choice_based_on_action.ipynb","syntax_error_free_sql.ipynb","text_summarization_quality.ipynb","toxic_language.ipynb","translation_to_specific_language.ipynb","translation_with_quality_check.ipynb","valid_chess_moves.ipynb","value_within_distribution.ipynb"]
env:
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
NLTK_DATA: /tmp/nltk_data
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Create .guardrailsrc
run: |
echo 'id="SYSTEM TESTING"' > ~/.guardrailsrc
echo 'no_metrics=false' >> ~/.guardrailsrc
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11.x
- name: Install dependencies
run: |
# 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
- name: Huggingface Hub Login
run: |
source .venv/bin/activate
huggingface-cli login --token $HUGGINGFACE_API_KEY
- name: download nltk data
run: |
source .venv/bin/activate
mkdir /tmp/nltk_data;
python -m nltk.downloader -d /tmp/nltk_data punkt;
- name: Execute notebooks and check for errors
run: |
source .venv/bin/activate
bash ./.github/workflows/scripts/run_notebooks.sh ${{ matrix.notebook }}