Coverage for python / lsst / ctrl / mpexec / mpGraphExecutor.py: 76%

37 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-06 08:32 +0000

1# This file is part of ctrl_mpexec. 

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 

28__all__ = ("MPGraphExecutor", "MPGraphExecutorError", "MPTimeoutError") 

29 

30from typing import Literal 

31 

32from deprecated.sphinx import deprecated 

33 

34import lsst.pipe.base.mp_graph_executor 

35from lsst.pipe.base.execution_graph_fixup import ExecutionGraphFixup 

36from lsst.pipe.base.quantum_graph_executor import QuantumExecutor 

37from lsst.pipe.base.quantum_reports import Report 

38 

39# TODO[DM-51962]: Remove this module. 

40 

41 

42@deprecated( 

43 "The MPGraphExecutor class has moved to lsst.pipe.base.mp_graph_executor. " 

44 "This forwarding shim will be removed after v30.", 

45 version="v30", 

46 category=FutureWarning, 

47) 

48class MPGraphExecutor(lsst.pipe.base.mp_graph_executor.MPGraphExecutor): 

49 """Implementation of QuantumGraphExecutor using same-host multiprocess 

50 execution of Quanta. 

51 

52 Parameters 

53 ---------- 

54 numProc : `int` 

55 Number of processes to use for executing tasks. 

56 timeout : `float` 

57 Time in seconds to wait for tasks to finish. 

58 quantumExecutor : `lsst.pipe.base.quantum_graph_executor.QuantumExecutor` 

59 Executor for single quantum. For multiprocess-style execution when 

60 ``num_proc`` is greater than one this instance must support pickle. 

61 startMethod : `str`, optional 

62 Start method from `multiprocessing` module, `None` selects the best 

63 one for current platform. 

64 failFast : `bool`, optional 

65 If set to ``True`` then stop processing on first error from any task. 

66 pdb : `str`, optional 

67 Debugger to import and use (via the ``post_mortem`` function) in the 

68 event of an exception. 

69 executionGraphFixup : \ 

70 `lsst.pipe.base.execution_graph_fixup.ExecutionGraphFixup`, \ 

71 optional 

72 Instance used for modification of execution graph. 

73 

74 Notes 

75 ----- 

76 This is a deprecated backwards-compatibility shim for 

77 `lsst.pipe.base.mp_graph_executor.MPGraphExecutor`, which has 

78 the same functionality with very minor interface changes. 

79 

80 """ 

81 

82 def __init__( 

83 self, 

84 numProc: int, 

85 timeout: float, 

86 quantumExecutor: QuantumExecutor, 

87 *, 

88 startMethod: Literal["spawn"] | Literal["forkserver"] | None = None, 

89 failFast: bool = False, 

90 pdb: str | None = None, 

91 executionGraphFixup: ExecutionGraphFixup | None = None, 

92 ): 

93 super().__init__( 

94 num_proc=numProc, 

95 timeout=timeout, 

96 quantum_executor=quantumExecutor, 

97 start_method=startMethod, 

98 fail_fast=failFast, 

99 pdb=pdb, 

100 execution_graph_fixup=executionGraphFixup, 

101 ) 

102 

103 @property 

104 def numProc(self) -> int: 

105 return self._num_proc 

106 

107 @property 

108 def timeout(self) -> float: 

109 return self._timeout 

110 

111 @property 

112 def quantumExecutor(self) -> QuantumExecutor: 

113 return self._quantum_executor 

114 

115 @property 

116 def failFast(self) -> bool: 

117 return self._fail_fast 

118 

119 @property 

120 def pdb(self) -> str | None: 

121 return self._pdb 

122 

123 @property 

124 def executionGraphFixup(self) -> ExecutionGraphFixup | None: 

125 return self._execution_graph_fixup 

126 

127 @property 

128 def report(self) -> Report | None: 

129 return self._report 

130 

131 @property 

132 def startMethod(self) -> str: 

133 return self._start_method 

134 

135 

136# We can't make these forwarders warn by subclassing, because an 'except' 

137# statement on a derived class won't catch a base class instance. 

138 

139MPGraphExecutorError = lsst.pipe.base.mp_graph_executor.MPGraphExecutorError 

140MPTimeoutError = lsst.pipe.base.mp_graph_executor.MPTimeoutError