Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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 

22import click 

23 

24from lsst.daf.butler.cli.utils import MWOptionDecorator, MWPath, split_commas, unwrap 

25 

26 

27butler_config_option = MWOptionDecorator("-b", "--butler-config", 

28 help="Location of the gen3 butler/registry config file.", 

29 type=MWPath(dir_okay=False, file_okay=True, readable=True)) 

30 

31 

32data_query_option = MWOptionDecorator("-d", "--data-query", 

33 help="User data selection expression.", 

34 metavar="QUERY") 

35 

36 

37debug_option = MWOptionDecorator("--debug", 

38 help="Enable debugging output using lsstDebug facility (imports debug.py).") 

39 

40 

41delete_option = MWOptionDecorator("--delete", 

42 callback=split_commas, 

43 help="Delete task with given label from pipeline.", 

44 multiple=True) 

45 

46 

47do_raise_option = MWOptionDecorator("--do-raise", 

48 help="Raise an exception on error. (else log a message and continue?)", 

49 is_flag=True) 

50 

51 

52extend_run_option = MWOptionDecorator("--extend-run", 

53 help=unwrap("""Instead of creating a new RUN collection, insert datasets 

54 into either the one given by --output-run (if provided) or 

55 the first child collection of - -output(which must be of 

56 type RUN)."""), 

57 is_flag=True) 

58 

59 

60graph_fixup_option = MWOptionDecorator("--graph-fixup", 

61 help=unwrap("""Name of the class or factory method which makes an 

62 instance used for execution graph fixup.""")) 

63 

64 

65init_only_option = MWOptionDecorator("--init-only", 

66 help=unwrap("""Do not actually run; just register dataset types and/or 

67 save init outputs. """), 

68 is_flag=True) 

69 

70 

71# TODO defaultMetavar and defaultHelp both match with the handling 

72# specified by the input_option callback defined in commands.py. Should 

73# that callback definition get moved here? Should these defaults be made 

74# less use-case specific and moved to commands.py? Is it ok as is? 

75input_option = MWOptionDecorator("--input", 

76 callback=split_commas, 

77 default=list(), 

78 help=unwrap("""Comma-separated names of the input collection(s). Entries may 

79 include a colon (:), the first string is a dataset type name that 

80 restricts the search in that collection."""), 

81 metavar="COLL,DSTYPE:COLL", 

82 multiple=True) 

83 

84no_versions_option = MWOptionDecorator("--no-versions", 

85 help="Do not save or check package versions.", 

86 is_flag=True) 

87 

88 

89order_pipeline_option = MWOptionDecorator("--order-pipeline", 

90 help=unwrap("""Order tasks in pipeline based on their data 

91 dependencies, ordering is performed as last step before saving or 

92 executing pipeline."""), 

93 is_flag=True) 

94 

95 

96output_option = MWOptionDecorator("-o", "--output", 

97 help=unwrap(f"""Name of the output CHAINED collection. This may either be an 

98 existing CHAINED collection to use as both input and output 

99 (incompatible with --input), or a new CHAINED collection created 

100 to include all inputs (requires --input). In both cases, the 

101 collection's children will start with an output RUN collection 

102 that directly holds all new datasets (see --output-run)."""), 

103 metavar="COLL") 

104 

105 

106output_run_option = MWOptionDecorator("--output-run", 

107 help=unwrap("""Name of the new output RUN collection. If not provided 

108 then --output must be provided and a new RUN collection will 

109 be created by appending a timestamp to the value passed with 

110 --output. If this collection already exists then 

111 --extend-run must be passed."""), 

112 metavar="COLL") 

113 

114 

115pipeline_option = MWOptionDecorator("-p", "--pipeline", 

116 help="Location of a pipeline definition file in YAML format.", 

117 type=MWPath(exists=True, file_okay=True, dir_okay=False, readable=True)) 

118 

119 

120pipeline_dot_option = MWOptionDecorator("--pipeline-dot", 

121 help=unwrap(""""Location for storing GraphViz DOT representation of a 

122 pipeline."""), 

123 type=MWPath(writable=True, file_okay=True, dir_okay=False)) 

124 

125 

126processes_option = MWOptionDecorator("-j", "--processes", 

127 help="Number of processes to use.", 

128 type=click.IntRange(min=1)) 

129 

130 

131profile_option = MWOptionDecorator("--profile", 

132 help="Dump cProfile statistics to file name.", 

133 type=MWPath(file_okay=True, dir_okay=False)) 

134 

135 

136prune_replaced_option = MWOptionDecorator("--prune-replaced", 

137 help=unwrap("""Delete the datasets in the collection replaced by 

138 --replace-run, either just from the datastore 

139 ('unstore') or by removing them and the RUN completely 

140 ('purge'). Requires --replace-run."""), 

141 type=click.Choice(("unstore", "purge"), case_sensitive=False)) 

142 

143 

144qgraph_option = MWOptionDecorator("-g", "--qgraph", 

145 help=unwrap("""Location for a serialized quantum graph definition (pickle 

146 file). If this option is given then all input data options and 

147 pipeline-building options cannot be used."""), 

148 type=MWPath(exists=True, file_okay=True, dir_okay=False, readable=True)) 

149 

150 

151qgraph_dot_option = MWOptionDecorator("--qgraph-dot", 

152 help=unwrap("""Location for storing GraphViz DOT representation of a 

153 quantum graph."""), 

154 type=MWPath(writable=True, file_okay=True, dir_okay=False)) 

155 

156 

157register_dataset_types_option = MWOptionDecorator("--register-dataset-types", 

158 help=unwrap("""Register DatasetTypes that do not already 

159 exist in the Registry."""), 

160 is_flag=True) 

161 

162 

163replace_run_option = MWOptionDecorator("--replace-run", 

164 help=unwrap(f"""Before creating a new RUN collection in an existing 

165 CHAINED collection, remove the first child collection 

166 (which must be of type RUN). This can be used to repeatedly 

167 write to the same (parent) collection during development, 

168 but it does not delete the datasets associated with the 

169 replaced run unless --prune-replaced is also passed. 

170 Requires --output, and incompatible with --extend-run."""), 

171 is_flag=True) 

172 

173 

174save_pipeline_option = MWOptionDecorator("-s", "--save-pipeline", 

175 help=unwrap("""Location for storing resulting pipeline definition in 

176 YAML format."""), 

177 type=MWPath(dir_okay=False, file_okay=True, writable=True)) 

178 

179save_qgraph_option = MWOptionDecorator("-q", "--save-qgraph", 

180 help=unwrap("""Location for storing a serialized quantum graph 

181 definition (pickle file)."""), 

182 type=MWPath(file_okay=True, dir_okay=False, readable=True)) 

183 

184 

185save_single_quanta_option = MWOptionDecorator("--save-single-quanta", 

186 help=unwrap("""Format string of locations for storing individual 

187 quantum graph definition (pickle files). The curly 

188 brace {} in the input string will be replaced by a 

189 quantum number.""")) 

190 

191 

192show_option = MWOptionDecorator("--show", 

193 callback=split_commas, 

194 help=unwrap("""Dump various info to standard output. Possible items are: 

195 `config`, `config=[Task::]<PATTERN>` or 

196 `config=[Task::]<PATTERN>:NOIGNORECASE` to dump configuration 

197 fields possibly matching given pattern and/or task label; 

198 `history=<FIELD>` to dump configuration history for a field, field 

199 name is specified as [Task::][SubTask.]Field; `dump-config`, 

200 `dump-config=Task` to dump complete configuration for a task given 

201 its label or all tasks; `pipeline` to show pipeline composition; 

202 `graph` to show information about quanta; `workflow` to show 

203 information about quanta and their dependency; `tasks` to show 

204 task composition."""), 

205 metavar="ITEM|ITEM=VALUE", 

206 multiple=True) 

207 

208 

209skip_existing_option = MWOptionDecorator("--skip-existing", 

210 help=unwrap("""If all Quantum outputs already exist in the output RUN 

211 collection then that Quantum will be excluded from the 

212 QuantumGraph. Requires the 'run` command's `--extend-run` 

213 flag to be set."""), 

214 is_flag=True) 

215 

216 

217skip_init_writes_option = MWOptionDecorator("--skip-init-writes", 

218 help=unwrap("""Do not write collection-wide 'init output' datasets 

219 (e.g.schemas)."""), 

220 is_flag=True) 

221 

222 

223task_option = MWOptionDecorator("-t", "--task", 

224 callback=split_commas, 

225 help=unwrap("""Task name to add to pipeline, must be a fully qualified task 

226 name. Task name can be followed by colon and label name, if label 

227 is not given then task base name (class name) is used as 

228 label."""), 

229 metavar="TASK[:LABEL]", 

230 multiple=True) 

231 

232 

233timeout_option = MWOptionDecorator("--timeout", 

234 help="Timeout for multiprocessing; maximum wall time (sec).") 

235 

236fail_fast_option = MWOptionDecorator("--fail-fast", 

237 help=unwrap("""Stop processing at first error, default is to process 

238 as many tasks as possible."""), 

239 is_flag=True)