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 (:py:class:`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 (:py:class:`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.

add_note()

Exception.add_note(note) – add a note to the exception

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.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

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

Bases: MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

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

Bases: MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

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

Bases: FileNotFoundError, MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

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, MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

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: CalledProcessError, MDTFBaseException

Wrapper for subprocess.CalledProcessError.

add_note()

Exception.add_note(note) – add a note to the exception

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, MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.DataclassParseError[source]

Bases: ValueError, MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.RegexParseError[source]

Bases: ValueError, MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.RegexSuppressedError[source]

Bases: ValueError, 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.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.UnitsError[source]

Bases: ValueError, MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

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

Bases: MDTFBaseException

Exception raised by a duplicate variable convention name.

add_note()

Exception.add_note(note) – add a note to the exception

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: 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.

add_note()

Exception.add_note(note) – add a note to the exception

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: 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.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.DataRequestError[source]

Bases: MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.MDTFEvent[source]

Bases: MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.FatalErrorEvent[source]

Bases: MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

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: 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.)

add_note()

Exception.add_note(note) – add a note to the exception

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: DataProcessingEvent

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

add_note()

Exception.add_note(note) – add a note to the exception

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: DataProcessingEvent

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

add_note()

Exception.add_note(note) – add a note to the exception

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: DataProcessingEvent

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

add_note()

Exception.add_note(note) – add a note to the exception

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: DataProcessingEvent

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

add_note()

Exception.add_note(note) – add a note to the exception

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: DataProcessingEvent

Exception signaling discrepancies in variable metadata.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.MetadataError[source]

Bases: MDTFBaseException

Exception signaling unrecoverable errors in variable metadata.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.UnitsUndefinedError[source]

Bases: MetadataError

Exception signaling unrecoverable errors in variable metadata.

add_note()

Exception.add_note(note) – add a note to the exception

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: DataProcessingEvent

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.UnsupportedFileTypeError[source]

Bases: MDTFBaseException

Exception for unsupported file types ingested by the framework

add_note()

Exception.add_note(note) – add a note to the exception

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: MDTFBaseException

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

add_note()

Exception.add_note(note) – add a note to the exception

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: 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.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception src.util.exceptions.PodConfigEvent[source]

Bases: MDTFEvent

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

add_note()

Exception.add_note(note) – add a note to the exception

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: PodExceptionBase

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

add_note()

Exception.add_note(note) – add a note to the exception

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: PodExceptionBase

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

add_note()

Exception.add_note(note) – add a note to the exception

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: PodExceptionBase

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

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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