Hide keyboard shortcuts

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

21 

22from click import ClickException 

23 

24from lsst.daf.butler.cli.cliLog import CliLog 

25from ... import CmdLineFwk 

26 

27 

28def build(order_pipeline=None, pipeline=None, pipeline_actions=(), pipeline_dot=None, save_pipeline=None, 

29 show=(), log_level=None): 

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

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

32 this function. 

33 

34 Build and optionally save pipeline definition. 

35 

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

37 this function with other script functions. 

38 

39 Parameters 

40 ---------- 

41 order_pipeline : `bool` 

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

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

44 pipeline_actions : `list` [`PipelineAction`]] 

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

46 pipeline_dot : `str` 

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

48 pipeline : `str` 

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

50 save_pipeline : `str` 

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

52 show : `list` [`str`] 

53 Descriptions of what to dump to stdout. 

54 

55 Returns 

56 ------- 

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

58 The pipeline instance that was built. 

59 """ 

60 if log_level is not None: 

61 CliLog.setLogLevels(log_level) 

62 

63 class MakePipelineArgs: 

64 """A container class for arguments to CmdLineFwk.makePipeline, whose 

65 API (currently) is written to accept inputs from argparse in a generic 

66 container class. 

67 """ 

68 def __init__(self, pipeline, pipeline_actions, pipeline_dot, save_pipeline): 

69 self.pipeline = pipeline 

70 self.pipeline_dot = pipeline_dot 

71 self.save_pipeline = save_pipeline 

72 self.pipeline_actions = pipeline_actions 

73 

74 args = MakePipelineArgs(pipeline, pipeline_actions, pipeline_dot, save_pipeline) 

75 

76 f = CmdLineFwk() 

77 try: 

78 pipeline = f.makePipeline(args) 

79 except Exception as exc: 

80 raise ClickException(f"Failed to build pipeline: {exc}") from exc 

81 

82 class ShowInfoArgs: 

83 """A container class for arguments to CmdLineFwk.showInfo, whose 

84 API (currently) is written to accept inputs from argparse in a generic 

85 container class. 

86 """ 

87 

88 def __init__(self, show): 

89 self.show = show 

90 

91 args = ShowInfoArgs(show) 

92 f.showInfo(args, pipeline) 

93 

94 return pipeline