Coverage for python/lsst/pipe/base/_status.py: 100%
11 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-02-28 11:04 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-02-28 11:04 +0000
1# This file is part of pipe_base.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This software is dual licensed under the GNU General Public License and also
10# under a 3-clause BSD license. Recipients may choose which of these licenses
11# to use; please see the files gpl-3.0.txt and/or bsd_license.txt,
12# respectively. If you choose the GPL option then the following text applies
13# (but note that there is still no warranty even if you opt for BSD instead):
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation, either version 3 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
28from __future__ import annotations
30__all__ = (
31 "NoWorkFound",
32 "RepeatableQuantumError",
33 "InvalidQuantumError",
34)
36from typing import Protocol
38from ._task_metadata import GetSetDictMetadata
41class GetSetDictMetadataHolder(Protocol):
42 """Protocol for objects that have a ``metadata`` attribute that satisfies
43 `GetSetDictMetadata`.
44 """
46 metadata: GetSetDictMetadata | None
49class NoWorkFound(BaseException):
50 """An exception raised when a Quantum should not exist because there is no
51 work for it to do.
53 This usually occurs because a non-optional input dataset is not present, or
54 a spatiotemporal overlap that was conservatively predicted does not
55 actually exist.
57 This inherits from BaseException because it is used to signal a case that
58 we don't consider a real error, even though we often want to use try/except
59 logic to trap it.
60 """
63class RepeatableQuantumError(RuntimeError):
64 """Exception that may be raised by PipelineTasks (and code they delegate
65 to) in order to indicate that a repeatable problem that will not be
66 addressed by retries.
68 This usually indicates that the algorithm and the data it has been given
69 are somehow incompatible, and the task should run fine on most other data.
71 This exception may be used as a base class for more specific questions, or
72 used directly while chaining another exception, e.g.::
74 try:
75 run_code()
76 except SomeOtherError as err:
77 raise RepeatableQuantumError() from err
79 This may be used for missing input data when the desired behavior is to
80 cause all downstream tasks being run be blocked, forcing the user to
81 address the problem. When the desired behavior is to skip all of this
82 quantum and attempt downstream tasks (or skip them) without its its
83 outputs, raise `NoWorkFound` or return without raising instead.
84 """
86 EXIT_CODE = 20
89class InvalidQuantumError(Exception):
90 """Exception that may be raised by PipelineTasks (and code they delegate
91 to) in order to indicate logic bug or configuration problem.
93 This usually indicates that the configured algorithm itself is invalid and
94 will not run on a significant fraction of quanta (often all of them).
96 This exception may be used as a base class for more specific questions, or
97 used directly while chaining another exception, e.g.::
99 try:
100 run_code()
101 except SomeOtherError as err:
102 raise RepeatableQuantumError() from err
104 Raising this exception in `PipelineTask.runQuantum` or something it calls
105 is a last resort - whenever possible, such problems should cause exceptions
106 in ``__init__`` or in QuantumGraph generation. It should never be used
107 for missing data.
108 """
110 EXIT_CODE = 21