Coverage for python/lsst/pipe/base/_status.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-01-30 10:50 +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/>. 

27 

28from __future__ import annotations 

29 

30__all__ = ( 

31 "NoWorkFound", 

32 "RepeatableQuantumError", 

33 "InvalidQuantumError", 

34) 

35 

36 

37class NoWorkFound(BaseException): 

38 """An exception raised when a Quantum should not exist because there is no 

39 work for it to do. 

40 

41 This usually occurs because a non-optional input dataset is not present, or 

42 a spatiotemporal overlap that was conservatively predicted does not 

43 actually exist. 

44 

45 This inherits from BaseException because it is used to signal a case that 

46 we don't consider a real error, even though we often want to use try/except 

47 logic to trap it. 

48 """ 

49 

50 

51class RepeatableQuantumError(RuntimeError): 

52 """Exception that may be raised by PipelineTasks (and code they delegate 

53 to) in order to indicate that a repeatable problem that will not be 

54 addressed by retries. 

55 

56 This usually indicates that the algorithm and the data it has been given 

57 are somehow incompatible, and the task should run fine on most other data. 

58 

59 This exception may be used as a base class for more specific questions, or 

60 used directly while chaining another exception, e.g.:: 

61 

62 try: 

63 run_code() 

64 except SomeOtherError as err: 

65 raise RepeatableQuantumError() from err 

66 

67 This may be used for missing input data when the desired behavior is to 

68 cause all downstream tasks being run be blocked, forcing the user to 

69 address the problem. When the desired behavior is to skip all of this 

70 quantum and attempt downstream tasks (or skip them) without its its 

71 outputs, raise `NoWorkFound` or return without raising instead. 

72 """ 

73 

74 EXIT_CODE = 20 

75 

76 

77class InvalidQuantumError(Exception): 

78 """Exception that may be raised by PipelineTasks (and code they delegate 

79 to) in order to indicate logic bug or configuration problem. 

80 

81 This usually indicates that the configured algorithm itself is invalid and 

82 will not run on a significant fraction of quanta (often all of them). 

83 

84 This exception may be used as a base class for more specific questions, or 

85 used directly while chaining another exception, e.g.:: 

86 

87 try: 

88 run_code() 

89 except SomeOtherError as err: 

90 raise RepeatableQuantumError() from err 

91 

92 Raising this exception in `PipelineTask.runQuantum` or something it calls 

93 is a last resort - whenever possible, such problems should cause exceptions 

94 in ``__init__`` or in QuantumGraph generation. It should never be used 

95 for missing data. 

96 """ 

97 

98 EXIT_CODE = 21