Coverage for python/lsst/ctrl/mpexec/cli/script/build.py: 31%
11 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-15 10:02 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-15 10:02 +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/>.
22from types import SimpleNamespace
24from ... import CmdLineFwk
25from ..utils import _PipelineAction
28def build( # type: ignore
29 order_pipeline, pipeline, pipeline_actions, pipeline_dot, save_pipeline, show, **kwargs
30):
31 """Implements the command line interface `pipetask build` subcommand,
32 should only be called by command line tools and unit test code that tests
33 this function.
35 Build and optionally save pipeline definition.
37 Returns the pipeline instance that was built, for testing and for using
38 this function with other script functions.
40 Parameters
41 ----------
42 order_pipeline : `bool`
43 If true, order tasks in pipeline based on their data dependencies,
44 ordering is performed as last step before saving or executing pipeline.
45 pipeline_actions : `list` [`PipelineAction`]] or `PipelineAction`
46 A list of pipeline actions in the order they should be executed.
47 pipeline_dot : `str`
48 Path location for storing GraphViz DOT representation of a pipeline.
49 pipeline : `str`
50 Path location of a pipeline definition file in YAML format.
51 save_pipeline : `str`
52 Path location for storing resulting pipeline definition in YAML format.
53 show : `lsst.ctrl.mpexec.showInfo.ShowInfo`
54 Descriptions of what to dump to stdout.
55 kwargs : `dict` [`str`, `str`]
56 Ignored; click commands may accept options for more than one script
57 function and pass all the option kwargs to each of the script functions
58 which ingore these unused kwargs.
60 Returns
61 -------
62 pipeline : `lsst.pipe.base.Pipeline`
63 The pipeline instance that was built.
65 Raises
66 ------
67 Exception
68 Raised if there is a failure building the pipeline.
69 """
70 # If pipeline_actions is a single instance, not a list, then put it in
71 # a list. _PipelineAction is a namedtuple, so we can't use
72 # `lsst.utils.iteration.iterable` because a namedtuple *is* iterable,
73 # but we need a list of _PipelineAction.
74 if isinstance(pipeline_actions, _PipelineAction):
75 pipeline_actions = (pipeline_actions,)
77 args = SimpleNamespace(
78 pipeline=pipeline,
79 pipeline_actions=pipeline_actions,
80 pipeline_dot=pipeline_dot,
81 save_pipeline=save_pipeline,
82 )
84 f = CmdLineFwk()
86 # Will raise an exception if it fails to build the pipeline.
87 pipeline = f.makePipeline(args)
89 show.show_pipeline_info(pipeline)
91 return pipeline