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

29 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-14 02:12 -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 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 

22 

23__all__ = ( 

24 "butler_options", 

25 "coverage_options", 

26 "execution_options", 

27 "meta_info_options", 

28 "pipeline_build_options", 

29 "qgraph_options", 

30 "run_options", 

31) 

32 

33 

34import click 

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

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

37from lsst.daf.butler.cli.opt import transfer_option 

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

39 

40from . import options as ctrlMpExecOpts 

41 

42instrumentOptionHelp = ( 

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

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

45) 

46 

47 

48class pipeline_build_options(OptionGroup): # noqa: N801 

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

50 pipeline. 

51 """ 

52 

53 def __init__(self) -> None: 

54 self.decorators = [ 

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

56 ctrlMpExecOpts.pipeline_option(), 

57 ctrlMpExecOpts.task_option(), 

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

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

60 dafButlerOpts.config_file_option( 

61 help=unwrap( 

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

63 with a given label.""" 

64 ), 

65 metavar="LABEL:FILE", 

66 multiple=True, 

67 ), 

68 ctrlMpExecOpts.order_pipeline_option(), 

69 ctrlMpExecOpts.save_pipeline_option(), 

70 ctrlMpExecOpts.pipeline_dot_option(), 

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

72 ] 

73 

74 

75class coverage_options(OptionGroup): # noqa: N801 

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

77 

78 def __init__(self) -> None: 

79 self.decorators = [ 

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

81 ctrlMpExecOpts.coverage_option(), 

82 ctrlMpExecOpts.coverage_report_option(), 

83 ctrlMpExecOpts.coverage_packages_option(), 

84 ] 

85 

86 

87class qgraph_options(OptionGroup): # noqa: N801 

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

89 graph. 

90 """ 

91 

92 def __init__(self) -> None: 

93 self.decorators = [ 

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

95 ctrlMpExecOpts.qgraph_option(), 

96 ctrlMpExecOpts.qgraph_id_option(), 

97 ctrlMpExecOpts.qgraph_node_id_option(), 

98 ctrlMpExecOpts.qgraph_datastore_records_option(), 

99 ctrlMpExecOpts.skip_existing_in_option(), 

100 ctrlMpExecOpts.skip_existing_option(), 

101 ctrlMpExecOpts.clobber_outputs_option(), 

102 ctrlMpExecOpts.save_qgraph_option(), 

103 ctrlMpExecOpts.save_single_quanta_option(), 

104 ctrlMpExecOpts.qgraph_dot_option(), 

105 ctrlMpExecOpts.save_execution_butler_option(), 

106 ctrlMpExecOpts.clobber_execution_butler_option(), 

107 ctrlMpExecOpts.target_datastore_root_option(), 

108 transfer_option( 

109 help=unwrap( 

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

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

112 """ 

113 ), 

114 ), 

115 ctrlMpExecOpts.dataset_query_constraint(), 

116 ctrlMpExecOpts.qgraph_header_data_option(), 

117 ctrlMpExecOpts.mock_option(), 

118 coverage_options(), 

119 ctrlMpExecOpts.unmocked_dataset_types_option(), 

120 ] 

121 

122 

123class butler_options(OptionGroup): # noqa: N801 

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

125 butler. 

126 """ 

127 

128 def __init__(self) -> None: 

129 self.decorators = [ 

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

131 ctrlMpExecOpts.butler_config_option(required=True), 

132 ctrlMpExecOpts.input_option(), 

133 ctrlMpExecOpts.output_option(), 

134 ctrlMpExecOpts.output_run_option(), 

135 ctrlMpExecOpts.extend_run_option(), 

136 ctrlMpExecOpts.replace_run_option(), 

137 ctrlMpExecOpts.prune_replaced_option(), 

138 ctrlMpExecOpts.data_query_option(), 

139 ] 

140 

141 

142class execution_options(OptionGroup): # noqa: N801 

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

144 pipeline. 

145 """ 

146 

147 def __init__(self) -> None: 

148 self.decorators = [ 

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

150 ctrlMpExecOpts.clobber_outputs_option(), 

151 ctrlMpExecOpts.pdb_option(), 

152 ctrlMpExecOpts.profile_option(), 

153 dafButlerOpts.processes_option(), 

154 ctrlMpExecOpts.start_method_option(), 

155 ctrlMpExecOpts.timeout_option(), 

156 ctrlMpExecOpts.fail_fast_option(), 

157 ctrlMpExecOpts.graph_fixup_option(), 

158 ctrlMpExecOpts.summary_option(), 

159 ctrlMpExecOpts.enable_implicit_threading_option(), 

160 ] 

161 

162 

163class meta_info_options(OptionGroup): # noqa: N801 

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

165 meta information. 

166 """ 

167 

168 def __init__(self) -> None: 

169 self.decorators = [ 

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

171 ctrlMpExecOpts.skip_init_writes_option(), 

172 ctrlMpExecOpts.init_only_option(), 

173 dafButlerOpts.register_dataset_types_option(), 

174 ctrlMpExecOpts.no_versions_option(), 

175 ] 

176 

177 

178class run_options(OptionGroup): # noqa: N801 

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

180 

181 def __init__(self) -> None: 

182 self.decorators = [ 

183 click.pass_context, 

184 ctrlMpExecOpts.debug_option(), 

185 ctrlMpExecOpts.show_option(), 

186 pipeline_build_options(), 

187 qgraph_options(), 

188 butler_options(), 

189 execution_options(), 

190 meta_info_options(), 

191 coverage_options(), 

192 option_section(sectionText=""), 

193 dafButlerOpts.options_file_option(), 

194 ]