Coverage for python/lsst/ctrl/mpexec/cli/script/qgraph.py : 38%

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# (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
27_log = logging.getLogger(__name__.partition(".")[2])
30def qgraph(pipelineObj, qgraph, skip_existing, save_qgraph, save_single_quanta, qgraph_dot,
31 butler_config, input, output, output_run, extend_run, replace_run, prune_replaced, data_query,
32 show, **kwargs):
33 """Implements the command line interface `pipetask qgraph` subcommand,
34 should only be called by command line tools and unit test code that test
35 this function.
37 Parameters
38 ----------
39 pipelineObj : `pipe.base.Pipeline` or None.
40 The pipeline object used to generate a qgraph. If this is not `None`
41 then `qgraph` should be `None`.
42 qgraph : `str` or `None`
43 URI location for a serialized quantum graph definition as a pickle
44 file. If this option is not None then `pipeline` should be `None`.
45 skip_existing : `bool`
46 If all Quantum outputs already exist in the output RUN collection then
47 that Quantum will be excluded from the QuantumGraph. Will only be used
48 if `extend_run` flag is set.
49 save_qgraph : `str` or `None`
50 URI location for storing a serialized quantum graph definition as a
51 pickle file.
52 save_single_quanta : `str` or `None`
53 Format string of URI locations for storing individual quantum graph
54 definition (pickle files). The curly brace {} in the input string will
55 be replaced by a quantum number.
56 qgraph_dot : `str` or `None`
57 Path location for storing GraphViz DOT representation of a quantum graph.
58 butler_config : `str`, `dict`, or `lsst.daf.butler.Config`
59 If `str`, `butler_config` is the path location of the gen3
60 butler/registry config file. If `dict`, `butler_config` is key value
61 pairs used to init or update the `lsst.daf.butler.Config` instance. If
62 `Config`, it is the object used to configure a Butler.
63 input : `str`
64 Comma-separated names of the input collection(s). Entries may include a
65 colon (:), the first string is a dataset type name that restricts the
66 search in that collection.
67 output : `str`
68 Name of the output CHAINED collection. This may either be an existing
69 CHAINED collection to use as both input and output (if `input` is
70 `None`), or a new CHAINED collection created to include all inputs
71 (if `input` is not `None`). In both cases, the collection's children
72 will start with an output RUN collection that directly holds all new
73 datasets (see `output_run`).
74 output_run : `str`
75 Name of the new output RUN collection. If not provided then `output`
76 must be provided and a new RUN collection will be created by appending
77 a timestamp to the value passed with `output`. If this collection
78 already exists then `extend_run` must be passed.
79 extend_run : `bool`
80 Instead of creating a new RUN collection, insert datasets into either
81 the one given by `output_run` (if provided) or the first child
82 collection of `output` (which must be of type RUN).
83 replace_run : `bool`
84 Before creating a new RUN collection in an existing CHAINED collection,
85 remove the first child collection (which must be of type RUN). This can
86 be used to repeatedly write to the same (parent) collection during
87 development, but it does not delete the datasets associated with the
88 replaced run unless `prune-replaced` is also True. Requires `output`,
89 and `extend_run` must be `None`.
90 prune_replaced : "unstore", "purge", or `None`.
91 If not `None`, delete the datasets in the collection replaced by
92 `replace_run`, either just from the datastore ("unstore") or by
93 removing them and the RUN completely ("purge"). Requires `replace_run`.
94 data_query : `str`
95 User query selection expression.
96 show : `list` [`str`] or `None`
97 Descriptions of what to dump to stdout.
98 kwargs : `dict` [`str`, `str`]
99 Ignored; click commands may accept options for more than one script
100 function and pass all the option kwargs to each of the script functions
101 which ingore these unused kwargs.
103 Returns
104 -------
105 qgraph : `lsst.pipe.base.QuantumGraph`
106 The qgraph object that was created.
107 """
108 args = SimpleNamespace(qgraph=qgraph,
109 save_qgraph=save_qgraph,
110 save_single_quanta=save_single_quanta,
111 qgraph_dot=qgraph_dot,
112 butler_config=butler_config,
113 input=input,
114 output=output,
115 output_run=output_run,
116 extend_run=extend_run,
117 replace_run=replace_run,
118 prune_replaced=prune_replaced,
119 data_query=data_query,
120 show=show,
121 skip_existing=skip_existing)
123 f = CmdLineFwk()
124 qgraph = f.makeGraph(pipelineObj, args)
126 # optionally dump some info.
127 if show:
128 f.showInfo(args, pipelineObj, qgraph)
130 return qgraph