Coverage for python / lsst / ctrl / mpexec / mpGraphExecutor.py: 76%
37 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-17 16:32 -0800
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-17 16:32 -0800
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 This is a deprecated backwards-compatibility shim for
53 `lsst.pipe.base.mp_graph_executor.MPGraphExecutor`, which has
54 the same functionality with very minor interface changes.
56 Parameters
57 ----------
58 numProc : `int`
59 Number of processes to use for executing tasks.
60 timeout : `float`
61 Time in seconds to wait for tasks to finish.
62 quantumExecutor : `lsst.pipe.base.quantum_graph_executor.QuantumExecutor`
63 Executor for single quantum. For multiprocess-style execution when
64 ``num_proc`` is greater than one this instance must support pickle.
65 startMethod : `str`, optional
66 Start method from `multiprocessing` module, `None` selects the best
67 one for current platform.
68 failFast : `bool`, optional
69 If set to ``True`` then stop processing on first error from any task.
70 pdb : `str`, optional
71 Debugger to import and use (via the ``post_mortem`` function) in the
72 event of an exception.
73 executionGraphFixup : \
74 `lsst.pipe.base.execution_graph_fixup.ExecutionGraphFixup`, \
75 optional
76 Instance used for modification of execution graph.
77 """
79 def __init__(
80 self,
81 numProc: int,
82 timeout: float,
83 quantumExecutor: QuantumExecutor,
84 *,
85 startMethod: Literal["spawn"] | Literal["forkserver"] | None = None,
86 failFast: bool = False,
87 pdb: str | None = None,
88 executionGraphFixup: ExecutionGraphFixup | None = None,
89 ):
90 super().__init__(
91 num_proc=numProc,
92 timeout=timeout,
93 quantum_executor=quantumExecutor,
94 start_method=startMethod,
95 fail_fast=failFast,
96 pdb=pdb,
97 execution_graph_fixup=executionGraphFixup,
98 )
100 @property
101 def numProc(self) -> int:
102 return self._num_proc
104 @property
105 def timeout(self) -> float:
106 return self._timeout
108 @property
109 def quantumExecutor(self) -> QuantumExecutor:
110 return self._quantum_executor
112 @property
113 def failFast(self) -> bool:
114 return self._fail_fast
116 @property
117 def pdb(self) -> str | None:
118 return self._pdb
120 @property
121 def executionGraphFixup(self) -> ExecutionGraphFixup | None:
122 return self._execution_graph_fixup
124 @property
125 def report(self) -> Report | None:
126 return self._report
128 @property
129 def startMethod(self) -> str:
130 return self._start_method
133# We can't make these forwarders warn by subclassing, because an 'except'
134# statement on a derived class won't catch a base class instance.
136MPGraphExecutorError = lsst.pipe.base.mp_graph_executor.MPGraphExecutorError
137MPTimeoutError = lsst.pipe.base.mp_graph_executor.MPTimeoutError