Skip to content

Add initial Python client#66

Open
peopleig wants to merge 1 commit intosdslabs:refactorfrom
peopleig:python-client
Open

Add initial Python client#66
peopleig wants to merge 1 commit intosdslabs:refactorfrom
peopleig:python-client

Conversation

@peopleig
Copy link

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an initial Python client for VortexDB, providing a Pythonic wrapper around the VortexDB gRPC API. The client enables users to insert, retrieve, search, and delete vector embeddings with associated payloads through a clean, typed interface.

Changes:

  • Added a complete Python client package with models, connection handling, configuration management, and error handling
  • Included comprehensive test coverage using pytest for all major components
  • Provided usage examples and detailed documentation in README.md

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
client/python/vortexdb/models.py Defines core data models (DenseVector, Payload, Point) with validation and protobuf conversion
client/python/vortexdb/grpc/vector_db_pb2.py Auto-generated protobuf message definitions
client/python/vortexdb/grpc/vector_db_pb2_grpc.py Auto-generated gRPC stub for VectorDB service
client/python/vortexdb/grpc/init.py Empty init file for grpc subpackage
client/python/vortexdb/exceptions.py Custom exception classes for error handling
client/python/vortexdb/connection.py gRPC connection wrapper with error mapping
client/python/vortexdb/config.py Configuration management with environment variable support
client/python/vortexdb/client.py Main VortexDB client class with CRUD operations
client/python/vortexdb/init.py Package exports and public API surface
client/python/tests/test_models.py Unit tests for model classes
client/python/tests/test_connection.py Unit tests for gRPC connection layer
client/python/tests/test_config.py Unit tests for configuration loading
client/python/tests/test_client.py Unit tests for client API methods
client/python/pyproject.toml Package metadata and dependencies
client/python/proto/vector-db.proto Protobuf schema definition
client/python/examples/context_manager_usage.py Example showing context manager usage pattern
client/python/examples/basic_usage.py Example demonstrating basic client operations
client/python/README.md Comprehensive documentation for the Python client
.gitignore Added Python-specific ignore patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

raise TypeError(
"vector must be a DenseVector. "
"Use: DenseVector([1.0, 2.0, 3.0])"
)
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The insert method validates that vector is a DenseVector but does not validate that payload is a Payload instance. For API consistency and better error messages, add a similar isinstance check for the payload parameter.

Suggested change
)
)
if not isinstance(payload, Payload):
raise TypeError(
"payload must be a Payload. "
"Use: Payload({...})"
)

Copilot uses AI. Check for mistakes.
"vector must be a DenseVector. "
"Use: DenseVector([1.0, 2.0, 3.0])"
)

Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search method does not validate that similarity is a Similarity enum instance. For consistency with the vector validation and better error messages, consider adding an isinstance check for the similarity parameter.

Suggested change
if not isinstance(similarity, Similarity):
raise TypeError(
"similarity must be a Similarity enum instance."
)

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +75



Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment has extra blank lines at the end (lines 73-74). Remove the trailing blank lines for cleaner code formatting.

Suggested change

Copilot uses AI. Check for mistakes.
api_key: str | None = None,
timeout: float | None = None,
):
# Config order followed - args -> env vars -> defaults
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation for the comment is inconsistent with standard Python formatting. The comment should be indented at the same level as the code block it precedes, not aligned with the method definition.

Suggested change
# Config order followed - args -> env vars -> defaults
# Config order followed - args -> env vars -> defaults

Copilot uses AI. Check for mistakes.

self._conn = GRPCConnection(self._config)

# The basic operations
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should be part of the class docstring or removed, as it's not formatted as a proper Python comment block. Standard convention is to use a docstring immediately after the class definition or keep comments aligned with code blocks.

Suggested change
# The basic operations
# The basic operations

Copilot uses AI. Check for mistakes.
Comment on lines +90 to +95
def search(
self,
*,
vector: DenseVector,
similarity: Similarity,
limit: int,
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search method does not validate that the limit parameter is positive. A negative or zero limit value could cause unexpected behavior or errors. Consider adding validation to ensure limit is a positive integer before making the gRPC call.

Copilot uses AI. Check for mistakes.
from vortexdb.client import VortexDB
from vortexdb.connection import GRPCConnection
from vortexdb.models import DenseVector, Payload, Similarity, ContentType, Point
from vortexdb.exceptions import InvalidArgumentError
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'InvalidArgumentError' is not used.

Suggested change
from vortexdb.exceptions import InvalidArgumentError

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,75 @@
import os
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'os' is not used.

Suggested change
import os

Copilot uses AI. Check for mistakes.
_sym_db = _symbol_database.Default()


from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'google_dot_protobuf_dot_empty__pb2' is not used.

Copilot uses AI. Check for mistakes.
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'warnings' is not used.

Suggested change
import warnings

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant