feat: adds s3 file system not found error to ingestion
This commit is contained in:
parent
d14d31adbe
commit
748e9fad86
3 changed files with 27 additions and 0 deletions
10
cognee/tasks/ingestion/exceptions/__init__.py
Normal file
10
cognee/tasks/ingestion/exceptions/__init__.py
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
"""
|
||||||
|
Custom exceptions for the Cognee API.
|
||||||
|
|
||||||
|
This module defines a set of exceptions for handling various application errors,
|
||||||
|
such as System, Validation, Configuration or TransientErrors
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .exceptions import (
|
||||||
|
S3FileSystemNotFoundError
|
||||||
|
)
|
||||||
12
cognee/tasks/ingestion/exceptions/exceptions.py
Normal file
12
cognee/tasks/ingestion/exceptions/exceptions.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
from cognee.exceptions import CogneeSystemError
|
||||||
|
from fastapi import status
|
||||||
|
|
||||||
|
|
||||||
|
class S3FileSystemNotFoundError(CogneeSystemError):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
name: str = "S3FileSystemNotFoundError",
|
||||||
|
status_code: int = status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
|
):
|
||||||
|
message = "Could not find S3FileSystem."
|
||||||
|
super().__init__(message, name, status_code)
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
import os
|
import os
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from typing import List, Union, BinaryIO
|
from typing import List, Union, BinaryIO
|
||||||
|
|
||||||
|
from cognee.tasks.ingestion.exceptions import S3FileSystemNotFoundError
|
||||||
|
from cognee.exceptions import CogneeSystemError
|
||||||
from cognee.infrastructure.files.storage.s3_config import get_s3_config
|
from cognee.infrastructure.files.storage.s3_config import get_s3_config
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -54,6 +57,8 @@ async def resolve_data_directories(
|
||||||
else:
|
else:
|
||||||
s3_files.append(key)
|
s3_files.append(key)
|
||||||
resolved_data.extend(s3_files)
|
resolved_data.extend(s3_files)
|
||||||
|
else:
|
||||||
|
raise S3FileSystemNotFoundError()
|
||||||
|
|
||||||
elif os.path.isdir(item): # If it's a directory
|
elif os.path.isdir(item): # If it's a directory
|
||||||
if include_subdirectories:
|
if include_subdirectories:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue