Skip to content

Commit a3e12aa

Browse files
author
Nikos Papailiou
committed
Merge branch 'main' into npapa/timetravel
2 parents 53aa88a + 39f94c3 commit a3e12aa

File tree

13 files changed

+148
-10
lines changed

13 files changed

+148
-10
lines changed

.github/workflows/ci_python.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ jobs:
3535
#pip uninstall -y tiledb.vector_search
3636
#pip install -e .
3737
#pytest
38+
pip install -r test/ipynb/requirements.txt
39+
pytest --nbmake test/ipynb
40+
env:
41+
TILEDB_REST_TOKEN: ${{ secrets.TILEDB_CLOUD_HELPER_VAR }}
3842
shell: bash -el {0}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,15 @@ development-build instructions. For large new
4242
features, please open an issue to discuss goals and approach in order
4343
to ensure a smooth PR integration and review process. All contributions
4444
must be licensed under the repository's [MIT License](../LICENSE).
45+
46+
# Testing
47+
48+
* Unit tests: `pytest`
49+
* Demo notebooks:
50+
* ```
51+
pip install -r test/ipynb/requirements.txt
52+
pytest --nbmake test/ipynb
53+
```
54+
* Credentials:
55+
* Some tests run on TileDB Cloud using your current environment variable `TILEDB_REST_TOKEN` -- you will need a valid API token for the tests to pass
56+
* For continuous integration, the token is configured for the `unittest` user and all tests should pass

apis/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
]
2727

2828
[project.optional-dependencies]
29-
test = ["pytest"]
29+
test = ["nbmake", "pytest"]
3030

3131

3232
[project.urls]

apis/python/src/tiledb/vector_search/flat_index.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ def __init__(
3838
config=config,
3939
timestamp=self.base_array_timestamp,
4040
)
41-
self.ids_uri = self.group[
42-
storage_formats[self.storage_version]["IDS_ARRAY_NAME"] + self.index_version
43-
].uri
44-
if tiledb.array_exists(self.ids_uri, self.ctx):
41+
# Check for existence of ids array. Previous versions were not using external_ids in the ingestion assuming
42+
# that the external_ids were the position of the vector in the array.
43+
if storage_formats[self.storage_version]["IDS_ARRAY_NAME"] + self.index_version in self.group:
44+
self.ids_uri = self.group[
45+
storage_formats[self.storage_version]["IDS_ARRAY_NAME"] + self.index_version
46+
].uri
4547
self._ids = read_vector_u64(self.ctx, self.ids_uri, 0, 0, self.base_array_timestamp)
4648
else:
4749
self._ids = StdVector_u64(np.arange(self.size).astype(np.uint64))

apis/python/src/tiledb/vector_search/index.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,15 @@ def consolidate_updates(self):
279279
config=self.config,
280280
)
281281
return new_index
282+
283+
@staticmethod
284+
def delete_index(uri, config):
285+
try:
286+
group = tiledb.Group(uri, "m", config=config)
287+
except tiledb.TileDBError as err:
288+
message = str(err)
289+
if "group does not exist" in message:
290+
return
291+
else:
292+
raise err
293+
group.delete()

apis/python/src/tiledb/vector_search/ingestion.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,11 +1751,12 @@ def consolidate_and_vacuum(
17511751
conf = tiledb.Config(config)
17521752
conf["sm.consolidation.mode"] = mode
17531753
conf["sm.vacuum.mode"] = mode
1754-
tiledb.consolidate(group[PARTS_ARRAY_NAME].uri, config=conf)
1755-
tiledb.vacuum(group[PARTS_ARRAY_NAME].uri, config=conf)
1756-
if index_type == "IVF_FLAT":
1757-
tiledb.consolidate(group[IDS_ARRAY_NAME].uri, config=conf)
1758-
tiledb.vacuum(group[IDS_ARRAY_NAME].uri, config=conf)
1754+
ids_uri = group[IDS_ARRAY_NAME].uri
1755+
parts_uri = group[PARTS_ARRAY_NAME].uri
1756+
tiledb.consolidate(parts_uri, config=conf)
1757+
tiledb.vacuum(parts_uri, config=conf)
1758+
tiledb.consolidate(ids_uri, config=conf)
1759+
tiledb.vacuum(ids_uri, config=conf)
17591760

17601761
# TODO remove temp data for tiledb URIs
17611762
if not index_group_uri.startswith("tiledb://"):

apis/python/test/common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import numpy as np
44

5+
import random
6+
import string
57
import tiledb
68

79

@@ -192,3 +194,8 @@ def accuracy(result, gt, external_ids_offset=0, updated_ids=None, only_updated_i
192194
total += len(temp_result)
193195
found += len(np.intersect1d(temp_result, gt[i]))
194196
return found / total
197+
198+
# Generate random names for test array uris
199+
def random_name(name: str) -> str:
200+
suffix = "".join(random.choices(string.ascii_letters, k=10))
201+
return f"zzz_unittest_{name}_{suffix}"

apis/python/test/ipynb/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Cloud Notebook tests
2+
3+
Run all tests:
4+
```
5+
pip install -r test/ipynb/requirements.txt
6+
pytest --nbmake test/ipynb
7+
```
8+
9+
This is using [nbmake](https://github.com/treebeardtech/nbmake) to test notebooks.
10+
Credentials:
11+
* Local tests: use `TILEDB_REST_TOKEN` -- you will need a valid API token for the tests to pass
12+
* For continuous integration, the token is configured for the `unittest` user and all tests should pass
13+
14+
When changes get merged in these files make sure that you also propagate the changes to the Cloud registered notebooks:
15+
* [tiledb_101_vector_search.ipynb](https://cloud.tiledb.com/notebooks/details/TileDB-Inc/b05dd4b4-ba1c-41c6-a3c9-a1de70abb039/preview)
16+
* [staging-vector-search-checks-py.ipynb](https://console.dev.tiledb.io/notebooks/details/TileDB-Inc/299dd052-6b45-4943-88ae-37639b7b4b48/preview)
17+
* [image-search-dashboard](https://cloud.tiledb.com/notebooks/details/TileDB-Inc/9289229a-1742-4f99-9b86-0bb1339b31a0/preview)

apis/python/test/ipynb/image-search-dashboard.ipynb

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
efficientnet
2+
ipywidgets
3+
panel
4+
tensorflow

0 commit comments

Comments
 (0)