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

29 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-10 03:29 -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# (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 

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

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

43from lsst.daf.butler.cli.opt import transfer_option_no_short 

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 

59 def __init__(self) -> None: 

60 self.decorators = [ 

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

62 ctrlMpExecOpts.pipeline_option(), 

63 ctrlMpExecOpts.task_option(), 

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

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

66 dafButlerOpts.config_file_option( 

67 help=unwrap( 

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

69 with a given label.""" 

70 ), 

71 metavar="LABEL:FILE", 

72 multiple=True, 

73 ), 

74 ctrlMpExecOpts.order_pipeline_option(), 

75 ctrlMpExecOpts.save_pipeline_option(), 

76 ctrlMpExecOpts.pipeline_dot_option(), 

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

78 ctrlMpExecOpts.butler_config_option(required=False), 

79 ] 

80 

81 

82class coverage_options(OptionGroup): # noqa: N801 

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

84 

85 def __init__(self) -> None: 

86 self.decorators = [ 

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

88 ctrlMpExecOpts.coverage_option(), 

89 ctrlMpExecOpts.coverage_report_option(), 

90 ctrlMpExecOpts.coverage_packages_option(), 

91 ] 

92 

93 

94class qgraph_options(OptionGroup): # noqa: N801 

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

96 graph. 

97 """ 

98 

99 def __init__(self) -> None: 

100 self.decorators = [ 

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

102 ctrlMpExecOpts.qgraph_option(), 

103 ctrlMpExecOpts.qgraph_id_option(), 

104 ctrlMpExecOpts.qgraph_node_id_option(), 

105 ctrlMpExecOpts.qgraph_datastore_records_option(), 

106 ctrlMpExecOpts.skip_existing_in_option(), 

107 ctrlMpExecOpts.skip_existing_option(), 

108 ctrlMpExecOpts.clobber_outputs_option(), 

109 ctrlMpExecOpts.save_qgraph_option(), 

110 ctrlMpExecOpts.save_single_quanta_option(), 

111 ctrlMpExecOpts.qgraph_dot_option(), 

112 ctrlMpExecOpts.save_execution_butler_option(), 

113 ctrlMpExecOpts.clobber_execution_butler_option(), 

114 ctrlMpExecOpts.target_datastore_root_option(), 

115 transfer_option_no_short( 

116 help=unwrap( 

117 """Data transfer mode for the execution butler datastore. 

118 Defaults to "copy" if --target-datastore-root is provided. 

119 """ 

120 ), 

121 ), 

122 ctrlMpExecOpts.dataset_query_constraint(), 

123 ctrlMpExecOpts.qgraph_header_data_option(), 

124 ctrlMpExecOpts.mock_option(), 

125 ctrlMpExecOpts.mock_failure_option(), 

126 ctrlMpExecOpts.unmocked_dataset_types_option(), 

127 coverage_options(), 

128 ] 

129 

130 

131class butler_options(OptionGroup): # noqa: N801 

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

133 butler. 

134 """ 

135 

136 def __init__(self) -> None: 

137 self.decorators = [ 

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

139 ctrlMpExecOpts.butler_config_option(required=True), 

140 ctrlMpExecOpts.input_option(), 

141 ctrlMpExecOpts.output_option(), 

142 ctrlMpExecOpts.output_run_option(), 

143 ctrlMpExecOpts.extend_run_option(), 

144 ctrlMpExecOpts.replace_run_option(), 

145 ctrlMpExecOpts.prune_replaced_option(), 

146 ctrlMpExecOpts.data_query_option(), 

147 ctrlMpExecOpts.rebase_option(), 

148 ] 

149 

150 

151class execution_options(OptionGroup): # noqa: N801 

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

153 pipeline. 

154 """ 

155 

156 def __init__(self) -> None: 

157 self.decorators = [ 

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

159 ctrlMpExecOpts.clobber_outputs_option(), 

160 ctrlMpExecOpts.pdb_option(), 

161 ctrlMpExecOpts.profile_option(), 

162 dafButlerOpts.processes_option(), 

163 ctrlMpExecOpts.start_method_option(), 

164 ctrlMpExecOpts.timeout_option(), 

165 ctrlMpExecOpts.fail_fast_option(), 

166 ctrlMpExecOpts.graph_fixup_option(), 

167 ctrlMpExecOpts.summary_option(), 

168 ctrlMpExecOpts.enable_implicit_threading_option(), 

169 ctrlMpExecOpts.cores_per_quantum_option(), 

170 ctrlMpExecOpts.memory_per_quantum_option(), 

171 ] 

172 

173 

174class meta_info_options(OptionGroup): # noqa: N801 

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

176 meta information. 

177 """ 

178 

179 def __init__(self) -> None: 

180 self.decorators = [ 

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

182 ctrlMpExecOpts.skip_init_writes_option(), 

183 ctrlMpExecOpts.init_only_option(), 

184 dafButlerOpts.register_dataset_types_option(), 

185 ctrlMpExecOpts.no_versions_option(), 

186 ] 

187 

188 

189class run_options(OptionGroup): # noqa: N801 

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

191 

192 def __init__(self) -> None: 

193 self.decorators = [ 

194 click.pass_context, 

195 ctrlMpExecOpts.debug_option(), 

196 ctrlMpExecOpts.show_option(), 

197 pipeline_build_options(), 

198 qgraph_options(), 

199 butler_options(), 

200 execution_options(), 

201 meta_info_options(), 

202 coverage_options(), 

203 option_section(sectionText=""), 

204 dafButlerOpts.options_file_option(), 

205 ]