Module dynamicio.errors
Hosts exception implementations for different errors.
Expand source code
"""Hosts exception implementations for different errors."""
# pylint: disable=missing-module-docstring, missing-class-docstring, missing-function-docstring, super-init-not-called
__all__ = [
    "DynamicIOError",
    "DataSourceError",
    "ColumnsDataTypeError",
    "NonUniqueIdColumnError",
    "NullValueInColumnError",
    "NotExpectedCategoricalValue",
    "MissingSchemaDefinition",
    "SchemaNotFoundError",
    "SchemaValidationError",
    "InvalidDatasetTypeError",
    "CASTING_WARNING_MSG",
    "NOTICE_MSG",
]
from typing import Any, Optional
class DynamicIOError(Exception):
    """Base class for DynamicIO errors."""
    ERROR_STR: str = ""
    ERROR_STR_DETAILED: str = "{0}"
    @property
    def message(self) -> Optional[Any]:
        """Easy access for optional message argument.
        Returns:
            Message or `None` if not set
        """
        try:
            return self.args[0]
        except IndexError:
            return None
    def __str__(self):
        """Enrich and return error message."""
        message = self.message
        if message is None:
            return self.ERROR_STR
        return self.ERROR_STR_DETAILED.format(message)
class SchemaNotFoundError(DynamicIOError):
    """Error raised when schema is not specified in the provided source."""
    ERROR_STR = "Schema not specified in the provided source"
    ERROR_STR_DETAILED = "Schema not specified in the provided source: {0} "
class SchemaValidationError(DynamicIOError):
    """Error raised when schema validation fails."""
class MissingSchemaDefinition(DynamicIOError):
    """Error raised when schema is not specified in the provided source."""
    ERROR_STR = "The resource definition for this class is missing a schema definition"
    ERROR_STR_DETAILED = "The resource definition for this class is missing a schema definition: {0}"
class DataSourceError(DynamicIOError):
    """Error raised when the data source fails to load."""
class ColumnsDataTypeError(DynamicIOError):
    """Error raised when the validated data does not have the expected data types."""
class NonUniqueIdColumnError(DynamicIOError):
    """Error raised when the data source fails to load."""
class NullValueInColumnError(DynamicIOError):
    """Error raised when the data source fails to load."""
class NotExpectedCategoricalValue(DynamicIOError):
    """Error raised when the data source fails to load."""
class InvalidDatasetTypeError(DynamicIOError):
    """Error raised when dataset type is not one of [parquet, json, csv, h5]."""
    ERROR_STR = "The dataset provided is not amongst the supported types (parquet, json, csv, h5) handled by dynamicio."
    ERROR_STR_DETAILED = "Dataset: {0} provided is not amongst the supported types (parquet, json, csv, h5) handled by dynamicio."
# Warning messages
CASTING_WARNING_MSG = "Applying casting column: '{0}' to: 'type:{1}' from 'type:{2}' though not advised, as `dtypes`>1 for {0}, which may lead to data corruption!"
NOTICE_MSG = "Keeping the {0} as is, may anyway cause I/O errors or data corruption issues especially when using `pandas.DataFrame.to_parquet` or `pandas.DataFrame.to_json`."Classes
- class ColumnsDataTypeError (*args, **kwargs)
- 
Error raised when the validated data does not have the expected data types. Expand source codeclass ColumnsDataTypeError(DynamicIOError): """Error raised when the validated data does not have the expected data types."""Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Inherited members
- class DataSourceError (*args, **kwargs)
- 
Error raised when the data source fails to load. Expand source codeclass DataSourceError(DynamicIOError): """Error raised when the data source fails to load."""Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Inherited members
- class DynamicIOError (*args, **kwargs)
- 
Base class for DynamicIO errors. Expand source codeclass DynamicIOError(Exception): """Base class for DynamicIO errors.""" ERROR_STR: str = "" ERROR_STR_DETAILED: str = "{0}" @property def message(self) -> Optional[Any]: """Easy access for optional message argument. Returns: Message or `None` if not set """ try: return self.args[0] except IndexError: return None def __str__(self): """Enrich and return error message.""" message = self.message if message is None: return self.ERROR_STR return self.ERROR_STR_DETAILED.format(message)Ancestors- builtins.Exception
- builtins.BaseException
 Subclasses- ColumnsDataTypeError
- DataSourceError
- InvalidDatasetTypeError
- MissingSchemaDefinition
- NonUniqueIdColumnError
- NotExpectedCategoricalValue
- NullValueInColumnError
- SchemaNotFoundError
- SchemaValidationError
 Class variables- var ERROR_STR : str
- var ERROR_STR_DETAILED : str
 Instance variables- var message : Optional[Any]
- 
Easy access for optional message argument. ReturnsMessage or Noneif not setExpand source code@property def message(self) -> Optional[Any]: """Easy access for optional message argument. Returns: Message or `None` if not set """ try: return self.args[0] except IndexError: return None
 
- class InvalidDatasetTypeError (*args, **kwargs)
- 
Error raised when dataset type is not one of [parquet, json, csv, h5]. Expand source codeclass InvalidDatasetTypeError(DynamicIOError): """Error raised when dataset type is not one of [parquet, json, csv, h5].""" ERROR_STR = "The dataset provided is not amongst the supported types (parquet, json, csv, h5) handled by dynamicio." ERROR_STR_DETAILED = "Dataset: {0} provided is not amongst the supported types (parquet, json, csv, h5) handled by dynamicio."Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Class variables- var ERROR_STR : str
- var ERROR_STR_DETAILED : str
 Inherited members
- class MissingSchemaDefinition (*args, **kwargs)
- 
Error raised when schema is not specified in the provided source. Expand source codeclass MissingSchemaDefinition(DynamicIOError): """Error raised when schema is not specified in the provided source.""" ERROR_STR = "The resource definition for this class is missing a schema definition" ERROR_STR_DETAILED = "The resource definition for this class is missing a schema definition: {0}"Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Class variables- var ERROR_STR : str
- var ERROR_STR_DETAILED : str
 Inherited members
- class NonUniqueIdColumnError (*args, **kwargs)
- 
Error raised when the data source fails to load. Expand source codeclass NonUniqueIdColumnError(DynamicIOError): """Error raised when the data source fails to load."""Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Inherited members
- class NotExpectedCategoricalValue (*args, **kwargs)
- 
Error raised when the data source fails to load. Expand source codeclass NotExpectedCategoricalValue(DynamicIOError): """Error raised when the data source fails to load."""Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Inherited members
- class NullValueInColumnError (*args, **kwargs)
- 
Error raised when the data source fails to load. Expand source codeclass NullValueInColumnError(DynamicIOError): """Error raised when the data source fails to load."""Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Inherited members
- class SchemaNotFoundError (*args, **kwargs)
- 
Error raised when schema is not specified in the provided source. Expand source codeclass SchemaNotFoundError(DynamicIOError): """Error raised when schema is not specified in the provided source.""" ERROR_STR = "Schema not specified in the provided source" ERROR_STR_DETAILED = "Schema not specified in the provided source: {0} "Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Class variables- var ERROR_STR : str
- var ERROR_STR_DETAILED : str
 Inherited members
- class SchemaValidationError (*args, **kwargs)
- 
Error raised when schema validation fails. Expand source codeclass SchemaValidationError(DynamicIOError): """Error raised when schema validation fails."""Ancestors- DynamicIOError
- builtins.Exception
- builtins.BaseException
 Inherited members