Coverage for python/lsst/ctrl/mpexec/cli/opt/optionGroups.py: 100%

36 statements  

« prev     ^ index     » next       coverage.py v7.15.0, created at 2026-07-09 09:10 +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# (https://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 

29__all__ = ( 

30 "butler_options", 

31 "coverage_options", 

32 "execution_options", 

33 "meta_info_options", 

34 "pipeline_build_options", 

35 "qgraph_options", 

36 "run_options", 

37) 

38 

39 

40import click 

41 

42import lsst.daf.butler.cli.opt as dafButlerOpts 

43import lsst.pipe.base.cli.opt as pipeBaseOpts 

44from lsst.daf.butler.cli.utils import OptionGroup, option_section, unwrap 

45 

46from . import options as ctrlMpExecOpts 

47 

48instrumentOptionHelp = ( 

49 "Add an instrument which will be used to load config overrides when " 

50 "defining a pipeline. This must be the fully qualified class name." 

51) 

52 

53 

54class pipeline_build_options(OptionGroup): # noqa: N801 

55 """Decorator to add options to the command function for building a 

56 pipeline. 

57 

58 Parameters 

59 ---------- 

60 skip_butler_config : `bool`, optional 

61 If `True` the butler configuration option will not be included and will 

62 be assumed to be added explicitly elsewhere. 

63 """ 

64 

65 def __init__(self, skip_butler_config: bool = False) -> None: 

66 self.decorators = [ 

67 option_section(sectionText="Pipeline build options:"), 

68 ctrlMpExecOpts.pipeline_option(), 

69 ctrlMpExecOpts.task_option(), 

70 ctrlMpExecOpts.delete_option(metavar="LABEL"), 

71 dafButlerOpts.config_option(metavar="LABEL:NAME=VALUE", multiple=True), 

72 dafButlerOpts.config_file_option( 

73 help=unwrap( 

74 """Configuration override file(s), applies to a task 

75 with a given label.""" 

76 ), 

77 metavar="LABEL:FILE", 

78 multiple=True, 

79 ), 

80 ctrlMpExecOpts.save_pipeline_option(), 

81 ctrlMpExecOpts.select_tasks_option(), 

82 ctrlMpExecOpts.pipeline_dot_option(), 

83 ctrlMpExecOpts.pipeline_mermaid_option(), 

84 pipeBaseOpts.instrument_option(help=instrumentOptionHelp, metavar="instrument", multiple=True), 

85 ] 

86 if not skip_butler_config: 

87 self.decorators.append(ctrlMpExecOpts.butler_config_option(required=False)) 

88 

89 

90class coverage_options(OptionGroup): # noqa: N801 

91 """Decorator to add options to the command function for test coverage.""" 

92 

93 def __init__(self) -> None: 

94 self.decorators = [ 

95 option_section(sectionText="Coverage options:"), 

96 ctrlMpExecOpts.coverage_option(), 

97 ctrlMpExecOpts.coverage_report_option(), 

98 ctrlMpExecOpts.coverage_packages_option(), 

99 ] 

100 

101 

102class qgraph_options(OptionGroup): # noqa: N801 

103 """Decorator to add options to a command function for creating a quantum 

104 graph. 

105 

106 Parameters 

107 ---------- 

108 skip_coverage : `bool`, optional 

109 If `True` the coverage configuration options will not be included and 

110 will be assumed to be added explicitly elsewhere. 

111 skip_clobber : `bool`, optional 

112 If `True` the clobber configuration option will not be included and 

113 will be assumed to be added explicitly elsewhere. 

114 skip_summary : `bool`, optional 

115 If `True` the summary configuration option will not be included and 

116 will be assumed to be added explicitly elsewhere. 

117 """ 

118 

119 def __init__( 

120 self, skip_coverage: bool = False, skip_clobber: bool = False, skip_summary: bool = False 

121 ) -> None: 

122 self.decorators = [ 

123 option_section(sectionText="Quantum graph building options:"), 

124 ctrlMpExecOpts.qgraph_option(), 

125 ctrlMpExecOpts.qgraph_id_option(), 

126 ctrlMpExecOpts.qgraph_node_id_option(), 

127 ctrlMpExecOpts.qgraph_datastore_records_option(), 

128 ctrlMpExecOpts.skip_existing_in_option(), 

129 ctrlMpExecOpts.skip_existing_option(), 

130 ctrlMpExecOpts.retained_dataset_types_option(), 

131 ctrlMpExecOpts.prune_unanchored_quanta_option(), 

132 ctrlMpExecOpts.save_qgraph_option(), 

133 ctrlMpExecOpts.qgraph_dot_option(), 

134 ctrlMpExecOpts.qgraph_mermaid_option(), 

135 ctrlMpExecOpts.dataset_query_constraint(), 

136 ctrlMpExecOpts.data_id_table_option(), 

137 ctrlMpExecOpts.mock_option(), 

138 ctrlMpExecOpts.mock_failure_option(), 

139 ctrlMpExecOpts.unmocked_dataset_types_option(), 

140 ] 

141 if not skip_clobber: 

142 self.decorators.append(ctrlMpExecOpts.clobber_outputs_option()) 

143 if not skip_summary: 

144 self.decorators.append(ctrlMpExecOpts.summary_option()) 

145 if not skip_coverage: 

146 self.decorators.append(coverage_options()) 

147 

148 

149class butler_options(OptionGroup): # noqa: N801 

150 """Decorator to add options to a command function for configuring a 

151 butler. 

152 """ 

153 

154 def __init__(self) -> None: 

155 self.decorators = [ 

156 option_section(sectionText="Data repository and selection options:"), 

157 ctrlMpExecOpts.butler_config_option(required=True), 

158 ctrlMpExecOpts.input_option(), 

159 ctrlMpExecOpts.output_option(), 

160 ctrlMpExecOpts.output_run_option(), 

161 ctrlMpExecOpts.extend_run_option(), 

162 ctrlMpExecOpts.replace_run_option(), 

163 ctrlMpExecOpts.prune_replaced_option(), 

164 ctrlMpExecOpts.data_query_option(), 

165 ctrlMpExecOpts.rebase_option(), 

166 ] 

167 

168 

169class execution_options(OptionGroup): # noqa: N801 

170 """Decorator to add options to a command function for executing a 

171 pipeline. 

172 """ 

173 

174 def __init__(self) -> None: 

175 self.decorators = [ 

176 option_section(sectionText="Execution options:"), 

177 ctrlMpExecOpts.clobber_outputs_option(), 

178 ctrlMpExecOpts.pdb_option(), 

179 ctrlMpExecOpts.profile_option(), 

180 dafButlerOpts.processes_option(), 

181 ctrlMpExecOpts.start_method_option(), 

182 ctrlMpExecOpts.timeout_option(), 

183 ctrlMpExecOpts.fail_fast_option(), 

184 ctrlMpExecOpts.raise_on_partial_outputs_option(), 

185 ctrlMpExecOpts.graph_fixup_option(), 

186 ctrlMpExecOpts.summary_option(), 

187 ctrlMpExecOpts.enable_implicit_threading_option(), 

188 ctrlMpExecOpts.cores_per_quantum_option(), 

189 ctrlMpExecOpts.memory_per_quantum_option(), 

190 ] 

191 

192 

193class meta_info_options(OptionGroup): # noqa: N801 

194 """Decorator to add options to a command function for managing pipeline 

195 meta information. 

196 """ 

197 

198 def __init__(self) -> None: 

199 self.decorators = [ 

200 option_section(sectionText="Meta-information output options:"), 

201 ctrlMpExecOpts.skip_init_writes_option(), 

202 ctrlMpExecOpts.init_only_option(), 

203 dafButlerOpts.register_dataset_types_option(), 

204 ctrlMpExecOpts.no_versions_option(), 

205 ] 

206 

207 

208class run_options(OptionGroup): # noqa: N801 

209 """Decorator to add the run options to the run command.""" 

210 

211 def __init__(self) -> None: 

212 self.decorators = [ 

213 click.pass_context, 

214 ctrlMpExecOpts.debug_option(), 

215 ctrlMpExecOpts.show_option(), 

216 pipeline_build_options(skip_butler_config=True), 

217 qgraph_options(skip_coverage=True, skip_clobber=True, skip_summary=True), 

218 butler_options(), 

219 execution_options(), 

220 meta_info_options(), 

221 coverage_options(), 

222 option_section(sectionText=""), 

223 dafButlerOpts.options_file_option(), 

224 ]