Skip to content
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
2 changes: 1 addition & 1 deletion arangoasync/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ async def add_index(

Args:
type (str): Type attribute (ex. "persistent", "inverted", "ttl", "mdi",
"geo").
"geo", "vector").
fields (dict | list): Fields to index.
options (dict | None): Additional index options.

Expand Down
18 changes: 18 additions & 0 deletions arangoasync/typings.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,10 @@ def key_options(self) -> KeyOptions:
def computed_values(self) -> Optional[Json]:
return self._data.get("computedValues")

@property
def supportsRBAC(self) -> Optional[bool]:
return self._data.get("supportsRBAC")

@property
def object_id(self) -> str:
return self._data["objectId"] # type: ignore[no-any-return]
Expand Down Expand Up @@ -808,6 +812,8 @@ def compatibility_formatter(data: Json) -> Json:
result["computedValues"] = data["computedValues"]
if "internalValidatorType" in data:
result["internal_validator_type"] = data["internalValidatorType"]
if "supportsRBAC" in data:
result["supportsRBAC"] = data["supportsRBAC"]
return result

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

@property
def error_message(self) -> Optional[str]:
return self._data.get("errorMessage")

@property
def training_state(self) -> Optional[str]:
return self._data.get("trainingState")

@staticmethod
def compatibility_formatter(data: Json) -> Json:
"""python-arango compatibility formatter."""
Expand Down Expand Up @@ -1179,6 +1193,10 @@ def compatibility_formatter(data: Json) -> Json:
result["writebuffer_max_size"] = data["writebufferSizeMax"]
if "optimizeTopK" in data:
result["optimizeTopK"] = data["optimizeTopK"]
if "errorMessage" in data:
result["error_message"] = data["errorMessage"]
if "trainingState" in data:
result["training_state"] = data["trainingState"]
return result

def format(self, formatter: Optional[Formatter] = None) -> Json:
Expand Down
2 changes: 1 addition & 1 deletion arangoasync/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
5 changes: 5 additions & 0 deletions tests/static/cluster-3.12.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ jwt-secret = /tests/static/keyfile

[args]
all.database.password = passwd
all.vector-index = true
all.database.extended-names = true
all.log.api-enabled = true
all.javascript.allow-admin-execute = true
all.server.options-api = admin
all.javascript.files-allowlist = ".*";
all.javascript.environment-variables-allowlist = ".*";
all.javascript.endpoints-allowlist = ".*";
all.javascript.startup-options-allowlist = ".*";
6 changes: 6 additions & 0 deletions tests/static/single-3.12.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ jwt-secret = /tests/static/keyfile

[args]
all.database.password = passwd
all.vector-index = true
all.database.extended-names = true
all.log.api-enabled = true
all.javascript.allow-admin-execute = true
all.server.options-api = admin
all.javascript.files-allowlist = ".*";
all.javascript.environment-variables-allowlist = ".*";
all.javascript.endpoints-allowlist = ".*";
all.javascript.startup-options-allowlist = ".*";
14 changes: 10 additions & 4 deletions tests/test_aql.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import time
import warnings

import pytest
from packaging import version
Expand Down Expand Up @@ -138,10 +139,15 @@ async def test_kill_query(db, bad_db, superuser):
queries = await aql.queries()
if len(queries) > 0:
break

# Kill the query
query_id = queries[0]["id"]
assert await aql.kill(query_id) is True
time.sleep(1)

if len(queries) > 0:
# Kill the query
query_id = queries[0]["id"]
assert await aql.kill(query_id) is True
else:
# This test is prone to races
warnings.warn("Query not found in the list, skipping!")

# Ignore missing
assert await aql.kill("fakeid", ignore_missing=True) is False
Expand Down
23 changes: 22 additions & 1 deletion tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,36 @@ async def test_collection_index(doc_col, bad_col, cluster):
await bad_col.load_indexes()
assert err.value.error_code == DATA_SOURCE_NOT_FOUND

# Create a vector index
docs = []
for key in range(100):
docs.append({"_key": f"key_{key}", "embedding": [1] * 128})
await doc_col.insert_many(docs)
idx4 = await doc_col.add_index(
"vector",
["embedding"],
{
"name": "vector_index",
"params": {
"metric": "cosine",
"dimension": 128,
"nLists": 2,
},
},
)
assert idx4.name == "vector_index"

# Delete indexes
del1, del2, del3 = await asyncio.gather(
del1, del2, del3, del4 = await asyncio.gather(
doc_col.delete_index(idx1.id),
doc_col.delete_index(idx2.numeric_id),
doc_col.delete_index(str(idx3.numeric_id)),
doc_col.delete_index(idx4.id),
)
assert del1 is True
assert del2 is True
assert del3 is True
assert del4 is True

# Now, the indexes should be gone
with pytest.raises(IndexDeleteError) as err:
Expand Down
Loading