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
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Event Observer API, to listen to events:
- see `astrapy.event_observers` module and docstring of classes therein for more.
SSL bugfix due to older patches of Python 3.12:
Introduced a fix to the httpx.ReadError `[SSL] passed invalid argument (_ssl.c:2570)` observed on Python 3.12.0-3.12.11
Removed the unused 'keyspace' parameter from `[async_]fetch_database_info` admin utility function
Removed the beta marker from find_and_rerank methods
Removed the legacy no-indexType fallback for parsing the response of list_indexes
maintenance: measure test coverage for PRs and merges to main; calculate delta for PRs
maintenance: bump urllib3 to >= 2.6.3 to avoid CVE-2026-21441
maintenance: add flag `TEST_EXTENDED_VECTORIZE` for test runnability in all cases
Expand Down
6 changes: 0 additions & 6 deletions astrapy/admin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ async def async_fetch_raw_database_info_from_id_token(
def fetch_database_info(
api_endpoint: str,
token: str | TokenProvider | UnsetType = _UNSET,
keyspace: str | None = None,
request_timeout_ms: int | None = None,
timeout_ms: int | None = None,
api_options: APIOptions | None = None,
Expand All @@ -341,8 +340,6 @@ def fetch_database_info(
api_endpoint: a full API endpoint for the Data API.
token: a valid token to access the database information.
If provided, overrides any token info found in api_options.
keyspace: the desired keyspace that will be used in the result.
If not specified, the resulting database info will show it as None.
request_timeout_ms: a timeout, in milliseconds, for waiting on a response.
timeout_ms: an alias for `request_timeout_ms`.
api_options: a (possibly partial) specification of the API Options to use.
Expand Down Expand Up @@ -376,7 +373,6 @@ def fetch_database_info(
async def async_fetch_database_info(
api_endpoint: str,
token: str | TokenProvider | UnsetType = _UNSET,
keyspace: str | None = None,
request_timeout_ms: int | None = None,
timeout_ms: int | None = None,
api_options: APIOptions | None = None,
Expand All @@ -389,8 +385,6 @@ async def async_fetch_database_info(
api_endpoint: a full API endpoint for the Data API.
token: a valid token to access the database information.
If provided, overrides any token info found in api_options.
keyspace: the desired keyspace that will be used in the result.
If not specified, the resulting database info will show it as None.
request_timeout_ms: a timeout, in milliseconds, for waiting on a response.
timeout_ms: an alias for `request_timeout_ms`.
api_options: a (possibly partial) specification of the API Options to use.
Expand Down
3 changes: 0 additions & 3 deletions astrapy/data/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
)
from astrapy.utils.api_commander import APICommander
from astrapy.utils.api_options import APIOptions, FullAPIOptions
from astrapy.utils.meta import beta_method
from astrapy.utils.request_tools import HttpMethod
from astrapy.utils.unset import _UNSET, UnsetType

Expand Down Expand Up @@ -1545,7 +1544,6 @@ def find_and_rerank(
timeout_ms: int | None = None,
) -> CollectionFindAndRerankCursor[DOC, RerankedResult[DOC2]]: ...

@beta_method
def find_and_rerank(
self,
filter: FilterType | None = None,
Expand Down Expand Up @@ -4581,7 +4579,6 @@ def find_and_rerank(
timeout_ms: int | None = None,
) -> AsyncCollectionFindAndRerankCursor[DOC, RerankedResult[DOC2]]: ...

@beta_method
def find_and_rerank(
self,
filter: FilterType | None = None,
Expand Down
2 changes: 0 additions & 2 deletions astrapy/data/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ def info(
logger.info("getting database info")
database_info = fetch_database_info(
self.api_endpoint,
keyspace=self.keyspace,
request_timeout_ms=_database_admin_timeout_ms,
api_options=self.api_options,
)
Expand Down Expand Up @@ -2653,7 +2652,6 @@ async def info(
logger.info("getting database info")
database_info = await async_fetch_database_info(
self.api_endpoint,
keyspace=self.keyspace,
request_timeout_ms=_database_admin_timeout_ms,
api_options=self.api_options,
)
Expand Down
40 changes: 14 additions & 26 deletions astrapy/data/info/table_descriptor/table_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,33 +729,21 @@ def _from_dict(cls, raw_dict: dict[str, Any]) -> TableIndexDescriptor:
_warn_residual_keys(cls, raw_dict, {"name", "definition", "indexType"})

index_definition: TableBaseIndexDefinition
# index type determination:
if "indexType" in raw_dict:
idx_type = raw_dict["indexType"]
idx_def = raw_dict["definition"]
if idx_type == TableIndexType.REGULAR.value:
index_definition = TableIndexDefinition._from_dict(idx_def)
elif idx_type == TableIndexType.VECTOR.value:
index_definition = TableVectorIndexDefinition._from_dict(idx_def)
elif idx_type == TableIndexType.TEXT.value:
index_definition = TableTextIndexDefinition._from_dict(idx_def)
elif idx_type == TableIndexType.UNKNOWN.value:
index_definition = TableUnsupportedIndexDefinition._from_dict(idx_def)
else:
# not throwing here. Log a warning and try the inspection path
logger.warning(
f"Found an unexpected indexType when parsing a {cls.__name__} "
f"dictionary: {idx_type}. Falling back to inspecting the "
f"index definition."
)
index_definition = TableBaseIndexDefinition._from_dict(
raw_dict["definition"]
)
idx_type = raw_dict.get("indexType")
idx_def = raw_dict["definition"]
if idx_type == TableIndexType.REGULAR.value:
index_definition = TableIndexDefinition._from_dict(idx_def)
elif idx_type == TableIndexType.VECTOR.value:
index_definition = TableVectorIndexDefinition._from_dict(idx_def)
elif idx_type == TableIndexType.TEXT.value:
index_definition = TableTextIndexDefinition._from_dict(idx_def)
elif idx_type == TableIndexType.UNKNOWN.value:
index_definition = TableUnsupportedIndexDefinition._from_dict(idx_def)
else:
# fall back to the 'inspection' path
logger.info(
f"Field 'indexType' missing when parsing a {cls.__name__} "
f"dictionary. Falling back to inspecting the "
# not throwing here. Log a warning and try the inspection path
logger.warning(
f"Found an unexpected indexType when parsing a {cls.__name__} "
f"dictionary: {idx_type}. Falling back to inspecting the "
f"index definition."
)
index_definition = TableBaseIndexDefinition._from_dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ async def test_database_info_timeout_async(
info = await async_fetch_database_info(
async_database.api_endpoint,
token=async_database.api_options.token,
keyspace=async_database.keyspace,
)
assert info is not None

with pytest.raises(DevOpsAPITimeoutException) as exc:
info = await async_fetch_database_info(
async_database.api_endpoint,
token=async_database.api_options.token,
keyspace=async_database.keyspace,
request_timeout_ms=10,
)
assert info is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,13 @@ def test_database_info_timeout_sync(
info = fetch_database_info(
sync_database.api_endpoint,
token=sync_database.api_options.token,
keyspace=sync_database.keyspace,
)
assert info is not None

with pytest.raises(DevOpsAPITimeoutException) as exc:
info = fetch_database_info(
sync_database.api_endpoint,
token=sync_database.api_options.token,
keyspace=sync_database.keyspace,
request_timeout_ms=50,
)
assert info is not None
Expand Down
18 changes: 8 additions & 10 deletions tests/base/unit/test_tableindexdescriptor_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,19 @@ def test_parsing_regular_index_description(
it_resp: dict[str, Any],
faulty_it_resp: dict[str, Any],
) -> None:
descriptors = [
TableIndexDescriptor.coerce(response["status"]["indexes"][0])
for response in [
PROD_U_RESPONSE,
LOCAL_U_RESPONSE,
]
]
descriptors = [TableIndexDescriptor.coerce(it_resp["status"]["indexes"][0])]
with caplog.at_level(logging.WARNING):
descriptors.append(
TableIndexDescriptor.coerce(LOCAL_U_RESPONSE_W["status"]["indexes"][0])
TableIndexDescriptor.coerce(no_it_resp["status"]["indexes"][0])
)
descriptors.append(
TableIndexDescriptor.coerce(faulty_it_resp["status"]["indexes"][0])
)

warnings = [rec for rec in caplog.records if rec.levelname == "WARNING"]
assert len(warnings) == 1
assert "WRONG_INDEX_TYPE" in warnings[0].message
assert len(warnings) == 2
assert "None" in warnings[0].message
assert "WRONG_INDEX_TYPE" in warnings[1].message
assert descriptors[0] == descriptors[1]
assert descriptors[0] == descriptors[2]

Expand Down