Skip to content

Commit b8e9371

Browse files
DARREN OBERSTDARREN OBERST
authored andcommitted
updating tests for configs library and readme
1 parent b125630 commit b8e9371

File tree

4 files changed

+49
-15
lines changed

4 files changed

+49
-15
lines changed

‎tests/README.md‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22

33
## Prereqs
44

5-
The tests rely on pytest, tabulate and sentence-transformers
5+
The tests rely on pytest and tabulate
66

77
```bash
8-
pip install pytest tabulate sentence-transformers
8+
pip install pytest tabulate
99
```
1010

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

13-
```bash
14-
docker compose up -d
15-
```
16-
17-
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:
13+
Some tests may require API Keys to particular cloud model providers. If you would like to test that provider, then
14+
you can either edit the test code to include your own, or update ```~/set-env.sh``` and run the following to get
15+
the environment variables loaded in your shell:
1816

1917
```bash
2018
source ~/set-env.sh
@@ -26,17 +24,28 @@ source ~/set-env.sh
2624
python3 ./run-tests.py
2725
```
2826

29-
WARNING: This will "clean" the environment before running *_all tests_*:
27+
Note: We do not currently recommend running all tests concurrently - we are updating our automation and test scope
28+
to improve this capability going forward.
29+
30+
WARNING: Initiating this script will "clean" the environment before running *_all tests_*:
3031
- Uninstall any llmware modules locally installed
3132
- Install the llmware module from this repo (simulating a user installing from pypi)
3233
- Completely remove $HOME/llmware_data
33-
- Reset Mongo and Milvus (drop all collections)
34+
- Reset Mongo and Milvus (drop all collections) -> not currently updated to drop Postgres and SQLITE DBs or other Vector DBs
3435
- Run ./models/test_all_generative_models.py which will pull down many GBs of model files to the test systems.
3536

3637

37-
3838
### Only running tests from a specific folder or file
3939

40+
This is our recommended testing approach, unless a PR has significant cross-module changes, and even in such cases
41+
it is usually more effective to run 2-3 individual tests and supplement with manual testing.
42+
43+
Note: please note that we are in the process of updating our test automation coverage suite. We would welcome
44+
contributions from the community to continue to improve the automation and coverage scope of these tests.
45+
46+
In addition to the formal tests, we would recommend using recent examples as well as good proxies, especially in
47+
targeted areas of the code base.
48+
4049
```bash
4150
python3 ./run-tests.py library
4251
```

‎tests/configs/test_account_overrides.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
""" Tests for custom account configuration over-rides to set up additional accounts, besides the default 'llmware'.
12
3+
By default, the test will run on MongoDB - to change the database (including no-install) - add:
4+
5+
`LLMWareConfig().set_active_db("sqlite")
6+
7+
"""
28

39
import os
410

@@ -7,10 +13,11 @@
713
from llmware.retrieval import Query
814
from llmware.setup import Setup
915

16+
1017
def test_setup_custom_account():
1118

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

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

34-

‎tests/configs/test_path_overrides.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

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

310
import os
411

@@ -7,6 +14,7 @@
714
from llmware.retrieval import Query
815
from llmware.setup import Setup
916

17+
1018
def test_standard_account_setup():
1119

1220
library_name = "test_standard_account_setup"
@@ -53,4 +61,4 @@ def test_setup_custom_location():
5361
results = Query(library).text_query("salary")
5462

5563
assert len(results) > 0
56-
64+

‎tests/library/test_library.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
2+
""" Tests core library functions. By default, runs on MongoDB - to change:
3+
4+
`LLMWareConfig().set_active_db("sqlite")
5+
6+
"""
7+
8+
19
import os
210
import tempfile
311
from llmware.configs import LLMWareConfig
412
from llmware.library import Library, LibraryCatalog
513
from llmware.setup import Setup
614

15+
716
def test_core_library_functions():
817

918
# Library creations
@@ -43,3 +52,5 @@ def test_core_library_functions():
4352

4453
# Ensure library name does not exist
4554
assert library_name not in all_library_names
55+
56+

0 commit comments

Comments
 (0)