Skip to content

Commit bda20cd

Browse files
Use standalone nbtest (#171)
* Use standalone nbtest * Add a NOTICE file, as requested by legal
1 parent ebd2e96 commit bda20cd

14 files changed

+42
-628
lines changed

Diff for: CONTRIBUTING.md

+24
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ python -m venv .venv
5656
* Test your notebook end to end before submitting a pull request.
5757
* Example of a well-formed notebook: [question-answering.ipynb](../notebooks/generative-ai/question-answering.ipynb).
5858

59+
### Automated testing
60+
61+
Some notebooks in this repository are automatically tested with our [nbtest](https://github.com/elastic/nbtest) tool and we welcome any new notebooks to also be included.
62+
63+
The following command shows how to run a notebook with our tester:
64+
65+
```bash
66+
bin/nbtest notebook/search/00-quick-start.ipynb
67+
```
68+
69+
The `bin/nbtest` script is a wrapper that install `nbtest`. Alternatively, you can install it directly on your own virtual environment with this command:
70+
71+
```bash
72+
pip install elastic-nbtest
73+
```
74+
75+
To run all supported notebooks under this tool, run the following from the top-level directory of this repository:
76+
77+
```bash
78+
make test
79+
```
80+
81+
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`.
82+
5983
## Contributing to example applications 💻
6084

6185
### Why

Diff for: Makefile

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
.PHONY: pre-commit test nbtest notebooks
2-
3-
pre-commit:
4-
python -m venv .venv
5-
.venv/bin/pip install -r requirements-dev.txt
6-
.venv/bin/pre-commit install
7-
8-
all: test
1+
.PHONY: install pre-commit nbtest test notebooks
92

103
test: nbtest notebooks
114

12-
nbtest:
13-
$(MAKE) -C test/nbtest
14-
155
notebooks: search document-chunking
166

177
search:
188
$(MAKE) -C notebooks/search
199

2010
document-chunking:
2111
$(MAKE) -C notebooks/document-chunking
12+
13+
install: pre-commit nbtest
14+
15+
pre-commit:
16+
python -m venv .venv
17+
.venv/bin/pip install -r requirements-dev.txt
18+
.venv/bin/pre-commit install
19+
20+
nbtest:
21+
python3 -m venv .venv
22+
.venv/bin/pip install elastic-nbtest

Diff for: NOTICE

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nbtest
2+
Copyright 2023-2024 Elasticsearch B.V.

Diff for: bin/nbtest

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/bin/bash
22
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
3-
NBTEST_DIR=$SCRIPT_DIR/../test/nbtest
43

5-
if [[ ! -f $NBTEST_DIR/.venv/bin/nbtest ]]; then
6-
make -C $NBTEST_DIR
4+
if [[ ! -f $SCRIPT_DIR/../.venv/bin/nbtest ]]; then
5+
make nbtest
76
fi
8-
source $NBTEST_DIR/.venv/bin/activate
9-
nbtest $*
7+
source $SCRIPT_DIR/../.venv/bin/activate
8+
$SCRIPT_DIR/../.venv/bin/nbtest $*

Diff for: test/README.md

-4
This file was deleted.

Diff for: test/nbtest/LICENSE

-201
This file was deleted.

Diff for: test/nbtest/MANIFEST.in

-2
This file was deleted.

Diff for: test/nbtest/Makefile

-7
This file was deleted.

0 commit comments

Comments
 (0)