-
Notifications
You must be signed in to change notification settings - Fork 100
153 lines (134 loc) · 5.53 KB
/
run_tutorials_v1.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Run Tutorials for v1.x
on:
workflow_dispatch: # Activate this workflow manually
pull_request:
paths:
# This workflow must run only for v1.x tutorials
# Some v1 tutorials are ignored in any case as we can't run those
# for different reasons
- "tutorials/01_Basic_QA_Pipeline.ipynb"
- "tutorials/03_Scalable_QA_System.ipynb"
- "tutorials/04_FAQ_style_QA.ipynb"
- "tutorials/05_Evaluation.ipynb"
- "tutorials/06_Better_Retrieval_via_Embedding_Retrieval.ipynb"
- "tutorials/07_RAG_Generator.ipynb"
- "tutorials/08_Preprocessing.ipynb"
- "tutorials/10_Knowledge_Graph.ipynb"
- "tutorials/11_Pipelines.ipynb"
- "tutorials/14_Query_Classifier.ipynb"
- "tutorials/15_TableQA.ipynb"
- "tutorials/16_Document_Classifier_at_Index_Time.ipynb"
- "tutorials/19_Text_to_Image_search_pipeline_with_MultiModal_Retriever.ipynb"
- "tutorials/20_Using_Haystack_with_REST_API.ipynb"
- "tutorials/21_Customizing_PromptNode.ipynb"
- "tutorials/22_Pipeline_with_PromptNode.ipynb"
- "tutorials/23_Answering_Multihop_Questions_with_Agents.ipynb"
- "tutorials/24_Building_Chat_App.ipynb"
- "tutorials/25_Customizing_Agents.ipynb"
- "tutorials/26_Hybrid_Retrieval.ipynb"
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.filter.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- id: generator
env:
GH_TOKEN: ${{ github.token }}
run: |
# Get tutorial notebooks for 1.x
VERSION=$(gh api /repos/deepset-ai/haystack/releases | \
jq -r '[.[].tag_name | select(test("^v1.[0-9]+.[0-9]+$"))] | first')
NOTEBOOKS=$(python ./scripts/generate_matrix.py --haystack-version "$VERSION")
echo "matrix={\"include\":$NOTEBOOKS}" >> "$GITHUB_OUTPUT"
- name: Get changed files
id: files
uses: tj-actions/changed-files@v44
with:
matrix: true
# We only want v1 tutorials, this is a necessary duplication
files: |
tutorials/01_Basic_QA_Pipeline.ipynb
tutorials/03_Scalable_QA_System.ipynb
tutorials/04_FAQ_style_QA.ipynb
tutorials/05_Evaluation.ipynb
tutorials/06_Better_Retrieval_via_Embedding_Retrieval.ipynb
tutorials/07_RAG_Generator.ipynb
tutorials/08_Preprocessing.ipynb
tutorials/10_Knowledge_Graph.ipynb
tutorials/11_Pipelines.ipynb
tutorials/14_Query_Classifier.ipynb
tutorials/15_TableQA.ipynb
tutorials/16_Document_Classifier_at_Index_Time.ipynb
tutorials/19_Text_to_Image_search_pipeline_with_MultiModal_Retriever.ipynb
tutorials/20_Using_Haystack_with_REST_API.ipynb
tutorials/21_Customizing_PromptNode.ipynb
tutorials/22_Pipeline_with_PromptNode.ipynb
tutorials/23_Answering_Multihop_Questions_with_Agents.ipynb
tutorials/24_Building_Chat_App.ipynb
tutorials/25_Customizing_Agents.ipynb
tutorials/26_Hybrid_Retrieval.ipynb
- name: Filter non changed notebooks
id: filter
shell: python
env:
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)
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
print(f"matrix={new_matrix}", file=f)
run-tutorials:
runs-on: ubuntu-latest
needs: generate-matrix
container: deepset/haystack:base-cpu-${{ matrix.haystack_version }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
services:
elasticsearch:
image: elasticsearch:7.9.2
env:
discovery.type: "single-node"
ES_JAVA_OPTS: "-Xms128m -Xmx256m"
env:
HAYSTACK_TELEMETRY_ENABLED: "False"
ELASTICSEARCH_HOST: "elasticsearch"
steps:
- name: Install dependencies
run: |
apt-get update && apt-get install -y git build-essential gcc libsndfile1 ffmpeg && rm -rf /var/lib/apt/lists/*
pip install nbconvert ipython
pip install "pyworld<=0.2.12" espnet espnet-model-zoo pydub
pip install farm-haystack[pdf]
- name: Install Haystack Extras text2speech dependencies
run: |
pip install farm-haystack-text2speech
- name: Install Hugging Face datasets
run: |
pip install "datasets>=2.6.1"
- name: Checkout
uses: actions/checkout@v4
# See https://github.com/actions/runner-images/issues/6775
- name: Change Owner of Container Working Directory
run: chown root:root .
- name: Convert notebook to Python
run: |
jupyter nbconvert --to python --RegexRemovePreprocessor.patterns '%%bash' ./tutorials/${{ matrix.notebook }}.ipynb
- name: Run the converted notebook
run: |
python ./tutorials/${{ matrix.notebook }}.py