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# (https://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 

22 

23__all__ = ("butler_options", "execution_options", "meta_info_options", "pipeline_build_options", 

24 "qgraph_options") 

25 

26 

27from functools import partial 

28 

29from lsst.daf.butler.cli.utils import option_section, split_kv, unwrap 

30import lsst.obs.base.cli.opt as obsBaseOpts 

31import lsst.daf.butler.cli.opt as dafButlerOpts 

32from . import options as ctrlMpExecOpts 

33 

34instrumentOptionHelp = ("Add an instrument which will be used to load config overrides when defining a " 

35 "pipeline. This must be the fully qualified class name.") 

36 

37 

38class OptionGroup: 

39 """Base class for an option group decorator. Requires the option group 

40 subclass to have a property called `decorator`.""" 

41 

42 def __call__(self, f): 

43 for decorator in reversed(self.decorators): 

44 f = decorator(f) 

45 return f 

46 

47 

48class pipeline_build_options(OptionGroup): # noqa: N801 

49 """Decorator to add options to a command function for building a pipeline. 

50 """ 

51 

52 def __init__(self): 

53 self.decorators = [ 

54 option_section(sectionText="Pipeline build options:"), 

55 ctrlMpExecOpts.pipeline_option(), 

56 ctrlMpExecOpts.task_option(), 

57 ctrlMpExecOpts.delete_option(metavar="LABEL"), 

58 dafButlerOpts.config_option(metavar="LABEL:NAME=VALUE", multiple=True), 

59 dafButlerOpts.config_file_option(help=unwrap("""Configuration override file(s), applies to a task 

60 with a given label."""), 

61 metavar="LABEL:FILE", 

62 multiple=True), 

63 ctrlMpExecOpts.order_pipeline_option(), 

64 ctrlMpExecOpts.save_pipeline_option(), 

65 ctrlMpExecOpts.pipeline_dot_option(), 

66 obsBaseOpts.instrument_option(help=instrumentOptionHelp, metavar="instrument", multiple=True)] 

67 

68 

69class qgraph_options(OptionGroup): # noqa: N801 

70 """Decorator to add options to a command function for creating a quantum 

71 graph.""" 

72 

73 def __init__(self): 

74 self.decorators = [ 

75 option_section(sectionText="Quantum graph building options:"), 

76 ctrlMpExecOpts.qgraph_option(), 

77 ctrlMpExecOpts.skip_existing_option(), 

78 ctrlMpExecOpts.save_qgraph_option(), 

79 ctrlMpExecOpts.save_single_quanta_option(), 

80 ctrlMpExecOpts.qgraph_dot_option()] 

81 

82 

83class butler_options(OptionGroup): # noqa: N801 

84 """Decorator to add options to a command function for configuring a butler. 

85 """ 

86 

87 def __init__(self): 

88 self.decorators = [ 

89 option_section(sectionText="Data repository and selection options:"), 

90 ctrlMpExecOpts.butler_config_option(), 

91 # CLI API says `--input` values should be given like 

92 # "datasetType:collectionName" or just "datasetType", but CmdLineFwk api 

93 # wants input values to be a tuple of tuples, where each tuple is 

94 # ("collectionName", "datasetType"), or (..., "datasetType") with elipsis if no 

95 # collectionName is provided. Setting `return_type=tuple`, `reverse_kv=True`, 

96 # and `default_key=...` make `split_kv` callback structure its return value 

97 # that way. 

98 ctrlMpExecOpts.input_option(callback=partial(split_kv, return_type=tuple, default_key=..., 

99 reverse_kv=True, unseparated_okay=True), 

100 multiple=True), 

101 ctrlMpExecOpts.output_option(), 

102 ctrlMpExecOpts.output_run_option(), 

103 ctrlMpExecOpts.extend_run_option(), 

104 ctrlMpExecOpts.replace_run_option(), 

105 ctrlMpExecOpts.prune_replaced_option(), 

106 ctrlMpExecOpts.data_query_option()] 

107 

108 

109class execution_options(OptionGroup): # noqa: N801 

110 """Decorator to add options to a command function for executing a pipeline. 

111 """ 

112 

113 def __init__(self): 

114 self.decorators = [ 

115 option_section(sectionText="Execution options:"), 

116 ctrlMpExecOpts.do_raise_option(), 

117 ctrlMpExecOpts.profile_option(), 

118 ctrlMpExecOpts.processes_option(), 

119 ctrlMpExecOpts.timeout_option(), 

120 ctrlMpExecOpts.fail_fast_option(), 

121 ctrlMpExecOpts.graph_fixup_option()] 

122 

123 

124class meta_info_options(OptionGroup): # noqa: N801 

125 """Decorator to add options to a command function for managing pipeline 

126 meta information.""" 

127 

128 def __init__(self): 

129 self.decorators = [ 

130 option_section(sectionText="Meta-information output options:"), 

131 ctrlMpExecOpts.skip_init_writes_option(), 

132 ctrlMpExecOpts.init_only_option(), 

133 ctrlMpExecOpts.register_dataset_types_option(), 

134 ctrlMpExecOpts.no_versions_option()]