Spaces:
Sleeping
Sleeping
Download src/exception/__init__.py from Sai-sathwik/MLOPS_LIFECYCLE: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/Sai-sathwik/MLOPS_LIFECYCLE/resolve/main/src/exception/__init__.py
- Command line
-
hf download hf://spaces/Sai-sathwik/MLOPS_LIFECYCLE/src/exception/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/Sai-sathwik/MLOPS_LIFECYCLE/resolve/main/src/exception/__init__.py
1.83 kB
| """Custom exception classes for the MLOps platform.""" | |
| import sys | |
| from typing import Optional | |
| def _get_error_message(error: Exception, error_detail: sys) -> str: | |
| """Extract detailed error message with file and line info.""" | |
| _, _, exc_tb = error_detail.exc_info() | |
| if exc_tb is not None: | |
| file_name = exc_tb.tb_frame.f_code.co_filename | |
| line_number = exc_tb.tb_lineno | |
| return f"Error in [{file_name}] at line [{line_number}]: {str(error)}" | |
| return str(error) | |
| class MLOpsPlatformError(Exception): | |
| """Base exception for MLOps Platform.""" | |
| def __init__(self, message: str, error_detail: Optional[sys] = None): | |
| super().__init__(message) | |
| if error_detail: | |
| self.message = _get_error_message(self, error_detail) | |
| else: | |
| self.message = message | |
| def __str__(self) -> str: | |
| return self.message | |
| class DataIngestionError(MLOpsPlatformError): | |
| """Raised when data ingestion fails.""" | |
| pass | |
| class DataValidationError(MLOpsPlatformError): | |
| """Raised when data validation fails.""" | |
| pass | |
| class DataPreprocessingError(MLOpsPlatformError): | |
| """Raised when data preprocessing fails.""" | |
| pass | |
| class ModelTrainingError(MLOpsPlatformError): | |
| """Raised when model training fails.""" | |
| pass | |
| class ModelEvaluationError(MLOpsPlatformError): | |
| """Raised when model evaluation fails.""" | |
| pass | |
| class ModelRegistryError(MLOpsPlatformError): | |
| """Raised when model registry operations fail.""" | |
| pass | |
| class PredictionError(MLOpsPlatformError): | |
| """Raised when prediction fails.""" | |
| pass | |
| class ConfigurationError(MLOpsPlatformError): | |
| """Raised when configuration is invalid.""" | |
| pass | |
| class FeatureEngineeringError(MLOpsPlatformError): | |
| """Raised when feature engineering fails.""" | |
| pass | |