src.util.exceptions module

All framework-specific exceptions are placed in a single module to simplify imports.

src.util.exceptions.exit_on_exception(exc, msg=None)[source]

Prints information about a fatal exception to the console before exiting. Use case is in user-facing subcommands (mdtf install etc.), since we have more sophisticated logging in the framework itself.

Parameters
  • exc (Exception) – Exception to print.

  • msg (str) – Optional, additional message to print.

src.util.exceptions.exit_handler(code=1, msg=None)[source]

Wraps all calls to sys.exit(); could do additional cleanup not handled by atexit() here.

src.util.exceptions.chain_exc(exc, new_msg, new_exc_class=None)[source]

Raise a new exception from an existing one, in order to give more context for debugging. See Python documentation on exception chaining.

Parameters
  • exc (Exception) – Incoming exception to chain new exception from.

  • new_msg (str) – Message for new Exception.

  • new_exc_class (class) – Optional. Class of new exception to raise. If not provided, raises a new exception of the same type as exc.

src.util.exceptions.exc_descriptor(exc)[source]
exception src.util.exceptions.TimeoutAlarm[source]

Bases: Exception

Dummy exception raised if a subprocess times out.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.MDTFBaseException[source]

Bases: Exception

Base class to describe all MDTF-specific errors that can happen during the framework’s operation.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.ChildFailureEvent(obj)[source]

Bases: src.util.exceptions.MDTFBaseException

Exception raised when a member of the object hierarchy is deactivated because all its child objects have failed.

__init__(obj)[source]

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.PropagatedEvent(exc, parent)[source]

Bases: src.util.exceptions.MDTFBaseException

Exception passed between members of the object hierarchy when a parent object (MDTFObjectBase) has been deactivated and needs to deactivate its children.

__init__(exc, parent)[source]

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.MDTFFileNotFoundError(path)[source]

Bases: FileNotFoundError, src.util.exceptions.MDTFBaseException

Wrapper for FileNotFoundError which handles error codes so we don’t have to remember to import errno everywhere.

__init__(path)[source]

Initialize self. See help(type(self)) for accurate signature.

args
characters_written
errno

POSIX exception code

filename

exception filename

filename2

second exception filename

strerror

exception strerror

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.MDTFFileExistsError(path)[source]

Bases: FileExistsError, src.util.exceptions.MDTFBaseException

Wrapper for FileExistsError which handles error codes so we don’t have to remember to import errno everywhere.

__init__(path)[source]

Initialize self. See help(type(self)) for accurate signature.

args
characters_written
errno

POSIX exception code

filename

exception filename

filename2

second exception filename

strerror

exception strerror

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.MDTFCalledProcessError(returncode, cmd, output=None, stderr=None)[source]

Bases: subprocess.CalledProcessError, src.util.exceptions.MDTFBaseException

Wrapper for subprocess.CalledProcessError.

args
property stdout

Alias for output attribute, to match stderr

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.WormKeyError[source]

Bases: KeyError, src.util.exceptions.MDTFBaseException

Raised when attempting to overwrite or delete an entry in a WormDict.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.DataclassParseError[source]

Bases: ValueError, src.util.exceptions.MDTFBaseException

Raised when parsing input data fails on a mdtf_dataclass() or regex_dataclass().

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.RegexParseError[source]

Bases: ValueError, src.util.exceptions.MDTFBaseException

Raised when parsing input data fails on a RegexPattern().

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.RegexSuppressedError[source]

Bases: ValueError, src.util.exceptions.MDTFBaseException

Raised when parsing input data fails on a RegexPattern(), but we’ve decided to supress error based on the associated RegexPattern’s match_error_filter attribute.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.UnitsError[source]

Bases: ValueError, src.util.exceptions.MDTFBaseException

Raised when trying to convert between quantities with physically inequivalent units.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.ConventionError(conv_name)[source]

Bases: src.util.exceptions.MDTFBaseException

Exception raised by a duplicate variable convention name.

__init__(conv_name)[source]

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.MixedDatePrecisionException(func_name='', msg='')[source]

Bases: src.util.exceptions.MDTFBaseException

Exception raised when we attempt to operate on Date or DateRange objects with differing levels of precision, which shouldn’t happen with data sampled at a single frequency.

__init__(func_name='', msg='')[source]

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.FXDateException(func_name='', msg='')[source]

Bases: src.util.exceptions.MDTFBaseException

Exception raised when FXDate or FXDateRange classes, which are placeholder/sentinel classes used to indicate static data with no time dependence, are accessed like real Date or DateRange objects.

__init__(func_name='', msg='')[source]

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.DataRequestError[source]

Bases: src.util.exceptions.MDTFBaseException

Dummy class used for fatal errors that take place during the data query/fetch/preprocess stage of the framework.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.MDTFEvent[source]

Bases: src.util.exceptions.MDTFBaseException

Dummy class to denote non-fatal errors, specifically “events” that are passed during the data query/fetch/preprocess stage of the framework.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.FatalErrorEvent[source]

Bases: src.util.exceptions.MDTFBaseException

Dummy class used to “convert” MDTFEvents to fatal errors (resulting in deactivation of a variable, pod or case.) via exception chaining.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.DataProcessingEvent(msg='', dataset=None)[source]

Bases: src.util.exceptions.MDTFEvent

Base class and common formatting code for events raised in data query/fetch. These should not be used for fatal errors (when a variable or POD is deactivated.)

__init__(msg='', dataset=None)[source]

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.DataQueryEvent(msg='', dataset=None)[source]

Bases: src.util.exceptions.DataProcessingEvent

Exception signaling a failure to find requested data in the remote location.

__init__(msg='', dataset=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.DataExperimentEvent(msg='', dataset=None)[source]

Bases: src.util.exceptions.DataProcessingEvent

Exception signaling a failure to uniquely select an experiment for all variables based on query results.

__init__(msg='', dataset=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.DataFetchEvent(msg='', dataset=None)[source]

Bases: src.util.exceptions.DataProcessingEvent

Exception signaling a failure to obtain data from the remote location.

__init__(msg='', dataset=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.DataPreprocessEvent(msg='', dataset=None)[source]

Bases: src.util.exceptions.DataProcessingEvent

Exception signaling an error in preprocessing data after it’s been fetched, but before any PODs run.

__init__(msg='', dataset=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.MetadataEvent(msg='', dataset=None)[source]

Bases: src.util.exceptions.DataProcessingEvent

Exception signaling discrepancies in variable metadata.

__init__(msg='', dataset=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.MetadataError[source]

Bases: src.util.exceptions.MDTFBaseException

Exception signaling unrecoverable errors in variable metadata.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.UnitsUndefinedError[source]

Bases: src.util.exceptions.MetadataError

Exception signaling unrecoverable errors in variable metadata.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.GenericDataSourceEvent(msg='', dataset=None)[source]

Bases: src.util.exceptions.DataProcessingEvent

Exception signaling a failure originating in the DataSource query/fetch pipeline whose cause doesn’t fall into the above categories.

__init__(msg='', dataset=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.PodExceptionBase(msg=None, pod=None)[source]

Bases: src.util.exceptions.MDTFBaseException

Base class and common formatting code for exceptions affecting a single POD.

__init__(msg=None, pod=None)[source]

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.PodConfigError(msg=None, pod=None)[source]

Bases: src.util.exceptions.PodExceptionBase

Exception raised if we can’t parse info in a POD’s settings.jsonc file. (Covers issues with the file format/schema; malformed JSONC will raise a JSONDecodeError when parse_json() attempts to parse the file.

__init__(msg=None, pod=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.PodConfigEvent[source]

Bases: src.util.exceptions.MDTFEvent

Exception raised during non-fatal events in resolving POD configuration.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.PodDataError(msg=None, pod=None)[source]

Bases: src.util.exceptions.PodExceptionBase

Exception raised if POD doesn’t have required data to run.

__init__(msg=None, pod=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.PodRuntimeError(msg=None, pod=None)[source]

Bases: src.util.exceptions.PodExceptionBase

Exception raised if POD doesn’t have required resources to run.

__init__(msg=None, pod=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception src.util.exceptions.PodExecutionError(msg=None, pod=None)[source]

Bases: src.util.exceptions.PodExceptionBase

Exception raised if POD exits with non-zero retcode or otherwise raises an error during execution.

__init__(msg=None, pod=None)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.