Coverage for python/lsst/ctrl/mpexec/mpGraphExecutor.py: 76%
37 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-16 15:01 -0700
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-16 15:01 -0700
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/>.
28__all__ = ("MPGraphExecutor", "MPGraphExecutorError", "MPTimeoutError")
30from typing import Literal
32from deprecated.sphinx import deprecated
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
39# TODO[DM-51962]: Remove this module.
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.
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.
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 """
81 def __init__(
82 self,
83 numProc: int,
84 timeout: float,
85 quantumExecutor: QuantumExecutor,
86 *,
87 startMethod: Literal["spawn"] | Literal["forkserver"] | None = None,
88 failFast: bool = False,
89 pdb: str | None = None,
90 executionGraphFixup: ExecutionGraphFixup | None = None,
91 ):
92 super().__init__(
93 num_proc=numProc,
94 timeout=timeout,
95 quantum_executor=quantumExecutor,
96 start_method=startMethod,
97 fail_fast=failFast,
98 pdb=pdb,
99 execution_graph_fixup=executionGraphFixup,
100 )
102 @property
103 def numProc(self) -> int:
104 return self._num_proc
106 @property
107 def timeout(self) -> float:
108 return self._timeout
110 @property
111 def quantumExecutor(self) -> QuantumExecutor:
112 return self._quantum_executor
114 @property
115 def failFast(self) -> bool:
116 return self._fail_fast
118 @property
119 def pdb(self) -> str | None:
120 return self._pdb
122 @property
123 def executionGraphFixup(self) -> ExecutionGraphFixup | None:
124 return self._execution_graph_fixup
126 @property
127 def report(self) -> Report | None:
128 return self._report
130 @property
131 def startMethod(self) -> str:
132 return self._start_method
135# We can't make these forwarders warn by subclassing, because an 'except'
136# statement on a derived class won't catch a base class instance.
138MPGraphExecutorError = lsst.pipe.base.mp_graph_executor.MPGraphExecutorError
139MPTimeoutError = lsst.pipe.base.mp_graph_executor.MPTimeoutError