Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 0 additions & 95 deletions .github/workflows/nightly.yml

This file was deleted.

77 changes: 48 additions & 29 deletions .github/workflows/run_tutorials.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
name: Run Haystack Tutorials
name: Run Tutorials

on:
workflow_dispatch: # Activate this workflow manually
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
workflow_dispatch: # Activate this workflow manually
workflow_dispatch:

Isn't the comment outdated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a just a comment that informs that using this event, you can activate the workflow manually
More info: https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_dispatch

Currently, in https://github.com/deepset-ai/haystack-tutorials/actions/workflows/nightly.yml there is this button
image

schedule:
- cron: "0 0 * * *"
pull_request:
paths:
- "tutorials/*.ipynb"

jobs:
generate-matrix:
runs-on: ubuntu-latest
runs-on: ubuntu-slim
outputs:
matrix: ${{ steps.filter.outputs.matrix }}
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
python-version: "3.11"

Expand All @@ -28,39 +31,41 @@ jobs:
echo "matrix={\"include\":$NOTEBOOKS}" >> "$GITHUB_OUTPUT"

- name: Get changed files
if: github.event_name == 'pull_request'
id: files
uses: tj-actions/changed-files@v46
uses: tj-actions/changed-files@v47
with:
matrix: true
files: tutorials/*.ipynb

- name: Filter non changed notebooks
id: filter
- name: Filter to changed notebooks (pull request only)
id: matrix
shell: python
env:
EVENT_NAME: ${{ github.event_name }}
MATRIX: ${{ steps.generator.outputs.matrix }}
CHANGED_FILES: ${{ steps.files.outputs.all_changed_files }}
run: |
import os
import json

matrix = json.loads(os.environ["MATRIX"])
changed_files = json.loads(os.environ["CHANGED_FILES"])
new_matrix = {"include": []}
for item in matrix["include"]:
notebook = item["notebook"]
if f"tutorials/{notebook}.ipynb" not in changed_files:
continue
new_matrix["include"].append(item)

new_matrix = json.dumps(new_matrix)

if os.environ["EVENT_NAME"] == "pull_request":
changed_files = json.loads(os.environ["CHANGED_FILES"])
new_matrix = {"include": []}
for item in matrix["include"]:
notebook = item["notebook"]
if f"tutorials/{notebook}.ipynb" in changed_files:
new_matrix["include"].append(item)
matrix = new_matrix

with open(os.environ["GITHUB_OUTPUT"], "a") as f:
print(f"matrix={new_matrix}", file=f)
print(f"matrix={json.dumps(matrix)}", file=f)

run-tutorials:
runs-on: ubuntu-latest
needs: generate-matrix
container: deepset/haystack:base-${{ matrix.haystack_version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand All @@ -75,29 +80,37 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup Python and uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.11"

- name: Install common dependencies
run: |
apt-get update && apt-get install -y \
build-essential \
gcc \
libsndfile1 \
ffmpeg

pip install nbconvert ipython
uv venv
if [ "${{ matrix.haystack_version }}" = "main" ]; then
uv pip install "haystack-ai @ git+https://github.com/deepset-ai/haystack.git@main"
else
VERSION="${{ matrix.haystack_version }}"
uv pip install "haystack-ai==${VERSION#v}"
fi
uv pip install nbconvert ipython

- name: Install tutorial dependencies
if: toJSON(matrix.dependencies) != '[]'
run: |
pip install "${{ join(matrix.dependencies, '" "')}}"
uv pip install "${{ join(matrix.dependencies, '" "')}}"

- name: Convert notebook to Python
run: |
. .venv/bin/activate
jupyter nbconvert --to python --RegexRemovePreprocessor.patterns '%%bash' ./tutorials/${{ matrix.notebook }}.ipynb

- name: Run the converted notebook
run: |
. .venv/bin/activate
NOTEBOOK="./tutorials/${{ matrix.notebook }}.py"
if [ "${{ matrix.notebook }}" = "47_Human_in_the_Loop_Agent" ]; then
# We add a prompt to confirm any user inputs in the HiTL notebook
Expand All @@ -107,3 +120,9 @@ jobs:
else
python "$NOTEBOOK"
fi

- name: Notify Slack on nightly failure
if: failure() && github.event_name != 'pull_request'
uses: deepset-ai/notify-slack-action@v1
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_NOTIFICATIONS }}
16 changes: 10 additions & 6 deletions .github/workflows/verify_generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ on:
- "index.toml"

jobs:
run-tutorials:
runs-on: ubuntu-latest
verify-markdown-generation:
runs-on: ubuntu-slim

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- uses: actions/setup-python@v5
- name: Setup Python and uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: pip install -r requirements.txt
run: |
uv venv
uv pip install -r requirements.txt

- name: Generate all tutorials
run: |
. .venv/bin/activate
mkdir output
python scripts/generate_markdowns.py --index index.toml --notebooks all --output ./output