Coverage for python/lsst/ctrl/mpexec/cli/script/run_qbb.py: 32%

15 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-05-03 02:51 -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/>. 

27 

28import logging 

29from types import SimpleNamespace 

30 

31from lsst.utils.threads import disable_implicit_threading 

32 

33from ... import CmdLineFwk, TaskFactory 

34 

35_log = logging.getLogger(__name__) 

36 

37 

38def run_qbb( 

39 butler_config: str, 

40 qgraph: str, 

41 config_search_path: list[str] | None, 

42 qgraph_id: str | None, 

43 qgraph_node_id: list[int] | None, 

44 processes: int, 

45 pdb: str | None, 

46 profile: str | None, 

47 debug: bool, 

48 start_method: str | None, 

49 timeout: int | None, 

50 fail_fast: bool, 

51 summary: str | None, 

52 enable_implicit_threading: bool, 

53 cores_per_quantum: int, 

54 memory_per_quantum: str, 

55) -> None: 

56 """Implement the command line interface ``pipetask run-qbb`` subcommand. 

57 

58 Should only be called by command line tools and unit test code that tests 

59 this function. 

60 

61 Parameters 

62 ---------- 

63 butler_config : `str` 

64 The path location of the gen3 butler/registry config file. 

65 qgraph : `str` 

66 URI location for a serialized quantum graph definition. 

67 config_search_path : `list` [`str`] 

68 Additional search paths for butler configuration. 

69 qgraph_id : `str` or `None` 

70 Quantum graph identifier, if specified must match the identifier of the 

71 graph loaded from a file. Ignored if graph is not loaded from a file. 

72 qgraph_node_id : `iterable` of `int`, or `None` 

73 Only load a specified set of nodes if graph is loaded from a file, 

74 nodes are identified by integer IDs. 

75 processes : `int` 

76 The number of processes to use. 

77 pdb : `str` or `None` 

78 Debugger to launch for exceptions. 

79 profile : `str` 

80 File name to dump cProfile information to. 

81 debug : `bool` 

82 If true, enable debugging output using lsstDebug facility (imports 

83 debug.py). 

84 start_method : `str` or `None` 

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

86 one for current platform. 

87 timeout : `int` 

88 Timeout for multiprocessing; maximum wall time (sec). 

89 fail_fast : `bool` 

90 If true then stop processing at first error, otherwise process as many 

91 tasks as possible. 

92 summary : `str` or `None` 

93 File path to store job report in JSON format. 

94 enable_implicit_threading : `bool` 

95 If `True`, do not disable implicit threading by third-party libraries. 

96 Implicit threading is always disabled during actual quantum execution 

97 if ``processes > 1``. 

98 cores_per_quantum : `int` 

99 Number of cores that can be used by each quantum. 

100 memory_per_quantum : `str` 

101 Amount of memory that each quantum can be allowed to use. Empty string 

102 implies no limit. The string can be either a single integer (implying 

103 units of MB) or a combination of number and unit. 

104 """ 

105 # Fork option still exists for compatibility but we use spawn instead. 

106 if start_method == "fork": 

107 start_method = "spawn" 

108 _log.warning("Option --start-method=fork is unsafe and no longer supported, will use spawn instead.") 

109 

110 if not enable_implicit_threading: 

111 disable_implicit_threading() 

112 

113 args = SimpleNamespace( 

114 butler_config=butler_config, 

115 qgraph=qgraph, 

116 config_search_path=config_search_path, 

117 qgraph_id=qgraph_id, 

118 qgraph_node_id=qgraph_node_id, 

119 processes=processes, 

120 pdb=pdb, 

121 profile=profile, 

122 enableLsstDebug=debug, 

123 start_method=start_method, 

124 timeout=timeout, 

125 fail_fast=fail_fast, 

126 summary=summary, 

127 enable_implicit_threading=enable_implicit_threading, 

128 cores_per_quantum=cores_per_quantum, 

129 memory_per_quantum=memory_per_quantum, 

130 ) 

131 

132 f = CmdLineFwk() 

133 task_factory = TaskFactory() 

134 f.runGraphQBB(task_factory, args)