Coverage for python/lsst/ctrl/mpexec/cli/script/build.py: 29%

Shortcuts 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

12 statements  

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/>. 

21 

22from types import SimpleNamespace 

23 

24from ... import CmdLineFwk 

25from ..utils import _PipelineAction 

26 

27 

28def build(order_pipeline, pipeline, pipeline_actions, pipeline_dot, save_pipeline, show, **kwargs): 

29 """Implements the command line interface `pipetask build` subcommand, 

30 should only be called by command line tools and unit test code that tests 

31 this function. 

32 

33 Build and optionally save pipeline definition. 

34 

35 Returns the pipeline instance that was built, for testing and for using 

36 this function with other script functions. 

37 

38 Parameters 

39 ---------- 

40 order_pipeline : `bool` 

41 If true, order tasks in pipeline based on their data dependencies, 

42 ordering is performed as last step before saving or executing pipeline. 

43 pipeline_actions : `list` [`PipelineAction`]] or `PipelineAction` 

44 A list of pipeline actions in the order they should be executed. 

45 pipeline_dot : `str` 

46 Path location for storing GraphViz DOT representation of a pipeline. 

47 pipeline : `str` 

48 Path location of a pipeline definition file in YAML format. 

49 save_pipeline : `str` 

50 Path location for storing resulting pipeline definition in YAML format. 

51 show : `list` [`str`] 

52 Descriptions of what to dump to stdout. 

53 kwargs : `dict` [`str`, `str`] 

54 Ignored; click commands may accept options for more than one script 

55 function and pass all the option kwargs to each of the script functions 

56 which ingore these unused kwargs. 

57 

58 Returns 

59 ------- 

60 pipeline : `lsst.pipe.base.Pipeline` 

61 The pipeline instance that was built. 

62 

63 Raises 

64 ------ 

65 Exception 

66 Raised if there is a failure building the pipeline. 

67 """ 

68 # If pipeline_actions is a single instance, not a list, then put it in 

69 # a list. _PipelineAction is a namedtuple, so we can't use 

70 # `lsst.utils.iteration.iterable` because a namedtuple *is* iterable, 

71 # but we need a list of _PipelineAction. 

72 if isinstance(pipeline_actions, _PipelineAction): 

73 pipeline_actions = (pipeline_actions,) 

74 

75 args = SimpleNamespace(pipeline=pipeline, 

76 pipeline_actions=pipeline_actions, 

77 pipeline_dot=pipeline_dot, 

78 save_pipeline=save_pipeline) 

79 

80 f = CmdLineFwk() 

81 

82 # Will raise an exception if it fails to build the pipeline. 

83 pipeline = f.makePipeline(args) 

84 

85 args = SimpleNamespace(show=show) 

86 f.showInfo(args, pipeline) 

87 

88 return pipeline