Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use standalone nbtest #171

Merged
merged 2 commits into from
Jan 24, 2024
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
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,30 @@ python -m venv .venv
* Test your notebook end to end before submitting a pull request.
* Example of a well-formed notebook: [question-answering.ipynb](../notebooks/generative-ai/question-answering.ipynb).

### Automated testing

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.

The following command shows how to run a notebook with our tester:

```bash
bin/nbtest notebook/search/00-quick-start.ipynb
```

The `bin/nbtest` script is a wrapper that install `nbtest`. Alternatively, you can install it directly on your own virtual environment with this command:

```bash
pip install elastic-nbtest
```

To run all supported notebooks under this tool, run the following from the top-level directory of this repository:

```bash
make test
```

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`.

## Contributing to example applications 💻

### Why
Expand Down
23 changes: 12 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
.PHONY: pre-commit test nbtest notebooks

pre-commit:
python -m venv .venv
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/pre-commit install

all: test
.PHONY: install pre-commit nbtest test notebooks

test: nbtest notebooks

nbtest:
$(MAKE) -C test/nbtest

notebooks: search document-chunking

search:
$(MAKE) -C notebooks/search

document-chunking:
$(MAKE) -C notebooks/document-chunking

install: pre-commit nbtest

pre-commit:
python -m venv .venv
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/pre-commit install

nbtest:
python3 -m venv .venv
.venv/bin/pip install elastic-nbtest
2 changes: 2 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nbtest
Copyright 2023-2024 Elasticsearch B.V.
9 changes: 4 additions & 5 deletions bin/nbtest
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
NBTEST_DIR=$SCRIPT_DIR/../test/nbtest

if [[ ! -f $NBTEST_DIR/.venv/bin/nbtest ]]; then
make -C $NBTEST_DIR
if [[ ! -f $SCRIPT_DIR/../.venv/bin/nbtest ]]; then
make nbtest
fi
source $NBTEST_DIR/.venv/bin/activate
nbtest $*
source $SCRIPT_DIR/../.venv/bin/activate
$SCRIPT_DIR/../.venv/bin/nbtest $*
4 changes: 0 additions & 4 deletions test/README.md

This file was deleted.

201 changes: 0 additions & 201 deletions test/nbtest/LICENSE

This file was deleted.

2 changes: 0 additions & 2 deletions test/nbtest/MANIFEST.in

This file was deleted.

7 changes: 0 additions & 7 deletions test/nbtest/Makefile

This file was deleted.

Loading