diff --git a/src/aerospike_vector_search/admin.py b/src/aerospike_vector_search/admin.py index 9bb36751..4ea69553 100644 --- a/src/aerospike_vector_search/admin.py +++ b/src/aerospike_vector_search/admin.py @@ -8,6 +8,7 @@ from . import types from .internal import channel_provider from .shared.admin_helpers import BaseClient +from .shared.conversions import fromIndexStatusResponse logger = logging.getLogger(__name__) @@ -337,7 +338,8 @@ def index_get_status( logger.error("Failed to get index status with error: %s", e) raise types.AVSServerError(rpc_error=e) - return types.IndexStatusResponse.from_proto_response(response) + + return fromIndexStatusResponse(response) def add_user( self, diff --git a/src/aerospike_vector_search/aio/admin.py b/src/aerospike_vector_search/aio/admin.py index 26b476ee..3ba07d3e 100644 --- a/src/aerospike_vector_search/aio/admin.py +++ b/src/aerospike_vector_search/aio/admin.py @@ -1,14 +1,18 @@ import asyncio import logging import sys -from typing import Any, Optional, Union +from http.client import responses +from typing import Optional, Union + import grpc -from .. import types from .internal import channel_provider +from .. import types +from ..shared.conversions import fromIndexStatusResponse from ..shared.admin_helpers import BaseClient from ..types import IndexStatusResponse + logger = logging.getLogger(__name__) @@ -351,6 +355,7 @@ async def index_get_status( raise types.AVSServerError(rpc_error=e) return IndexStatusResponse.from_proto_response(response) + return fromIndexStatusResponse(responses) async def add_user( self, diff --git a/src/aerospike_vector_search/shared/conversions.py b/src/aerospike_vector_search/shared/conversions.py index 8d4d3299..0bfc0a3e 100644 --- a/src/aerospike_vector_search/shared/conversions.py +++ b/src/aerospike_vector_search/shared/conversions.py @@ -2,6 +2,7 @@ from .. import types from .proto_generated import types_pb2 +from ..types import IndexStatusResponse def toVectorDbValue(value: Any) -> types_pb2.Value: @@ -158,3 +159,23 @@ def fromVectorDbValue(input: types_pb2.Value) -> Any: return [v for v in vector.boolData.value] return None + +def fromIndexStatusResponse(response: 'index_pb2.IndexStatusResponse') -> 'IndexStatusResponse': + """ + Converts a protobuf IndexStatusResponse into an IndexStatusResponse object. + + Parameters: + ----------- + response : index_pb2.IndexStatusResponse + A protobuf IndexStatusResponse object. + + Returns: + -------- + IndexStatusResponse + An instance of IndexStatusResponse with the values from the protobuf message. + """ + result = IndexStatusResponse() + result.unmerged_record_count = response.unmergedRecordCount + result.index_healer_vector_records_indexed = response.indexHealerVectorRecordsIndexed + result.index_healer_vertices_valid = response.indexHealerVerticesValid + return result diff --git a/src/aerospike_vector_search/types.py b/src/aerospike_vector_search/types.py index 702f3ac8..efa768f2 100644 --- a/src/aerospike_vector_search/types.py +++ b/src/aerospike_vector_search/types.py @@ -920,24 +920,3 @@ def __repr__(self) -> str: return (f"IndexStatusResponse(unmerged_record_count={self.unmerged_record_count}, " f"index_healer_vector_records_indexed={self.index_healer_vector_records_indexed}, " f"index_healer_vertices_valid={self.index_healer_vertices_valid})") - - @staticmethod - def from_proto_response(response: 'index_pb2.IndexStatusResponse') -> 'IndexStatusResponse': - """ - Converts a protobuf IndexStatusResponse into an IndexStatusResponse object. - - Parameters: - ----------- - response : index_pb2.IndexStatusResponse - A protobuf IndexStatusResponse object. - - Returns: - -------- - IndexStatusResponse - An instance of IndexStatusResponse with the values from the protobuf message. - """ - result = IndexStatusResponse() - result.unmerged_record_count = response.unmergedRecordCount - result.index_healer_vector_records_indexed = response.indexHealerVectorRecordsIndexed - result.index_healer_vertices_valid = response.indexHealerVerticesValid - return result