From fd265573dbf110905f5f18b86852f8aff3cc57d2 Mon Sep 17 00:00:00 2001 From: Stefano Lottini <236640031+sl-at-ibm@users.noreply.github.com> Date: Tue, 10 Feb 2026 22:59:36 +0100 Subject: [PATCH 1/2] remove beta marker for find_and_rerank; remove fallback for legacy missing-indexType responses --- CHANGES | 2 + astrapy/data/collection.py | 3 -- .../info/table_descriptor/table_indexes.py | 40 +++++++------------ .../unit/test_tableindexdescriptor_parsing.py | 18 ++++----- 4 files changed, 24 insertions(+), 39 deletions(-) diff --git a/CHANGES b/CHANGES index e9972bf3..495bc837 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,8 @@ 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 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 diff --git a/astrapy/data/collection.py b/astrapy/data/collection.py index a950c174..b2ca5056 100644 --- a/astrapy/data/collection.py +++ b/astrapy/data/collection.py @@ -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 @@ -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, @@ -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, diff --git a/astrapy/data/info/table_descriptor/table_indexes.py b/astrapy/data/info/table_descriptor/table_indexes.py index 1bf3fc7b..fc55c6bd 100644 --- a/astrapy/data/info/table_descriptor/table_indexes.py +++ b/astrapy/data/info/table_descriptor/table_indexes.py @@ -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( diff --git a/tests/base/unit/test_tableindexdescriptor_parsing.py b/tests/base/unit/test_tableindexdescriptor_parsing.py index 9f46678b..e27f456a 100644 --- a/tests/base/unit/test_tableindexdescriptor_parsing.py +++ b/tests/base/unit/test_tableindexdescriptor_parsing.py @@ -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] From 61dc063278430a7ef8b5634e400a17bf9c4852f4 Mon Sep 17 00:00:00 2001 From: Stefano Lottini <236640031+sl-at-ibm@users.noreply.github.com> Date: Tue, 10 Feb 2026 23:05:40 +0100 Subject: [PATCH 2/2] remove unused keyspace param from asinc_/fetch_database_info admin utility --- CHANGES | 1 + astrapy/admin/admin.py | 6 ------ astrapy/data/database.py | 2 -- .../collections/test_collection_timeout_async.py | 2 -- .../integration/collections/test_collection_timeout_sync.py | 2 -- 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 495bc837..2248c13d 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,7 @@ 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 diff --git a/astrapy/admin/admin.py b/astrapy/admin/admin.py index 5f9f3571..bda5104f 100644 --- a/astrapy/admin/admin.py +++ b/astrapy/admin/admin.py @@ -330,7 +330,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, @@ -342,8 +341,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. @@ -377,7 +374,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, @@ -390,8 +386,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. diff --git a/astrapy/data/database.py b/astrapy/data/database.py index b45b17ab..c0295017 100644 --- a/astrapy/data/database.py +++ b/astrapy/data/database.py @@ -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, ) @@ -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, ) diff --git a/tests/base/integration/collections/test_collection_timeout_async.py b/tests/base/integration/collections/test_collection_timeout_async.py index 57d06eeb..6c67e74a 100644 --- a/tests/base/integration/collections/test_collection_timeout_async.py +++ b/tests/base/integration/collections/test_collection_timeout_async.py @@ -56,7 +56,6 @@ 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 @@ -64,7 +63,6 @@ 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, request_timeout_ms=10, ) assert info is not None diff --git a/tests/base/integration/collections/test_collection_timeout_sync.py b/tests/base/integration/collections/test_collection_timeout_sync.py index ed95d1a9..d137dbcd 100644 --- a/tests/base/integration/collections/test_collection_timeout_sync.py +++ b/tests/base/integration/collections/test_collection_timeout_sync.py @@ -52,7 +52,6 @@ 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 @@ -60,7 +59,6 @@ def test_database_info_timeout_sync( info = fetch_database_info( sync_database.api_endpoint, token=sync_database.api_options.token, - keyspace=sync_database.keyspace, request_timeout_ms=10, ) assert info is not None