Coverage for python/lsst/ctrl/mpexec/cli/script/run.py: 56%
9 statements
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-12 01:56 -0800
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-12 01:56 -0800
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# (http://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 logging
23from types import SimpleNamespace
25from ... import CmdLineFwk, TaskFactory
27_log = logging.getLogger(__name__.partition(".")[2])
30def run(do_raise,
31 graph_fixup,
32 init_only,
33 no_versions,
34 processes,
35 start_method,
36 profile,
37 qgraphObj,
38 register_dataset_types,
39 skip_init_writes,
40 timeout,
41 butler_config,
42 input,
43 output,
44 output_run,
45 extend_run,
46 replace_run,
47 prune_replaced,
48 data_query,
49 skip_existing_in,
50 skip_existing,
51 debug,
52 fail_fast,
53 clobber_outputs,
54 **kwargs):
55 """Implements the command line interface `pipetask run` subcommand, should
56 only be called by command line tools and unit test code that test this
57 function.
59 Parameters
60 ----------
61 do_raise : `bool`
62 Raise an exception in the case of an error.
63 graph_fixup : `str`
64 The name of the class or factory method which makes an instance used
65 for execution graph fixup.
66 init_only : `bool`
67 If true, do not actually run; just register dataset types and/or save
68 init outputs.
69 no_versions : `bool`
70 If true, do not save or check package versions.
71 processes : `int`
72 The number of processes to use.
73 start_method : `str` or `None`
74 Start method from `multiprocessing` module, `None` selects the best
75 one for current platform.
76 profile : `str`
77 File name to dump cProfile information to.
78 qgraphObj : `lsst.pipe.base.QuantumGraph`
79 A QuantumGraph generated by a previous subcommand.
80 register_dataset_types : `bool`
81 If true, register DatasetTypes that do not already exist in the
82 Registry.
83 skip_init_writes : `bool`
84 If true, do not write collection-wide 'init output' datasets (e.g.
85 schemas).
86 timeout : `int`
87 Timeout for multiprocessing; maximum wall time (sec).
88 butler_config : `str`, `dict`, or `lsst.daf.butler.Config`
89 If `str`, `butler_config` is the path location of the gen3
90 butler/registry config file. If `dict`, `butler_config` is key value
91 pairs used to init or update the `lsst.daf.butler.Config` instance. If
92 `Config`, it is the object used to configure a Butler.
93 input : `list` [ `str` ]
94 List of names of the input collection(s).
95 output : `str`
96 Name of the output CHAINED collection. This may either be an existing
97 CHAINED collection to use as both input and output (if `input` is
98 `None`), or a new CHAINED collection created to include all inputs
99 (if `input` is not `None`). In both cases, the collection's children
100 will start with an output RUN collection that directly holds all new
101 datasets (see `output_run`).
102 output_run : `str`
103 Name of the new output RUN collection. If not provided then `output`
104 must be provided and a new RUN collection will be created by appending
105 a timestamp to the value passed with `output`. If this collection
106 already exists then `extend_run` must be passed.
107 extend_run : `bool`
108 Instead of creating a new RUN collection, insert datasets into either
109 the one given by `output_run` (if provided) or the first child
110 collection of `output` (which must be of type RUN).
111 replace_run : `bool`
112 Before creating a new RUN collection in an existing CHAINED collection,
113 remove the first child collection (which must be of type RUN). This can
114 be used to repeatedly write to the same (parent) collection during
115 development, but it does not delete the datasets associated with the
116 replaced run unless `prune-replaced` is also True. Requires `output`,
117 and `extend_run` must be `None`.
118 prune_replaced : "unstore", "purge", or `None`.
119 If not `None`, delete the datasets in the collection replaced by
120 `replace_run`, either just from the datastore ("unstore") or by
121 removing them and the RUN completely ("purge"). Requires `replace_run`.
122 data_query : `str`
123 User query selection expression.
124 skip_existing_in : `list` [ `str` ]
125 Accepts list of collections, if all Quantum outputs already exist in
126 the specified list of collections then that Quantum will be excluded
127 from the QuantumGraph.
128 skip_existing : `bool`
129 Appends output RUN collection to the ``skip_existing_in`` list.
130 debug : `bool`
131 If true, enable debugging output using lsstDebug facility (imports
132 debug.py).
133 fail_fast : `bool`
134 If true then stop processing at first error, otherwise process as many
135 tasks as possible.
136 clobber_outputs : `bool`
137 Remove outputs from previous execution of the same quantum before new
138 execution. Only applies to failed quanta if skip_existing is also
139 given.
140 kwargs : `dict` [`str`, `str`]
141 Ignored; click commands may accept options for more than one script
142 function and pass all the option kwargs to each of the script functions
143 which ingore these unused kwargs.
144 """
145 args = SimpleNamespace(do_raise=do_raise,
146 graph_fixup=graph_fixup,
147 init_only=init_only,
148 no_versions=no_versions,
149 processes=processes,
150 start_method=start_method,
151 profile=profile,
152 skip_init_writes=skip_init_writes,
153 timeout=timeout,
154 register_dataset_types=register_dataset_types,
155 butler_config=butler_config,
156 input=input,
157 output=output,
158 output_run=output_run,
159 extend_run=extend_run,
160 replace_run=replace_run,
161 prune_replaced=prune_replaced,
162 data_query=data_query,
163 skip_existing_in=skip_existing_in,
164 skip_existing=skip_existing,
165 enableLsstDebug=debug,
166 fail_fast=fail_fast,
167 clobber_outputs=clobber_outputs)
169 f = CmdLineFwk()
170 taskFactory = TaskFactory()
171 f.runPipeline(qgraphObj, taskFactory, args)