refactor: Moved ingestion exceptions to ingestion module
Moved custom ingestion exceptions to ingestion module Refactor COG-502
This commit is contained in:
parent
1b2bdd9b83
commit
eb09e5ad89
11 changed files with 37 additions and 25 deletions
|
|
@ -11,8 +11,6 @@ from .exceptions import (
|
|||
EntityNotFoundError,
|
||||
EntityAlreadyExistsError,
|
||||
InvalidOperationError,
|
||||
PermissionDeniedError,
|
||||
IngestionError,
|
||||
InvalidValueError,
|
||||
InvalidAttributeError,
|
||||
)
|
||||
|
|
@ -70,24 +70,6 @@ class InvalidOperationError(CogneeApiError):
|
|||
super().__init__(message, name, status_code)
|
||||
|
||||
|
||||
class PermissionDeniedError(CogneeApiError):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "User does not have permission on documents.",
|
||||
name: str = "PermissionDeniedError",
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
):
|
||||
super().__init__(message, name, status_code)
|
||||
|
||||
class IngestionError(CogneeApiError):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "Type of data sent to classify not supported.",
|
||||
name: str = "IngestionError",
|
||||
status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
|
||||
):
|
||||
super().__init__(message, name, status_code)
|
||||
|
||||
class InvalidValueError(CogneeApiError):
|
||||
def __init__(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from typing import Union, BinaryIO
|
|||
from .data_types import TextData, BinaryData
|
||||
from tempfile import SpooledTemporaryFile
|
||||
|
||||
from cognee.exceptions import IngestionError
|
||||
from cognee.modules.ingestion.exceptions import IngestionError
|
||||
|
||||
|
||||
def classify(data: Union[str, BinaryIO], filename: str = None):
|
||||
|
|
|
|||
9
cognee/modules/ingestion/exceptions/__init__.py
Normal file
9
cognee/modules/ingestion/exceptions/__init__.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
"""
|
||||
Custom exceptions for the Cognee API.
|
||||
|
||||
This module defines a set of exceptions for handling various ingestion errors
|
||||
"""
|
||||
|
||||
from .exceptions import (
|
||||
IngestionError,
|
||||
)
|
||||
11
cognee/modules/ingestion/exceptions/exceptions.py
Normal file
11
cognee/modules/ingestion/exceptions/exceptions.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from cognee.exceptions import CogneeApiError
|
||||
from fastapi import status
|
||||
|
||||
class IngestionError(CogneeApiError):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "Type of data sent to classify not supported.",
|
||||
name: str = "IngestionError",
|
||||
status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
|
||||
):
|
||||
super().__init__(message, name, status_code)
|
||||
|
|
@ -7,4 +7,5 @@ This module defines a set of exceptions for handling various user errors
|
|||
from .exceptions import (
|
||||
GroupNotFoundError,
|
||||
UserNotFoundError,
|
||||
PermissionDeniedError,
|
||||
)
|
||||
|
|
@ -24,3 +24,13 @@ class UserNotFoundError(CogneeApiError):
|
|||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
):
|
||||
super().__init__(message, name, status_code)
|
||||
|
||||
|
||||
class PermissionDeniedError(CogneeApiError):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "User does not have permission on documents.",
|
||||
name: str = "PermissionDeniedError",
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
):
|
||||
super().__init__(message, name, status_code)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from uuid import UUID
|
|||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from cognee.exceptions import PermissionDeniedError
|
||||
from cognee.modules.users.exceptions import PermissionDeniedError
|
||||
from cognee.infrastructure.databases.relational import get_relational_engine
|
||||
|
||||
from ...models.User import User
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import aiofiles
|
|||
import pandas as pd
|
||||
from pydantic import BaseModel
|
||||
|
||||
from cognee.exceptions import IngestionError, EntityNotFoundError
|
||||
from cognee.exceptions import EntityNotFoundError
|
||||
from cognee.modules.ingestion.exceptions import IngestionError
|
||||
from cognee.infrastructure.llm.prompts import read_query_prompt
|
||||
from cognee.infrastructure.llm.get_llm_client import get_llm_client
|
||||
from cognee.infrastructure.data.chunking.config import get_chunk_config
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Union, BinaryIO
|
||||
|
||||
from cognee.exceptions import IngestionError
|
||||
from cognee.modules.ingestion.exceptions import IngestionError
|
||||
from cognee.modules.ingestion import save_data_to_file
|
||||
|
||||
def save_data_item_to_storage(data_item: Union[BinaryIO, str], dataset_name: str) -> str:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Union, BinaryIO, Any
|
||||
|
||||
from cognee.exceptions import IngestionError
|
||||
from cognee.modules.ingestion.exceptions import IngestionError
|
||||
from cognee.modules.ingestion import save_data_to_file
|
||||
|
||||
def save_data_item_with_metadata_to_storage(data_item: Union[BinaryIO, str, Any], dataset_name: str) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue