Skip to content

climate_ref_core.exceptions #

Custom exceptions

CondaCommandError #

Bases: ExecutionError

Exception raised when a conda command fails

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class CondaCommandError(ExecutionError):
    """Exception raised when a conda command fails"""

    def __init__(self, message: str, stdout: str = "", stderr: str = "") -> None:
        self.short_message = message
        self.stdout = stdout
        self.stderr = stderr
        complete_msg = f"{message}\nstdout: {stdout}\nstderr: {stderr}"

        super().__init__(complete_msg)

ConstraintNotSatisfied #

Bases: RefException

Exception raised when a constraint is violated

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class ConstraintNotSatisfied(RefException):
    """Exception raised when a constraint is violated"""

DatasetResolutionError #

Bases: TestCaseError

Raised when datasets cannot be resolved for a test case.

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class DatasetResolutionError(TestCaseError):
    """Raised when datasets cannot be resolved for a test case."""

    pass

DiagnosticError #

Bases: RefException

Error from diagnostic computing

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class DiagnosticError(RefException):
    """Error from diagnostic computing"""

    def __init__(self, message: str, result: Any):
        super().__init__(message)
        self.message = message
        self.result = result

    # need for serialization of parsl
    def __reduce__(self) -> tuple[type["DiagnosticError"], tuple[str, Any]]:
        # Return a tuple: (callable, args_tuple_for_reconstruction)
        return (self.__class__, (self.message, self.result))

ExecutionError #

Bases: RefException

Exception raised when an execution fails

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class ExecutionError(RefException):
    """Exception raised when an execution fails"""

    def __init__(self, message: str) -> None:
        super().__init__(message)

InvalidDiagnosticException #

Bases: RefException

Exception raised when an invalid diagnostic is registered

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class InvalidDiagnosticException(RefException):
    """Exception raised when an invalid diagnostic is registered"""

    def __init__(self, metric: Any, message: str) -> None:
        message = f"Invalid diagnostic: '{metric}'\n {message}"

        super().__init__(message)

InvalidExecutorException #

Bases: RefException

Exception raised when an invalid executor is used

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class InvalidExecutorException(RefException):
    """Exception raised when an invalid executor is used"""

    def __init__(self, executor: Any, message: str) -> None:
        message = f"Invalid executor: '{executor}'\n {message}"

        super().__init__(message)

InvalidProviderException #

Bases: RefException

Exception raised when an invalid diagnostic is registered

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class InvalidProviderException(RefException):
    """Exception raised when an invalid diagnostic is registered"""

    def __init__(self, provider: Any, message: str) -> None:
        message = f"Invalid provider: '{provider}'\n {message}"

        super().__init__(message)

NoTestDataSpecError #

Bases: TestCaseError

Raised when a diagnostic has no test_data_spec.

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class NoTestDataSpecError(TestCaseError):
    """Raised when a diagnostic has no test_data_spec."""

    pass

RefException #

Bases: Exception

Base class for exceptions related to REF operations

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class RefException(Exception):
    """Base class for exceptions related to REF operations"""

    pass

ResultValidationError #

Bases: RefException

Exception raised when the executions from a diagnostic are invalid

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class ResultValidationError(RefException):
    """Exception raised when the executions from a diagnostic are invalid"""

TestCaseError #

Bases: RefException

Raised when there is an error with a test case.

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class TestCaseError(RefException):
    """Raised when there is an error with a test case."""

    pass

TestCaseNotFoundError #

Bases: TestCaseError

Raised when a test case is not found.

Source code in packages/climate-ref-core/src/climate_ref_core/exceptions.py
class TestCaseNotFoundError(TestCaseError):
    """Raised when a test case is not found."""

    pass