This is an automated email from the ASF dual-hosted git repository.
utkarsharma pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 0a741b2fe6 Handle list like input objects in weavaite's
'create_or_replace_document_objects' hook method (#36475)
0a741b2fe6 is described below
commit 0a741b2fe674e62f693e73937aec5fb97c204b6a
Author: Utkarsh Sharma <[email protected]>
AuthorDate: Thu Dec 28 21:18:33 2023 +0530
Handle list like input objects in weavaite's
'create_or_replace_document_objects' hook method (#36475)
---
airflow/providers/weaviate/hooks/weaviate.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/airflow/providers/weaviate/hooks/weaviate.py
b/airflow/providers/weaviate/hooks/weaviate.py
index 10f784e9fe..e67061f757 100644
--- a/airflow/providers/weaviate/hooks/weaviate.py
+++ b/airflow/providers/weaviate/hooks/weaviate.py
@@ -21,7 +21,7 @@ import contextlib
import json
import warnings
from functools import cached_property
-from typing import TYPE_CHECKING, Any, Dict, List, cast
+from typing import TYPE_CHECKING, Any, Dict, List, Sequence, cast
import requests
import weaviate.exceptions
@@ -36,7 +36,7 @@ from airflow.exceptions import
AirflowProviderDeprecationWarning
from airflow.hooks.base import BaseHook
if TYPE_CHECKING:
- from typing import Callable, Collection, Literal, Sequence
+ from typing import Callable, Collection, Literal
import pandas as pd
from weaviate.types import UUID
@@ -974,10 +974,10 @@ class WeaviateHook(BaseHook):
if len(data) == 0:
return []
- if isinstance(data, list) and isinstance(data[0], dict):
+ if isinstance(data, Sequence) and isinstance(data[0], dict):
# This is done to narrow the type to List[Dict[str, Any].
data = pd.json_normalize(cast(List[Dict[str, Any]], data))
- elif isinstance(data, list) and isinstance(data[0], pd.DataFrame):
+ elif isinstance(data, Sequence) and isinstance(data[0], pd.DataFrame):
# This is done to narrow the type to List[pd.DataFrame].
data = pd.concat(cast(List[pd.DataFrame], data), ignore_index=True)
else: