Skip to content

Commit

Permalink
Add per-version testing restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed May 22, 2024
1 parent 4b8923d commit 5bdbee6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
run: make install-nbtest
- name: Warm up
continue-on-error: true
run: sleep 30 && PATCH_ES=1 ELASTIC_CLOUD_ID=foo ELASTIC_API_KEY=bar bin/nbtest notebooks/search/00-quick-start.ipynb
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
- name: Run tests
run: PATCH_ES=1 FORCE_COLOR=1 make -s test
run: PATCH_ES=1 FORCE_COLOR=1 ES_STACK=${{ matrix.es_stack }} make -s test
- name: Show installed Python dependencies
if: always()
run: .venv/bin/pip freeze
42 changes: 40 additions & 2 deletions bin/find-notebooks-to-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
# add any notebooks that are currently not testable to the exempt list

EXEMPT_NOTEBOOKS=(
# Add any notebooks that are currently not testable to the exempt list
"notebooks/esql/esql-getting-started.ipynb"
"notebooks/search/07-inference.ipynb"
"notebooks/search/08-learning-to-rank.ipynb"
Expand All @@ -25,9 +26,46 @@ EXEMPT_NOTEBOOKS=(
"notebooks/enterprise-search/app-search-engine-exporter.ipynb"
)

# Per-version testing exceptions
# use variables named EXEMPT_NOTEBOOKS__{major}_[minor}_{patch} to list
# notebooks that cannot run on that stack version or older
# Examples:
# EXEMPT_NOTEBOOKS__8 for notebooks that must be skipped on all versions 8.x and older
# EXEMPT_NOTEBOOKS__8_14 for notebooks that must skipped on versions 8.14 and older
# EXEMPT_NOTEBOOKS__8_13_2 for notebooks that must be skipped on versions 8.13.2 and older

EXEMPT_NOTEBOOKS__8_13=(
# Add any notebooks that must be skipped on versions 8.13 or older here
"notebooks/search/03-ELSER.ipynb"
"notebooks/model-upgrades/upgrading-index-to-use-elser.ipynb"
"notebooks/langchain/langchain-vector-store-using-elser.ipynb"
)

# this function parses a version given as M[.N[.P]] or M[_N[_P]] into a numeric form
function parse_version { echo "$@" | awk -F'[._]' '{ printf("%02d%02d%02d\n", $1, $2, $3); }'; }

# this is the version CI is running
ci_version=$(parse_version ${ES_STACK:-99.99})

ALL_NOTEBOOKS=$(find notebooks -name "*.ipynb" | grep -v "_nbtest" | grep -v ".ipynb_checkpoints" | sort)
for notebook in $ALL_NOTEBOOKS; do
if [[ ! "${EXEMPT_NOTEBOOKS[@]}" =~ $notebook ]]; then
skip=
# check the master exception list
if [[ "${EXEMPT_NOTEBOOKS[@]}" =~ $notebook ]]; then
skip=yes
else
# check the versioned exception lists
for exempt_key in ${!EXEMPT_NOTEBOOKS__*}; do
exempt_version=$(parse_version ${exempt_key/EXEMPT_NOTEBOOKS__/})
if [ $exempt_version -ge $ci_version ]; then
exempt_notebooks=$(eval 'echo ${'${exempt_key}'[@]}')
if [[ "${exempt_notebooks[@]}" =~ $notebook ]]; then
skip=yes
fi
fi
done
fi
if [[ "$skip" == "" ]]; then
echo $notebook
fi
done
1 change: 1 addition & 0 deletions notebooks/document-chunking/with-index-pipelines.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"source": [
"from elasticsearch import Elasticsearch\n",
"from getpass import getpass\n",
"import time\n",
"\n",
"# https://www.elastic.co/search-labs/tutorials/install-elasticsearch/elastic-cloud#finding-your-cloud-id\n",
"ELASTIC_CLOUD_ID = getpass(\"Elastic Cloud ID: \")\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/document-chunking/with-langchain-splitters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python3 -m pip install -qU langchain langchain-elasticsearch elasticsearch eland==8.12.1 jq"
"!python3 -m pip install -qU langchain langchain-community langchain-elasticsearch elasticsearch eland==8.12.1 jq"
]
},
{
Expand Down

0 comments on commit 5bdbee6

Please sign in to comment.