class_docstr: Interact with Weaviate database to store vectors. This hook uses the 'conn_id'.
  
  :param conn_id: The connection id to use when connecting to Weaviate. <howto/connection:weaviate>
class_docstr_tok: ["Interact","with","Weaviate","database","to","store","vectors",".","This","hook","uses","the","'conn_id","'",".",":","param","conn_id",":","The","connection","id","to","use","when","connecting","to","Weaviate",".","<","howto\/connection",":","weaviate",">"]
docstr: Add multiple objects or object references at once into weaviate.
  
  :param class_name: The name of the class that objects belongs to.
  :param data: list or dataframe of objects we want to add.
  :param batch_config_params: dict of batch configuration option.
      .. seealso:: `batch_config_params options <https://weaviate-python-client.readthedocs.io/en/v3.25.3/weaviate.batch.html#weaviate.batch.Batch.configure>`__
  :param vector_col: name of the column containing the vector.
  :param uuid_col: Name of the column containing the UUID.
  :param retry_attempts_per_object: number of time to try in case of failure before giving up.
  :param tenant: The tenant to which the object will be added.
code: def batch_data(
      self,
      class_name: str,
      data: list[dict[str, Any]] | pd.DataFrame,
      batch_config_params: dict[str, Any] | None = None,
      vector_col: str = "Vector",
      uuid_col: str = "id",
      retry_attempts_per_object: int = 5,
      tenant: str | None = None,
  ) -> list:
      """
      Add multiple objects or object references at once into weaviate.
  
      :param class_name: The name of the class that objects belongs to.
      :param data: list or dataframe of objects we want to add.
      :param batch_config_params: dict of batch configuration option.
          .. seealso:: `batch_config_params options <https://weaviate-python-client.readthedocs.io/en/v3.25.3/weaviate.batch.html#weaviate.batch.Batch.configure>`__
      :param vector_col: name of the column containing the vector.
      :param uuid_col: Name of the column containing the UUID.
      :param retry_attempts_per_object: number of time to try in case of failure before giving up.
      :param tenant: The tenant to which the object will be added.
      """
      data = self._convert_dataframe_to_list(data)
      total_results = 0
      error_results = 0
      insertion_errors: list = []
  
      def _process_batch_errors(
          results: list,
          verbose: bool = True,
      ) -> None:
          """
          Helper function to processes the results from insert or delete batch operation and collects any errors.
  
          :param results: Results from the batch operation.
          :param verbose: Flag to enable verbose logging.
          """
          nonlocal total_results
          nonlocal error_results
          total_batch_results = len(results)
          error_batch_results = 0
          for item in results:
              if "errors" in item["result"]:
                  error_batch_results = error_batch_results + 1
                  item_error = {
                      "uuid": item["id"],
                      "errors": item["result"]["errors"],
                  }
                  if verbose:
                      self.log.info(
                          "Error occurred in batch process for %s with error %s",
                          item["id"],
                          item["result"]["errors"],
                      )
                  insertion_errors.append(item_error)
          if verbose:
              total_results = total_results + (
                  total_batch_results - error_batch_results
              )
              error_results = error_results + error_batch_results
  
              self.log.info(
                  "Total Objects %s / Objects %s successfully inserted and Objects %s had errors.",
                  len(data),
                  total_results,
                  error_results,
              )
  
      client = self.conn
      if not batch_config_params:
          batch_config_params = {}
  
      # configuration for context manager for __exit__ method to callback on errors for weaviate
      # batch ingestion.
      if not batch_config_params.get("callback"):
          batch_config_params["callback"] = _process_batch_errors
  
      if not batch_config_params.get("timeout_retries"):
          batch_config_params["timeout_retries"] = 5
  
      if not batch_config_params.get("connection_error_retries"):
          batch_config_params["connection_error_retries"] = 5
  
      client.batch.configure(**batch_config_params)
      with client.batch as batch:
          # Batch import all data
          for index, data_obj in enumerate(data):
              for attempt in Retrying(
                  stop=stop_after_attempt(retry_attempts_per_object),
                  retry=(
                      retry_if_exception(
                          lambda exc: check_http_error_is_retryable(exc)
                      )
                      | retry_if_exception_type(
                          REQUESTS_EXCEPTIONS_TYPES
                      )
                  ),
              ):
                  with attempt:
                      vector = data_obj.pop(vector_col, None)
                      uuid = data_obj.pop(uuid_col, None)
                      self.log.debug(
                          "Attempt %s of inserting object with uuid: %s",
                          attempt.retry_state.attempt_number,
                          uuid,
                      )
                      batch.add_data_object(
                          data_object=data_obj,
                          class_name=class_name,
                          vector=vector,
                          uuid=uuid,
                          tenant=tenant,
                      )
                      self.log.debug(
                          "Inserted object with uuid: %s into batch",
                          uuid,
                      )
      return insertion_errors
  
imports: from __future__ import annotations
  import contextlib
  import json
  import warnings
  from functools import cached_property
  from typing import TYPE_CHECKING, Any, Dict, List, Sequence, cast
  import requests
  import weaviate.exceptions
  from tenacity import Retrying, retry, retry_if_exception, retry_if_exception_type, stop_after_attempt
  from weaviate import Client
  from weaviate.auth import AuthApiKey, AuthBearerToken, AuthClientCredentials, AuthClientPassword
  from weaviate.data.replication import ConsistencyLevel
  from weaviate.exceptions import ObjectAlreadyExistsException
  from weaviate.util import generate_uuid5
  from airflow.exceptions import AirflowProviderDeprecationWarning
  from airflow.hooks.base import BaseHook
label_desc: Use image node_id 19 for calling the WeaviateHook obj's underlying member method code with example usage: obj.batch_data(class_name, data, batch_config_params, vector_col, uuid_col, retry_attempts_per_object, tenant) and returns: insertion_errors