Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions airflow/providers/weaviate/hooks/weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def create_schema(self, schema_json: dict[str, Any] | str) -> None:
client.schema.create(schema_json)

@staticmethod
def _convert_dataframe_to_list(data: list[dict[str, Any]] | pd.DataFrame) -> list[dict[str, Any]]:
def _convert_dataframe_to_list(data: list[dict[str, Any]] | pd.DataFrame | None) -> list[dict[str, Any]]:
"""Helper function to convert dataframe to list of dicts.

In scenario where Pandas isn't installed and we pass data as a list of dictionaries, importing
Expand Down Expand Up @@ -382,7 +382,7 @@ def check_subset_of_schema(self, classes_objects: list) -> bool:
def batch_data(
self,
class_name: str,
data: list[dict[str, Any]] | pd.DataFrame,
data: list[dict[str, Any]] | pd.DataFrame | None,
batch_config_params: dict[str, Any] | None = None,
vector_col: str = "Vector",
uuid_col: str = "id",
Expand All @@ -401,7 +401,7 @@ def batch_data(
: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)
converted_data = self._convert_dataframe_to_list(data)
total_results = 0
error_results = 0
insertion_errors: list = []
Expand Down Expand Up @@ -437,7 +437,7 @@ def _process_batch_errors(

self.log.info(
"Total Objects %s / Objects %s successfully inserted and Objects %s had errors.",
len(data),
len(converted_data),
total_results,
error_results,
)
Expand All @@ -460,7 +460,7 @@ def _process_batch_errors(
client.batch.configure(**batch_config_params)
with client.batch as batch:
# Batch import all data
for index, data_obj in enumerate(data):
for index, data_obj in enumerate(converted_data):
for attempt in Retrying(
stop=stop_after_attempt(retry_attempts_per_object),
retry=(
Expand Down
7 changes: 3 additions & 4 deletions airflow/providers/weaviate/operators/weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,16 @@ def __init__(
self.input_json = input_json
self.uuid_column = uuid_column
self.tenant = tenant
if input_data is not None:
self.input_data = input_data
elif input_json is not None:
self.input_data = input_data
if (self.input_data is None) and (input_json is not None):
warnings.warn(
"Passing 'input_json' to WeaviateIngestOperator is deprecated and"
" you should use 'input_data' instead",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
self.input_data = input_json
else:
elif self.input_data is None and input_json is None:
raise TypeError("Either input_json or input_data is required")

@cached_property
Expand Down