Skip to content

Commit

Permalink
fix: Moving from col name to col id+name as identifier in the state.
Browse files Browse the repository at this point in the history
  • Loading branch information
tazarov committed Feb 14, 2024
1 parent 6a5439b commit 6b4485a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions chromadb/test/property/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_coll(
metadata=coll.metadata,
embedding_function=coll.embedding_function,
)
self.set_model(coll.name, coll.metadata)
self.set_model(coll, coll.metadata)

assert c.name == coll.name
assert c.metadata == self.model[coll.name]
Expand Down Expand Up @@ -163,7 +163,7 @@ def get_or_create_coll(
coll.metadata = (
self.model[coll.name] if new_metadata is None else new_metadata
)
self.set_model(coll.name, coll.metadata)
self.set_model(coll, coll.metadata)

# Update API
c = self.api.get_or_create_collection(
Expand Down Expand Up @@ -196,7 +196,6 @@ def modify_coll(

c = self.api.get_collection(name=coll.name)
_metadata: Optional[Mapping[str, Any]] = coll.metadata
_name: str = coll.name
if new_metadata is not None:
if len(new_metadata) == 0:
with pytest.raises(Exception):
Expand All @@ -217,8 +216,7 @@ def modify_coll(

self.delete_from_model(coll.name)
coll.name = new_name
_name = new_name
self.set_model(_name, _metadata) # type: ignore
self.set_model(coll, _metadata) # type: ignore

c.modify(metadata=new_metadata, name=new_name)
c = self.api.get_collection(name=coll.name)
Expand All @@ -228,10 +226,10 @@ def modify_coll(
return multiple(coll)

def set_model(
self, name: str, metadata: Optional[types.CollectionMetadata]
self, coll: strategies.Collection, metadata: Optional[types.CollectionMetadata]
) -> None:
model = self.model
model[name] = metadata
model[f"{coll.id}-{coll.name}"] = metadata

def delete_from_model(self, name: str) -> None:
model = self.model
Expand Down

0 comments on commit 6b4485a

Please sign in to comment.