Coverage for python/lsst/ctrl/mpexec/cli/opt/options.py: 100%
45 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-10-07 03:02 -0700
« prev ^ index » next coverage.py v6.5.0, created at 2022-10-07 03:02 -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/>.
22import click
23from lsst.daf.butler.cli.utils import MWOptionDecorator, MWPath, split_commas, unwrap
25butler_config_option = MWOptionDecorator(
26 "-b", "--butler-config", help="Location of the gen3 butler/registry config file."
27)
30data_query_option = MWOptionDecorator(
31 "-d", "--data-query", help="User data selection expression.", metavar="QUERY"
32)
35debug_option = MWOptionDecorator(
36 "--debug", help="Enable debugging output using lsstDebug facility (imports debug.py).", is_flag=True
37)
40delete_option = MWOptionDecorator(
41 "--delete", callback=split_commas, help="Delete task with given label from pipeline.", multiple=True
42)
45pdb_option = MWOptionDecorator(
46 "--pdb",
47 help="Post-mortem debugger to launch for exceptions (defaults to pdb if unspecified; requires a tty).",
48 is_flag=False,
49 flag_value="pdb",
50 default=None,
51)
54extend_run_option = MWOptionDecorator(
55 "--extend-run",
56 help=unwrap(
57 """Instead of creating a new RUN collection, insert datasets
58 into either the one given by --output-run (if provided) or
59 the first child collection of --output (which must be of
60 type RUN). This also enables --skip-existing option."""
61 ),
62 is_flag=True,
63)
66graph_fixup_option = MWOptionDecorator(
67 "--graph-fixup",
68 help=unwrap(
69 """Name of the class or factory method which makes an
70 instance used for execution graph fixup."""
71 ),
72)
75init_only_option = MWOptionDecorator(
76 "--init-only",
77 help=unwrap(
78 """Do not actually run; just register dataset types and/or
79 save init outputs. """
80 ),
81 is_flag=True,
82)
85input_option = MWOptionDecorator(
86 "-i",
87 "--input",
88 callback=split_commas,
89 default=list(),
90 help=unwrap("""Comma-separated names of the input collection(s)."""),
91 metavar="COLLECTION",
92 multiple=True,
93)
95no_versions_option = MWOptionDecorator(
96 "--no-versions", help="Do not save or check package versions.", is_flag=True
97)
100order_pipeline_option = MWOptionDecorator(
101 "--order-pipeline",
102 help=unwrap(
103 """Order tasks in pipeline based on their data
104 dependencies, ordering is performed as last step before saving or
105 executing pipeline."""
106 ),
107 is_flag=True,
108)
111output_option = MWOptionDecorator(
112 "-o",
113 "--output",
114 help=unwrap(
115 """Name of the output CHAINED collection. This may either be an
116 existing CHAINED collection to use as both input and output
117 (incompatible with --input), or a new CHAINED collection created
118 to include all inputs (requires --input). In both cases, the
119 collection's children will start with an output RUN collection
120 that directly holds all new datasets (see --output-run)."""
121 ),
122 metavar="COLL",
123)
126output_run_option = MWOptionDecorator(
127 "--output-run",
128 help=unwrap(
129 """Name of the new output RUN collection. If not provided
130 then --output must be provided and a new RUN collection will
131 be created by appending a timestamp to the value passed with
132 --output. If this collection already exists then
133 --extend-run must be passed."""
134 ),
135 metavar="COLL",
136)
139pipeline_option = MWOptionDecorator(
140 "-p",
141 "--pipeline",
142 help="Location of a pipeline definition file in YAML format.",
143 type=MWPath(file_okay=True, dir_okay=False, readable=True),
144)
147pipeline_dot_option = MWOptionDecorator(
148 "--pipeline-dot",
149 help=unwrap(
150 """"Location for storing GraphViz DOT representation of a
151 pipeline."""
152 ),
153 type=MWPath(writable=True, file_okay=True, dir_okay=False),
154)
157profile_option = MWOptionDecorator(
158 "--profile", help="Dump cProfile statistics to file name.", type=MWPath(file_okay=True, dir_okay=False)
159)
162prune_replaced_option = MWOptionDecorator(
163 "--prune-replaced",
164 help=unwrap(
165 """Delete the datasets in the collection replaced by
166 --replace-run, either just from the datastore
167 ('unstore') or by removing them and the RUN completely
168 ('purge'). Requires --replace-run."""
169 ),
170 type=click.Choice(choices=("unstore", "purge"), case_sensitive=False),
171)
174qgraph_option = MWOptionDecorator(
175 "-g",
176 "--qgraph",
177 help=unwrap(
178 """Location for a serialized quantum graph definition (pickle
179 file). If this option is given then all input data options and
180 pipeline-building options cannot be used. Can be a URI."""
181 ),
182)
185qgraph_id_option = MWOptionDecorator(
186 "--qgraph-id",
187 help=unwrap(
188 """Quantum graph identifier, if specified must match the
189 identifier of the graph loaded from a file. Ignored if graph
190 is not loaded from a file."""
191 ),
192)
195qgraph_datastore_records_option = MWOptionDecorator(
196 "--qgraph-datastore-records",
197 help=unwrap(
198 """Include datastore records into generated quantum graph, these records are used by a
199 quantum-backed butler.
200 """
201 ),
202 is_flag=True,
203)
206# I wanted to use default=None here to match Python API but click silently
207# replaces None with an empty tuple when multiple=True.
208qgraph_node_id_option = MWOptionDecorator(
209 "--qgraph-node-id",
210 callback=split_commas,
211 multiple=True,
212 help=unwrap(
213 """Only load a specified set of nodes when graph is
214 loaded from a file, nodes are identified by UUID
215 values. One or more comma-separated integers are
216 accepted. By default all nodes are loaded. Ignored if
217 graph is not loaded from a file."""
218 ),
219)
221qgraph_header_data_option = MWOptionDecorator(
222 "--show-qgraph-header",
223 is_flag=True,
224 default=False,
225 help=unwrap(
226 """Print the headerData for Quantum Graph to the
227 console"""
228 ),
229)
231qgraph_dot_option = MWOptionDecorator(
232 "--qgraph-dot",
233 help=unwrap(
234 """Location for storing GraphViz DOT representation of a
235 quantum graph."""
236 ),
237 type=MWPath(writable=True, file_okay=True, dir_okay=False),
238)
241replace_run_option = MWOptionDecorator(
242 "--replace-run",
243 help=unwrap(
244 """Before creating a new RUN collection in an existing
245 CHAINED collection, remove the first child collection
246 (which must be of type RUN). This can be used to repeatedly
247 write to the same (parent) collection during development,
248 but it does not delete the datasets associated with the
249 replaced run unless --prune-replaced is also passed.
250 Requires --output, and incompatible with --extend-run."""
251 ),
252 is_flag=True,
253)
256save_pipeline_option = MWOptionDecorator(
257 "-s",
258 "--save-pipeline",
259 help=unwrap(
260 """Location for storing resulting pipeline definition in
261 YAML format."""
262 ),
263 type=MWPath(dir_okay=False, file_okay=True, writable=True),
264)
266save_qgraph_option = MWOptionDecorator(
267 "-q",
268 "--save-qgraph",
269 help=unwrap(
270 """URI location for storing a serialized quantum graph
271 definition (pickle file)."""
272 ),
273)
276save_single_quanta_option = MWOptionDecorator(
277 "--save-single-quanta",
278 help=unwrap(
279 """Format string of locations for storing individual
280 quantum graph definition (pickle files). The curly
281 brace {} in the input string will be replaced by a
282 quantum number. Can be a URI."""
283 ),
284)
287show_option = MWOptionDecorator(
288 "--show",
289 callback=split_commas,
290 help=unwrap(
291 """Dump various info to standard output. Possible items are:
292 `config`, `config=[Task::]<PATTERN>` or
293 `config=[Task::]<PATTERN>:NOIGNORECASE` to dump configuration
294 fields possibly matching given pattern and/or task label;
295 `history=<FIELD>` to dump configuration history for a field, field
296 name is specified as [Task::]<PATTERN>; `dump-config`,
297 `dump-config=Task` to dump complete configuration for a task given
298 its label or all tasks; `pipeline` to show pipeline composition;
299 `graph` to show information about quanta; `workflow` to show
300 information about quanta and their dependency; `tasks` to show
301 task composition; `uri` to show predicted dataset URIs of
302 quanta"""
303 ),
304 metavar="ITEM|ITEM=VALUE",
305 multiple=True,
306)
309skip_existing_in_option = MWOptionDecorator(
310 "--skip-existing-in",
311 callback=split_commas,
312 default=None,
313 metavar="COLLECTION",
314 multiple=True,
315 help=unwrap(
316 """If all Quantum outputs already exist in the specified list of
317 collections then that Quantum will be excluded from the QuantumGraph.
318 """
319 ),
320)
323skip_existing_option = MWOptionDecorator(
324 "--skip-existing",
325 is_flag=True,
326 help=unwrap(
327 """This option is equivalent to --skip-existing-in with the name of
328 the output RUN collection. If both --skip-existing-in and
329 --skip-existing are given then output RUN collection is appended to
330 the list of collections."""
331 ),
332)
335clobber_outputs_option = MWOptionDecorator(
336 "--clobber-outputs",
337 help=unwrap(
338 """Remove outputs from previous execution of the same
339 quantum before new execution. If --skip-existing
340 is also passed, then only failed quanta will be
341 clobbered. Requires the 'run' command's --extend-run
342 flag to be set."""
343 ),
344 is_flag=True,
345)
348skip_init_writes_option = MWOptionDecorator(
349 "--skip-init-writes",
350 help=unwrap(
351 """Do not write collection-wide 'init output' datasets
352 (e.g.schemas)."""
353 ),
354 is_flag=True,
355)
358task_option = MWOptionDecorator(
359 "-t",
360 "--task",
361 callback=split_commas,
362 help=unwrap(
363 """Task name to add to pipeline, must be a fully qualified task
364 name. Task name can be followed by colon and label name, if label
365 is not given then task base name (class name) is used as
366 label."""
367 ),
368 metavar="TASK[:LABEL]",
369 multiple=True,
370)
373timeout_option = MWOptionDecorator(
374 "--timeout", type=click.IntRange(min=0), help="Timeout for multiprocessing; maximum wall time (sec)."
375)
378start_method_option = MWOptionDecorator(
379 "--start-method",
380 default=None,
381 type=click.Choice(choices=["spawn", "fork", "forkserver"]),
382 help="Multiprocessing start method, default is platform-specific.",
383)
386fail_fast_option = MWOptionDecorator(
387 "--fail-fast",
388 help=unwrap(
389 """Stop processing at first error, default is to process
390 as many tasks as possible."""
391 ),
392 is_flag=True,
393)
395save_execution_butler_option = MWOptionDecorator(
396 "--save-execution-butler",
397 help=unwrap(
398 """Export location for an
399 execution-specific butler after making
400 QuantumGraph"""
401 ),
402)
404mock_option = MWOptionDecorator(
405 "--mock",
406 help=unwrap("""Mock pipeline execution."""),
407 is_flag=True,
408)
410clobber_execution_butler_option = MWOptionDecorator(
411 "--clobber-execution-butler",
412 help=unwrap(
413 """When creating execution butler overwrite
414 any existing products"""
415 ),
416 is_flag=True,
417)
419target_datastore_root_option = MWOptionDecorator(
420 "--target-datastore-root",
421 help=unwrap(
422 """Root directory for datastore of execution butler.
423 Default is to use the original datastore.
424 """
425 ),
426)
428dataset_query_constraint = MWOptionDecorator(
429 "--dataset-query-constraint",
430 help=unwrap(
431 """When constructing a quantum graph constrain by
432 pre-existence of specified dataset types. Valid
433 values are `all` for all inputs dataset types in
434 pipeline, `off` to not consider dataset type
435 existance as a constraint, single or comma
436 separated list of dataset type names"""
437 ),
438 default="all",
439)
441summary_option = MWOptionDecorator(
442 "--summary",
443 help=(
444 "Location for storing job summary (JSON file). Note that the"
445 " structure of this file may not be stable."
446 ),
447 type=MWPath(dir_okay=False, file_okay=True, writable=True),
448)
451recursive_option = MWOptionDecorator(
452 "--recursive",
453 is_flag=True,
454)