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