Skip to content

Commit d4ae76f

Browse files
Add per-version testing restrictions (#246)
* Add per-version testing restrictions * updated testing documentation * replace eland pin on 8.12 with an exemption list
1 parent 4b8923d commit d4ae76f

File tree

7 files changed

+54
-9
lines changed

7 files changed

+54
-9
lines changed

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
run: make install-nbtest
5050
- name: Warm up
5151
continue-on-error: true
52-
run: sleep 30 && PATCH_ES=1 ELASTIC_CLOUD_ID=foo ELASTIC_API_KEY=bar bin/nbtest notebooks/search/00-quick-start.ipynb
52+
run: sleep 30 && PATCH_ES=1 ELASTIC_CLOUD_ID=foo ELASTIC_API_KEY=bar ES_STACK=${{ matrix.es_stack }} bin/nbtest notebooks/search/00-quick-start.ipynb
5353
- name: Run tests
54-
run: PATCH_ES=1 FORCE_COLOR=1 make -s test
54+
run: PATCH_ES=1 FORCE_COLOR=1 ES_STACK=${{ matrix.es_stack }} make -s test
5555
- name: Show installed Python dependencies
5656
if: always()
5757
run: .venv/bin/pip freeze

CONTRIBUTING.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ To run all supported notebooks under this tool, run the following from the top-l
8888
make test
8989
```
9090

91-
To add a new notebook to our automated testing, you will need to modify the `Makefile` in the directory where your notebook is located. If there is no Makefile in your directory, you can use the one in the `notebooks/search` directory as a model to create one, and then add a reference to it in the top-level `Makefile`.
91+
If you want to test under a previous release of Elasticsearch, you can define the `ES_STACK` variable with the target version so that notebooks that are not intended for that or previous versions are skipped. For example, here is how to only run tests for the 8.12 release of Elasticsearch:
92+
93+
```bash
94+
ES_STACK=8.12 make test
95+
```
96+
97+
Any notebooks that are added in subdirectories under `notebooks` are automatically picked up for testing. Notebooks that are known to not be suitable for automatic testing should be added to the list of exempt tests in the `bin/find_notebooks_to_test.sh` script. If the notebook should never be tested, add it to the `EXEMPT_NOTEBOOKS` list. If the notebook should be tested only under some versions of Elasticsearch, then add it to the appropriate versioned exemption list. For example, the `EXEMPT_NOTEBOOKS__8_12` list should include notebooks that are not be tested under releases 8.12 and older. New versioned lists are automatically recognized and can be added as needed.
9298

9399
## Contributing to example applications 💻
94100

bin/find-notebooks-to-test.sh

+40-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
2-
# add any notebooks that are currently not testable to the exempt list
2+
33
EXEMPT_NOTEBOOKS=(
4+
# Add any notebooks that are currently not testable to the exempt list
45
"notebooks/esql/esql-getting-started.ipynb"
56
"notebooks/search/07-inference.ipynb"
67
"notebooks/search/08-learning-to-rank.ipynb"
@@ -25,9 +26,46 @@ EXEMPT_NOTEBOOKS=(
2526
"notebooks/enterprise-search/app-search-engine-exporter.ipynb"
2627
)
2728

29+
# Per-version testing exceptions
30+
# use variables named EXEMPT_NOTEBOOKS__{major}_[minor} to list notebooks that
31+
# cannot run on that stack version or older
32+
# Examples:
33+
# EXEMPT_NOTEBOOKS__8 for notebooks that must be skipped on all versions 8.x and older
34+
# EXEMPT_NOTEBOOKS__8_12 for notebooks that must skipped on versions 8.12 and older
35+
36+
EXEMPT_NOTEBOOKS__8_12=(
37+
# Add any notebooks that must be skipped on versions 8.12 or older here
38+
"notebooks/document-chunking/with-index-pipelines.ipynb"
39+
"notebooks/document-chunking/with-langchain-splitters.ipynb"
40+
"notebooks/integrations/hugging-face/loading-model-from-hugging-face.ipynb"
41+
"notebooks/langchain/langchain-using-own-model.ipynb"
42+
)
43+
44+
# this function parses a version given as M[.N[.P]] or M[_N[_P]] into a numeric form
45+
function parse_version { echo "$@" | awk -F'[._]' '{ printf("%02d%02d\n", $1, $2); }'; }
46+
47+
# this is the version CI is running
48+
ci_version=$(parse_version ${ES_STACK:-99.99})
49+
2850
ALL_NOTEBOOKS=$(find notebooks -name "*.ipynb" | grep -v "_nbtest" | grep -v ".ipynb_checkpoints" | sort)
2951
for notebook in $ALL_NOTEBOOKS; do
30-
if [[ ! "${EXEMPT_NOTEBOOKS[@]}" =~ $notebook ]]; then
52+
skip=
53+
# check the master exception list
54+
if [[ "${EXEMPT_NOTEBOOKS[@]}" =~ $notebook ]]; then
55+
skip=yes
56+
else
57+
# check the versioned exception lists
58+
for exempt_key in ${!EXEMPT_NOTEBOOKS__*}; do
59+
exempt_version=$(parse_version ${exempt_key/EXEMPT_NOTEBOOKS__/})
60+
if [ $exempt_version -ge $ci_version ]; then
61+
exempt_notebooks=$(eval 'echo ${'${exempt_key}'[@]}')
62+
if [[ "${exempt_notebooks[@]}" =~ $notebook ]]; then
63+
skip=yes
64+
fi
65+
fi
66+
done
67+
fi
68+
if [[ "$skip" == "" ]]; then
3169
echo $notebook
3270
fi
3371
done

notebooks/document-chunking/with-index-pipelines.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"outputs": [],
5656
"source": [
57-
"!python3 -m pip install -qU elasticsearch eland==8.12.1"
57+
"!python3 -m pip install -qU elasticsearch eland"
5858
]
5959
},
6060
{
@@ -84,6 +84,7 @@
8484
"source": [
8585
"from elasticsearch import Elasticsearch\n",
8686
"from getpass import getpass\n",
87+
"import time\n",
8788
"\n",
8889
"# https://www.elastic.co/search-labs/tutorials/install-elasticsearch/elastic-cloud#finding-your-cloud-id\n",
8990
"ELASTIC_CLOUD_ID = getpass(\"Elastic Cloud ID: \")\n",

notebooks/document-chunking/with-langchain-splitters.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
34-
"!python3 -m pip install -qU langchain langchain-elasticsearch elasticsearch eland==8.12.1 jq"
34+
"!python3 -m pip install -qU langchain langchain-community langchain-elasticsearch elasticsearch eland jq"
3535
]
3636
},
3737
{

notebooks/integrations/hugging-face/loading-model-from-hugging-face.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
"outputs": [],
4949
"source": [
50-
"!python3 -m pip install sentence-transformers eland==8.12.1 elasticsearch transformers"
50+
"!python3 -m pip install sentence-transformers eland elasticsearch transformers"
5151
]
5252
},
5353
{

notebooks/langchain/langchain-using-own-model.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"metadata": {},
3131
"outputs": [],
3232
"source": [
33-
"!python3 -m pip install -qU langchain langchain-elasticsearch tiktoken sentence-transformers eland==8.12.1 transformers\n",
33+
"!python3 -m pip install -qU langchain langchain-elasticsearch tiktoken sentence-transformers eland transformers\n",
3434
"\n",
3535
"from getpass import getpass\n",
3636
"from langchain_elasticsearch import ElasticsearchStore\n",

0 commit comments

Comments
 (0)