Skip to content

Commit

Permalink
updating tests for configs library and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
DARREN OBERST authored and DARREN OBERST committed May 7, 2024
1 parent b125630 commit b8e9371
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 15 deletions.
31 changes: 20 additions & 11 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

## Prereqs

The tests rely on pytest, tabulate and sentence-transformers
The tests rely on pytest and tabulate

```bash
pip install pytest tabulate sentence-transformers
pip install pytest tabulate
```

Mongo and Milvus are expected to be already running. From the root of this repo:
To run tests specific to a particular database or vector database requires that the resources are up and running.

```bash
docker compose up -d
```

Some tests in the ./models and ./prompts folder require API Keys to cloud model providers. You can edit the test code to include your own, or update ```~/set-env.sh``` and run the following to get the environment variables loaded in your shell:
Some tests may require API Keys to particular cloud model providers. If you would like to test that provider, then
you can either edit the test code to include your own, or update ```~/set-env.sh``` and run the following to get
the environment variables loaded in your shell:

```bash
source ~/set-env.sh
Expand All @@ -26,17 +24,28 @@ source ~/set-env.sh
python3 ./run-tests.py
```

WARNING: This will "clean" the environment before running *_all tests_*:
Note: We do not currently recommend running all tests concurrently - we are updating our automation and test scope
to improve this capability going forward.

WARNING: Initiating this script will "clean" the environment before running *_all tests_*:
- Uninstall any llmware modules locally installed
- Install the llmware module from this repo (simulating a user installing from pypi)
- Completely remove $HOME/llmware_data
- Reset Mongo and Milvus (drop all collections)
- Reset Mongo and Milvus (drop all collections) -> not currently updated to drop Postgres and SQLITE DBs or other Vector DBs
- Run ./models/test_all_generative_models.py which will pull down many GBs of model files to the test systems.



### Only running tests from a specific folder or file

This is our recommended testing approach, unless a PR has significant cross-module changes, and even in such cases
it is usually more effective to run 2-3 individual tests and supplement with manual testing.

Note: please note that we are in the process of updating our test automation coverage suite. We would welcome
contributions from the community to continue to improve the automation and coverage scope of these tests.

In addition to the formal tests, we would recommend using recent examples as well as good proxies, especially in
targeted areas of the code base.

```bash
python3 ./run-tests.py library
```
Expand Down
12 changes: 9 additions & 3 deletions tests/configs/test_account_overrides.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
""" Tests for custom account configuration over-rides to set up additional accounts, besides the default 'llmware'.
By default, the test will run on MongoDB - to change the database (including no-install) - add:
`LLMWareConfig().set_active_db("sqlite")
"""

import os

Expand All @@ -7,10 +13,11 @@
from llmware.retrieval import Query
from llmware.setup import Setup


def test_setup_custom_account():

# creation of custom accounts -> 'implicit' creation allowed in llmware (no permissioning checks)
# assumed that upstream application will manage permissioning and account management
# creation of custom accounts -> 'implicit' creation allowed in llmware (no permission checks)
# assumed that upstream application will manage permission scope and account management

account_name = "custom_account123"
library_name = "custom_lib123"
Expand All @@ -31,4 +38,3 @@ def test_setup_custom_account():
results = Query(library).text_query("salary")
assert len(results) > 0


10 changes: 9 additions & 1 deletion tests/configs/test_path_overrides.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

""" Tests paths both for a standard account setup and custom account setup.
Note: by default, this test will run on MongoDB - to switch DB used - add one-line:
`LLMWareConfig().set_active_db("sqlite")
"""

import os

Expand All @@ -7,6 +14,7 @@
from llmware.retrieval import Query
from llmware.setup import Setup


def test_standard_account_setup():

library_name = "test_standard_account_setup"
Expand Down Expand Up @@ -53,4 +61,4 @@ def test_setup_custom_location():
results = Query(library).text_query("salary")

assert len(results) > 0

11 changes: 11 additions & 0 deletions tests/library/test_library.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@

""" Tests core library functions. By default, runs on MongoDB - to change:
`LLMWareConfig().set_active_db("sqlite")
"""


import os
import tempfile
from llmware.configs import LLMWareConfig
from llmware.library import Library, LibraryCatalog
from llmware.setup import Setup


def test_core_library_functions():

# Library creations
Expand Down Expand Up @@ -43,3 +52,5 @@ def test_core_library_functions():

# Ensure library name does not exist
assert library_name not in all_library_names


0 comments on commit b8e9371

Please sign in to comment.