Skip to content

Commit 8b19114

Browse files
committed
Add url parser to all dict inputs
1 parent e53b536 commit 8b19114

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

weaviate/data/crud_data.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,13 @@ def create(self, data_object, class_name, uuid=None, semantic_type=SEMANTIC_TYPE
4242
ConnectionError: if the network connection to weaviate fails.
4343
:rtype: str
4444
"""
45-
46-
if not isinstance(data_object, dict):
47-
raise TypeError(
48-
"Expected" + semantic_type[:-1] + " to be of type dict instead it was: " + str(type(data_object)))
45+
loaded_data_object = _get_dict_from_object(data_object)
4946
if not isinstance(class_name, str):
5047
raise TypeError("Expected class_name of type str but was: " + str(type(class_name)))
5148

5249
weaviate_obj = {
5350
"class": class_name,
54-
"schema": data_object
51+
"schema": loaded_data_object
5552
}
5653
if uuid is not None:
5754
if not isinstance(uuid, str):
@@ -116,10 +113,7 @@ def merge(self, data_object, class_name, uuid, semantic_type=SEMANTIC_TYPE_THING
116113
ConnectionError: If the network connection to weaviate fails.
117114
UnexpectedStatusCodeException: If weaviate reports a none successful status.
118115
"""
119-
try:
120-
object_dict = _get_dict_from_object(data_object)
121-
except:
122-
raise # Keep exception boiling back to user
116+
object_dict = _get_dict_from_object(data_object)
123117

124118
if not isinstance(class_name, str):
125119
raise TypeError("Class must be type str")

weaviate/schema/crud_schema.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ def create_class(self, schema_class, semantic_type=SEMANTIC_TYPE_THINGS):
7070
ConnectionError: if the network connection to weaviate fails.
7171
UnexpectedStatusCodeException: if weaviate reports a none OK status.
7272
"""
73-
check_class(schema_class)
73+
try:
74+
loaded_schema_class = _get_dict_from_object(schema_class)
75+
except ConnectionError:
76+
raise
77+
except UnexpectedStatusCodeException:
78+
raise
79+
80+
check_class(loaded_schema_class)
7481
self._create_class_with_premitives(semantic_type, schema_class)
7582
self._create_complex_properties_from_class(schema_class, semantic_type)
7683

0 commit comments

Comments
 (0)