Coverage for python/lsst/ctrl/mpexec/cli/script/run.py: 38%

11 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-05 10:47 +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 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 

22import logging 

23from types import SimpleNamespace 

24 

25from ... import CmdLineFwk, TaskFactory 

26 

27_log = logging.getLogger(__name__) 

28 

29 

30def run( # type: ignore 

31 pdb, 

32 graph_fixup, 

33 init_only, 

34 no_versions, 

35 processes, 

36 start_method, 

37 profile, 

38 qgraphObj, 

39 register_dataset_types, 

40 skip_init_writes, 

41 timeout, 

42 butler_config, 

43 input, 

44 output, 

45 output_run, 

46 extend_run, 

47 replace_run, 

48 prune_replaced, 

49 data_query, 

50 skip_existing_in, 

51 skip_existing, 

52 debug, 

53 fail_fast, 

54 clobber_outputs, 

55 summary, 

56 mock, 

57 mock_configs, 

58 enable_implicit_threading, 

59 **kwargs, 

60): 

61 """Implements the command line interface `pipetask run` subcommand, should 

62 only be called by command line tools and unit test code that test this 

63 function. 

64 

65 Parameters 

66 ---------- 

67 pdb : `bool` 

68 Drop into pdb on exception? 

69 graph_fixup : `str` 

70 The name of the class or factory method which makes an instance used 

71 for execution graph fixup. 

72 init_only : `bool` 

73 If true, do not actually run; just register dataset types and/or save 

74 init outputs. 

75 no_versions : `bool` 

76 If true, do not save or check package versions. 

77 processes : `int` 

78 The number of processes to use. 

79 start_method : `str` or `None` 

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

81 one for current platform. 

82 profile : `str` 

83 File name to dump cProfile information to. 

84 qgraphObj : `lsst.pipe.base.QuantumGraph` 

85 A QuantumGraph generated by a previous subcommand. 

86 register_dataset_types : `bool` 

87 If true, register DatasetTypes that do not already exist in the 

88 Registry. 

89 skip_init_writes : `bool` 

90 If true, do not write collection-wide 'init output' datasets (e.g. 

91 schemas). 

92 timeout : `int` 

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

94 butler_config : `str`, `dict`, or `lsst.daf.butler.Config` 

95 If `str`, `butler_config` is the path location of the gen3 

96 butler/registry config file. If `dict`, `butler_config` is key value 

97 pairs used to init or update the `lsst.daf.butler.Config` instance. If 

98 `Config`, it is the object used to configure a Butler. 

99 input : `list` [ `str` ] 

100 List of names of the input collection(s). 

101 output : `str` 

102 Name of the output CHAINED collection. This may either be an existing 

103 CHAINED collection to use as both input and output (if `input` is 

104 `None`), or a new CHAINED collection created to include all inputs 

105 (if `input` is not `None`). In both cases, the collection's children 

106 will start with an output RUN collection that directly holds all new 

107 datasets (see `output_run`). 

108 output_run : `str` 

109 Name of the new output RUN collection. If not provided then `output` 

110 must be provided and a new RUN collection will be created by appending 

111 a timestamp to the value passed with `output`. If this collection 

112 already exists then `extend_run` must be passed. 

113 extend_run : `bool` 

114 Instead of creating a new RUN collection, insert datasets into either 

115 the one given by `output_run` (if provided) or the first child 

116 collection of `output` (which must be of type RUN). 

117 replace_run : `bool` 

118 Before creating a new RUN collection in an existing CHAINED collection, 

119 remove the first child collection (which must be of type RUN). This can 

120 be used to repeatedly write to the same (parent) collection during 

121 development, but it does not delete the datasets associated with the 

122 replaced run unless `prune-replaced` is also True. Requires `output`, 

123 and `extend_run` must be `None`. 

124 prune_replaced : "unstore", "purge", or `None`. 

125 If not `None`, delete the datasets in the collection replaced by 

126 `replace_run`, either just from the datastore ("unstore") or by 

127 removing them and the RUN completely ("purge"). Requires `replace_run`. 

128 data_query : `str` 

129 User query selection expression. 

130 skip_existing_in : `list` [ `str` ] 

131 Accepts list of collections, if all Quantum outputs already exist in 

132 the specified list of collections then that Quantum will be excluded 

133 from the QuantumGraph. 

134 skip_existing : `bool` 

135 Appends output RUN collection to the ``skip_existing_in`` list. 

136 debug : `bool` 

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

138 debug.py). 

139 fail_fast : `bool` 

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

141 tasks as possible. 

142 clobber_outputs : `bool` 

143 Remove outputs from previous execution of the same quantum before new 

144 execution. Only applies to failed quanta if skip_existing is also 

145 given. 

146 summary : `str` 

147 File path to store job report in JSON format. 

148 mock : `bool`, optional 

149 If `True` then run mock pipeline instead of real one. 

150 mock_configs : `list` [ `PipelineAction` ] 

151 A list of config overrides for mock tasks. 

152 enable_implicit_threading : `bool`, optional 

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

154 Implicit threading is always disabled during actual quantum execution 

155 if ``processes > 1``. 

156 kwargs : `dict` [`str`, `str`] 

157 Ignored; click commands may accept options for more than one script 

158 function and pass all the option kwargs to each of the script functions 

159 which ignore these unused kwargs. 

160 """ 

161 args = SimpleNamespace( 

162 pdb=pdb, 

163 graph_fixup=graph_fixup, 

164 init_only=init_only, 

165 no_versions=no_versions, 

166 processes=processes, 

167 start_method=start_method, 

168 profile=profile, 

169 skip_init_writes=skip_init_writes, 

170 timeout=timeout, 

171 register_dataset_types=register_dataset_types, 

172 butler_config=butler_config, 

173 input=input, 

174 output=output, 

175 output_run=output_run, 

176 extend_run=extend_run, 

177 replace_run=replace_run, 

178 prune_replaced=prune_replaced, 

179 data_query=data_query, 

180 skip_existing_in=skip_existing_in, 

181 skip_existing=skip_existing, 

182 enableLsstDebug=debug, 

183 fail_fast=fail_fast, 

184 clobber_outputs=clobber_outputs, 

185 summary=summary, 

186 mock=mock, 

187 mock_configs=mock_configs, 

188 enable_implicit_threading=enable_implicit_threading, 

189 ) 

190 

191 f = CmdLineFwk() 

192 taskFactory = TaskFactory() 

193 

194 # If we have no output run specified, use the one from the graph rather 

195 # than letting a new timestamped run be created. 

196 if not args.output_run and qgraphObj.metadata and (output_run := qgraphObj.metadata.get("output_run")): 

197 args.output_run = output_run 

198 

199 f.runPipeline(qgraphObj, taskFactory, args)