Skip to content

Commit

Permalink
assert config equality in test
Browse files Browse the repository at this point in the history
  • Loading branch information
atroyn committed Jul 2, 2024
1 parent 68561fc commit a7ae5c4
Show file tree
Hide file tree
Showing 30 changed files with 1,046 additions and 953 deletions.
3 changes: 3 additions & 0 deletions chromadb/db/impl/grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List, Optional, Sequence, Tuple, Union, cast
from uuid import UUID
from overrides import overrides
from chromadb.api.configuration import CollectionConfiguration
from chromadb.config import DEFAULT_DATABASE, DEFAULT_TENANT, System, logger
from chromadb.db.base import NotFoundError, UniqueConstraintError
from chromadb.db.system import SysDB
Expand Down Expand Up @@ -197,6 +198,7 @@ def create_collection(
self,
id: UUID,
name: str,
configuration: CollectionConfiguration,
metadata: Optional[Metadata] = None,
dimension: Optional[int] = None,
get_or_create: bool = False,
Expand All @@ -206,6 +208,7 @@ def create_collection(
request = CreateCollectionRequest(
id=id.hex,
name=name,
configuration_json_str=configuration.to_json_str(),
metadata=to_proto_update_metadata(metadata) if metadata else None,
dimension=dimension,
get_or_create=get_or_create,
Expand Down
6 changes: 6 additions & 0 deletions chromadb/db/impl/grpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, Dict, cast
from uuid import UUID
from overrides import overrides
from chromadb.api.configuration import CollectionConfiguration
from chromadb.config import DEFAULT_DATABASE, DEFAULT_TENANT, Component, System
from chromadb.proto.convert import (
from_proto_metadata,
Expand Down Expand Up @@ -310,10 +311,15 @@ def CreateCollection(
)
)

configuration = CollectionConfiguration.from_json_str(
request.configuration_json_str
)

id = UUID(hex=request.id)
new_collection = Collection(
id=id,
name=request.name,
configuration=configuration,
metadata=from_proto_metadata(request.metadata),
dimension=request.dimension,
database=database,
Expand Down
172 changes: 86 additions & 86 deletions chromadb/proto/chroma_pb2.py

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions chromadb/proto/chroma_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions chromadb/proto/convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import array
from uuid import UUID
from typing import Dict, Optional, Tuple, Union, cast
from chromadb.api.configuration import CollectionConfiguration
from chromadb.api.types import Embedding
import chromadb.proto.chroma_pb2 as proto
from chromadb.types import (
Expand Down Expand Up @@ -203,6 +204,9 @@ def from_proto_collection(collection: proto.Collection) -> Collection:
return Collection(
id=UUID(hex=collection.id),
name=collection.name,
configuration=CollectionConfiguration.from_json_str(
collection.configuration_json_str
),
metadata=from_proto_metadata(collection.metadata)
if collection.HasField("metadata")
else None,
Expand All @@ -219,6 +223,7 @@ def to_proto_collection(collection: Collection) -> proto.Collection:
return proto.Collection(
id=collection["id"].hex,
name=collection["name"],
configuration_json_str=collection.get_configuration().to_json_str(),
metadata=None
if collection["metadata"] is None
else to_proto_update_metadata(collection["metadata"]),
Expand Down
Loading

0 comments on commit a7ae5c4

Please sign in to comment.