ephraimbuddy commented on code in PR #35934:
URL: https://github.com/apache/airflow/pull/35934#discussion_r1413182172


##########
airflow/providers/weaviate/hooks/weaviate.py:
##########
@@ -193,3 +195,88 @@ def query_without_vector(
             .do()
         )
         return results
+
+    def create_object(self, data_object, class_name, **kwargs) -> str | 
dict[str, Any] | None:
+        """Create a new object.
+
+        data_object: Object to be added. If type is str it should be either a 
URL or a file.
+        class_name: Class name associated with the object given.
+        **kwargs: Additional parameters to be passed to 
weaviateclient.data_object.create()
+        """
+        client = self.get_conn()
+        # generate deterministic uuid if not provided
+        uuid = kwargs.pop("uuid", generate_uuid5(data_object))
+        try:
+            return client.data_object.create(data_object, class_name, 
uuid=uuid, **kwargs)
+        except ObjectAlreadyExistsException:
+            self.log.warning("Object with the UUID %s already exists", uuid)
+            return None
+
+    def get_or_create_object(self, data_object, class_name, **kwargs) -> str | 
dict[str, Any] | None:
+        """Get or Create a new object.
+
+        Returns the object if already exists
+        data_object: Object to be added. If type is str it should be either a 
URL or a file.
+        class_name: Class name associated with the object given.
+        **kwargs: Additional parameters to be passed to 
weaviateclient.data_object.create() and
+        weaviateclient.data_object.get()
+        """
+        vector = kwargs.pop("vector", None)
+        class_name = kwargs.pop("class_name", class_name)

Review Comment:
   only `vector` is used in creating new objects, others can be used in both 
operations. I have updated it to reflect that and added those named arguments 
in the `create_object` operation explicitly



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to