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 installetc.), since we have more sophisticated logging in the framework itself.
- src.util.exceptions.exit_handler(code=1, msg=None)[source]¶
Wraps all calls to
sys.exit(); could do additional cleanup not handled by exit() 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.
- exception src.util.exceptions.TimeoutAlarm[source]¶
Bases:
ExceptionDummy 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:
ExceptionBase 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:
MDTFBaseExceptionException 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:
MDTFBaseExceptionException 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,MDTFBaseExceptionWrapper for
FileNotFoundErrorwhich handles error codes so we don’t have to remember to importerrnoeverywhere.- 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,MDTFBaseExceptionWrapper for
FileExistsErrorwhich handles error codes so we don’t have to remember to importerrnoeverywhere.- 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,MDTFBaseExceptionWrapper 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,MDTFBaseExceptionRaised 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,MDTFBaseExceptionRaised when parsing input data fails on a
mdtf_dataclass()orregex_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,MDTFBaseExceptionRaised 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,MDTFBaseExceptionRaised 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,MDTFBaseExceptionRaised 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:
MDTFBaseExceptionException 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:
MDTFBaseExceptionException raised when we attempt to operate on
DateorDateRangeobjects 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:
MDTFBaseExceptionException raised when
FXDateorFXDateRangeclasses, which are placeholder/sentinel classes used to indicate static data with no time dependence, are accessed like realDateorDateRangeobjects.- 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:
MDTFBaseExceptionDummy 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:
MDTFBaseExceptionDummy 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:
MDTFBaseExceptionDummy class used to “convert” :class:`MDTFEvent`s 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:
MDTFEventBase 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:
DataProcessingEventException 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:
DataProcessingEventException 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:
DataProcessingEventException 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:
DataProcessingEventException 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:
DataProcessingEventException 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:
MDTFBaseExceptionException 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:
MetadataErrorException 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:
DataProcessingEventException 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:
MDTFBaseExceptionException 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:
MDTFBaseExceptionBase 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:
PodExceptionBaseException 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
JSONDecodeErrorwhenparse_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:
MDTFEventException 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:
PodExceptionBaseException 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:
PodExceptionBaseException 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:
PodExceptionBaseException 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.