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

7 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-11 02:00 -0700

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 program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22from __future__ import annotations 

23 

24__all__ = ( 

25 "NoWorkFound", 

26 "RepeatableQuantumError", 

27 "InvalidQuantumError", 

28) 

29 

30 

31class NoWorkFound(BaseException): 

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

33 work for it to do. 

34 

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

36 a spatiotemporal overlap that was conservatively predicted does not 

37 actually exist. 

38 

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

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

41 logic to trap it. 

42 """ 

43 

44 

45class RepeatableQuantumError(RuntimeError): 

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

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

48 addressed by retries. 

49 

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

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

52 

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

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

55 

56 try: 

57 run_code() 

58 except SomeOtherError as err: 

59 raise RepeatableQuantumError() from err 

60 

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

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

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

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

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

66 """ 

67 

68 EXIT_CODE = 20 

69 

70 

71class InvalidQuantumError(Exception): 

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

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

74 

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

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

77 

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

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

80 

81 try: 

82 run_code() 

83 except SomeOtherError as err: 

84 raise RepeatableQuantumError() from err 

85 

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

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

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

89 for missing data. 

90 """ 

91 

92 EXIT_CODE = 21