-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[BUG] Raise Error when can't deserialize configuration json from server #4471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,13 @@ | |
from uuid import UUID | ||
from enum import Enum | ||
from pydantic import BaseModel | ||
import warnings | ||
|
||
from chromadb.api.configuration import ( | ||
ConfigurationInternal, | ||
) | ||
from chromadb.serde import BaseModelJSONSerializable | ||
from chromadb.api.collection_configuration import ( | ||
CollectionConfiguration, | ||
HNSWConfiguration, | ||
SpannConfiguration, | ||
collection_configuration_to_json, | ||
load_collection_configuration_from_json, | ||
) | ||
|
@@ -149,15 +146,8 @@ def get_configuration(self) -> CollectionConfiguration: | |
try: | ||
return load_collection_configuration_from_json(self.configuration_json) | ||
except Exception as e: | ||
warnings.warn( | ||
f"Server does not respond with configuration_json. Please update server: {e}", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return CollectionConfiguration( | ||
hnsw=HNSWConfiguration(), | ||
spann=SpannConfiguration(), | ||
embedding_function=None, | ||
raise ValueError( | ||
Comment on lines
146
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [CriticalError] Instead of returning a default configuration on deserialization error, now code raises |
||
f"Could not deserialize configuration_json: {e}", | ||
) | ||
|
||
def set_configuration(self, configuration: CollectionConfiguration) -> None: | ||
|
@@ -175,19 +165,12 @@ def get_model_fields(self) -> Dict[Any, Any]: | |
@override | ||
def from_json(cls, json_map: Dict[str, Any]) -> Self: | ||
"""Deserializes a Collection object from JSON""" | ||
configuration: CollectionConfiguration = { | ||
"hnsw": {}, | ||
"spann": {}, | ||
"embedding_function": None, | ||
} | ||
try: | ||
configuration_json = json_map.get("configuration_json", None) | ||
Comment on lines
168
to
169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [DataTypeCheck] Calls to |
||
configuration = load_collection_configuration_from_json(configuration_json) | ||
except Exception as e: | ||
warnings.warn( | ||
f"Server does not respond with configuration_json. Please update server: {e}", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
raise ValueError( | ||
f"Could not deserialize configuration_json: {e}", | ||
) | ||
return cls( | ||
id=json_map["id"], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[CriticalError]
The
warnings
module is used in this file now (see usage inchromadb/api/collection_configuration.py
), but it is not imported. Add the import at the top of the file to prevent runtime errors.