Skip to content

Commit afe54d7

Browse files
committed
Adding new vector index fields
1 parent bf0f5d3 commit afe54d7

6 files changed

Lines changed: 53 additions & 3 deletions

File tree

arangoasync/collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ async def add_index(
397397
398398
Args:
399399
type (str): Type attribute (ex. "persistent", "inverted", "ttl", "mdi",
400-
"geo").
400+
"geo", "vector").
401401
fields (dict | list): Fields to index.
402402
options (dict | None): Additional index options.
403403

arangoasync/typings.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,10 @@ def key_options(self) -> KeyOptions:
727727
def computed_values(self) -> Optional[Json]:
728728
return self._data.get("computedValues")
729729

730+
@property
731+
def supportsRBAC(self) -> Optional[bool]:
732+
return self._data.get("supportsRBAC")
733+
730734
@property
731735
def object_id(self) -> str:
732736
return self._data["objectId"] # type: ignore[no-any-return]
@@ -808,6 +812,8 @@ def compatibility_formatter(data: Json) -> Json:
808812
result["computedValues"] = data["computedValues"]
809813
if "internalValidatorType" in data:
810814
result["internal_validator_type"] = data["internalValidatorType"]
815+
if "supportsRBAC" in data:
816+
result["supportsRBAC"] = data["supportsRBAC"]
811817
return result
812818

813819
def format(self, formatter: Optional[Formatter] = None) -> Json:
@@ -1121,6 +1127,14 @@ def include_all_fields(self) -> Optional[bool]:
11211127
def features(self) -> Optional[List[str]]:
11221128
return self._data.get("features")
11231129

1130+
@property
1131+
def error_message(self) -> Optional[str]:
1132+
return self._data.get("errorMessage")
1133+
1134+
@property
1135+
def training_state(self) -> Optional[str]:
1136+
return self._data.get("trainingState")
1137+
11241138
@staticmethod
11251139
def compatibility_formatter(data: Json) -> Json:
11261140
"""python-arango compatibility formatter."""
@@ -1179,6 +1193,10 @@ def compatibility_formatter(data: Json) -> Json:
11791193
result["writebuffer_max_size"] = data["writebufferSizeMax"]
11801194
if "optimizeTopK" in data:
11811195
result["optimizeTopK"] = data["optimizeTopK"]
1196+
if "errorMessage" in data:
1197+
result["error_message"] = data["errorMessage"]
1198+
if "trainingState" in data:
1199+
result["training_state"] = data["trainingState"]
11821200
return result
11831201

11841202
def format(self, formatter: Optional[Formatter] = None) -> Json:

arangoasync/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.2.1"
1+
__version__ = "1.2.2"

tests/static/cluster-3.12.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ jwt-secret = /tests/static/keyfile
99

1010
[args]
1111
all.database.password = passwd
12+
all.vector-index = true
1213
all.database.extended-names = true
1314
all.log.api-enabled = true
1415
all.javascript.allow-admin-execute = true
1516
all.server.options-api = admin
17+
all.javascript.files-allowlist = ".*";
18+
all.javascript.environment-variables-allowlist = ".*";
19+
all.javascript.endpoints-allowlist = ".*";
20+
all.javascript.startup-options-allowlist = ".*";

tests/static/single-3.12.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ jwt-secret = /tests/static/keyfile
88

99
[args]
1010
all.database.password = passwd
11+
all.vector-index = true
1112
all.database.extended-names = true
13+
all.log.api-enabled = true
1214
all.javascript.allow-admin-execute = true
1315
all.server.options-api = admin
16+
all.javascript.files-allowlist = ".*";
17+
all.javascript.environment-variables-allowlist = ".*";
18+
all.javascript.endpoints-allowlist = ".*";
19+
all.javascript.startup-options-allowlist = ".*";

tests/test_collection.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,36 @@ async def test_collection_index(doc_col, bad_col, cluster):
228228
await bad_col.load_indexes()
229229
assert err.value.error_code == DATA_SOURCE_NOT_FOUND
230230

231+
# Create a vector index
232+
docs = []
233+
for key in range(100):
234+
docs.append({"_key": f"key_{key}", "embedding": [1] * 128})
235+
await doc_col.insert_many(docs)
236+
idx4 = await doc_col.add_index(
237+
"vector",
238+
["embedding"],
239+
{
240+
"name": "vector_index",
241+
"params": {
242+
"metric": "cosine",
243+
"dimension": 128,
244+
"nLists": 2,
245+
},
246+
},
247+
)
248+
assert idx4.name == "vector_index"
249+
231250
# Delete indexes
232-
del1, del2, del3 = await asyncio.gather(
251+
del1, del2, del3, del4 = await asyncio.gather(
233252
doc_col.delete_index(idx1.id),
234253
doc_col.delete_index(idx2.numeric_id),
235254
doc_col.delete_index(str(idx3.numeric_id)),
255+
doc_col.delete_index(idx4.id),
236256
)
237257
assert del1 is True
238258
assert del2 is True
239259
assert del3 is True
260+
assert del4 is True
240261

241262
# Now, the indexes should be gone
242263
with pytest.raises(IndexDeleteError) as err:

0 commit comments

Comments
 (0)