Skip to content

Commit

Permalink
Addressed PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-aerospike committed Oct 21, 2024
1 parent 76ee876 commit 11c8d35
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
4 changes: 3 additions & 1 deletion src/aerospike_vector_search/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions src/aerospike_vector_search/aio/admin.py
Original file line number Diff line number Diff line change
@@ -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__)


Expand Down Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions src/aerospike_vector_search/shared/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .. import types
from .proto_generated import types_pb2
from ..types import IndexStatusResponse


def toVectorDbValue(value: Any) -> types_pb2.Value:
Expand Down Expand Up @@ -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
21 changes: 0 additions & 21 deletions src/aerospike_vector_search/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 11c8d35

Please sign in to comment.