Coverage for python/lsst/ctrl/mpexec/cli/script/build.py: 31%
11 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-13 09:53 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-13 09:53 +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 software is dual licensed under the GNU General Public License and also
10# under a 3-clause BSD license. Recipients may choose which of these licenses
11# to use; please see the files gpl-3.0.txt and/or bsd_license.txt,
12# respectively. If you choose the GPL option then the following text applies
13# (but note that there is still no warranty even if you opt for BSD instead):
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation, either version 3 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
28from types import SimpleNamespace
30from ... import CmdLineFwk
31from ..utils import _PipelineAction
34def build( # type: ignore
35 order_pipeline, pipeline, pipeline_actions, pipeline_dot, save_pipeline, show, **kwargs
36):
37 """Implement the command line interface `pipetask build` subcommand.
39 Should only be called by command line tools and unit test code that tests
40 this function.
42 Build and optionally save pipeline definition.
44 Returns the pipeline instance that was built, for testing and for using
45 this function with other script functions.
47 Parameters
48 ----------
49 order_pipeline : `bool`
50 If true, order tasks in pipeline based on their data dependencies,
51 ordering is performed as last step before saving or executing pipeline.
52 pipeline_actions : `list` [`PipelineAction`]] or `PipelineAction`
53 A list of pipeline actions in the order they should be executed.
54 pipeline_dot : `str`
55 Path location for storing GraphViz DOT representation of a pipeline.
56 pipeline : `str`
57 Path location of a pipeline definition file in YAML format.
58 save_pipeline : `str`
59 Path location for storing resulting pipeline definition in YAML format.
60 show : `lsst.ctrl.mpexec.showInfo.ShowInfo`
61 Descriptions of what to dump to stdout.
62 kwargs : `dict` [`str`, `str`]
63 Ignored; click commands may accept options for more than one script
64 function and pass all the option kwargs to each of the script functions
65 which ingore these unused kwargs.
67 Returns
68 -------
69 pipeline : `lsst.pipe.base.Pipeline`
70 The pipeline instance that was built.
72 Raises
73 ------
74 Exception
75 Raised if there is a failure building the pipeline.
76 """
77 # If pipeline_actions is a single instance, not a list, then put it in
78 # a list. _PipelineAction is a namedtuple, so we can't use
79 # `lsst.utils.iteration.iterable` because a namedtuple *is* iterable,
80 # but we need a list of _PipelineAction.
81 if isinstance(pipeline_actions, _PipelineAction):
82 pipeline_actions = (pipeline_actions,)
84 args = SimpleNamespace(
85 pipeline=pipeline,
86 pipeline_actions=pipeline_actions,
87 pipeline_dot=pipeline_dot,
88 save_pipeline=save_pipeline,
89 )
91 f = CmdLineFwk()
93 # Will raise an exception if it fails to build the pipeline.
94 pipeline = f.makePipeline(args)
96 show.show_pipeline_info(pipeline)
98 return pipeline