Spaces:
Sleeping

File size: 1,827 Bytes
5e6746d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""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