-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dlt for metadata #247
Fix dlt for metadata #247
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,9 @@ | |
async def save_data_item_with_metadata_to_storage( | ||
data_item: Union[BinaryIO, str, Any], dataset_name: str | ||
) -> str: | ||
# Dynamic import is used because the llama_index module is optional. | ||
# For the same reason Any is accepted as a data item | ||
# Check if data is of type Document or any of it's subclasses | ||
if str(type(data_item)).startswith("llama_index"): | ||
|
||
if "llama_index" in str(type(data_item)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve type checking for Using Since try:
from llama_index import LlamaIndexType # Replace with the actual type
except ImportError:
LlamaIndexType = None
if LlamaIndexType and isinstance(data_item, LlamaIndexType):
# Process data_item Alternatively, use attribute checks: if hasattr(data_item, 'some_unique_attribute'):
# Process data_item This approach is more reliable and easier to maintain. |
||
# Dynamic import is used because the llama_index module is optional. | ||
from .transform_data import get_data_from_llama_index | ||
|
||
file_path = get_data_from_llama_index(data_item, dataset_name) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the type annotation for
file_paths
indata_resources
.The
file_paths
parameter should be annotated as a list of strings (List[str]
), notstr
, since it is iterated over in the function.Apply this diff to fix the type annotation: