Coverage for python/lsst/ctrl/bps/cli/cmd/commands.py: 86%

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

57 statements  

1# This file is part of ctrl_bps. 

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 <https://www.gnu.org/licenses/>. 

21"""Subcommand definitions. 

22""" 

23import click 

24 

25from lsst.daf.butler.cli.utils import MWCommand 

26from ...drivers import ( 

27 acquire_qgraph_driver, 

28 cluster_qgraph_driver, 

29 transform_driver, 

30 prepare_driver, 

31 submit_driver, 

32 report_driver, 

33 restart_driver, 

34 cancel_driver 

35) 

36from .. import opt 

37 

38 

39class BpsCommand(MWCommand): 

40 """Command subclass with bps-command specific overrides.""" 

41 

42 extra_epilog = "See 'bps --help' for more options." 

43 

44 

45@click.command(cls=BpsCommand) 

46@opt.config_file_argument(required=True) 

47@opt.submission_options() 

48def acquire(*args, **kwargs): 

49 """Create a new quantum graph or read existing one from a file. 

50 """ 

51 acquire_qgraph_driver(*args, **kwargs) 

52 

53 

54@click.command(cls=BpsCommand) 

55@opt.config_file_argument(required=True) 

56@opt.submission_options() 

57def cluster(*args, **kwargs): 

58 """Create a clustered quantum graph. 

59 """ 

60 cluster_qgraph_driver(*args, **kwargs) 

61 

62 

63@click.command(cls=BpsCommand) 

64@opt.config_file_argument(required=True) 

65@opt.submission_options() 

66def transform(*args, **kwargs): 

67 """Transform a quantum graph to a generic workflow. 

68 """ 

69 transform_driver(*args, **kwargs) 

70 

71 

72@click.command(cls=BpsCommand) 

73@opt.config_file_argument(required=True) 

74@opt.wms_service_option() 

75@opt.submission_options() 

76def prepare(*args, **kwargs): 

77 """Prepare a workflow for submission. 

78 """ 

79 prepare_driver(*args, **kwargs) 

80 

81 

82@click.command(cls=BpsCommand) 

83@opt.config_file_argument(required=True) 

84@opt.wms_service_option() 

85@opt.submission_options() 

86def submit(*args, **kwargs): 

87 """Submit a workflow for execution. 

88 """ 

89 submit_driver(*args, **kwargs) 

90 

91 

92@click.command(cls=BpsCommand) 

93@opt.wms_service_option() 

94@click.option("--id", "run_id", 

95 help="Run id of workflow to restart.") 

96def restart(*args, **kwargs): 

97 """Restart a failed workflow. 

98 """ 

99 restart_driver(*args, **kwargs) 

100 

101 

102@click.command(cls=BpsCommand) 

103@opt.wms_service_option() 

104@click.option("--id", "run_id", 

105 help="Restrict report to specific WMS run id.") 

106@click.option("--user", 

107 help="Restrict report to specific user.") 

108@click.option("--hist", "hist_days", 

109 default=0.0, 

110 help="Search WMS history X days for completed info.") 

111@click.option("--pass-thru", 

112 help="Pass the given string to the WMS service class.") 

113@click.option("--global/--no-global", "is_global", default=False, 

114 help="Query all available job queues for job information.") 

115def report(*args, **kwargs): 

116 """Display execution status for submitted workflows. 

117 """ 

118 report_driver(*args, **kwargs) 

119 

120 

121@click.command(cls=BpsCommand) 

122@opt.wms_service_option() 

123@click.option("--id", "run_id", 

124 help="Run id of workflow to cancel.") 

125@click.option("--user", 

126 help="User for which to cancel all submitted workflows.") 

127@click.option("--require-bps/--skip-require-bps", "require_bps", default=True, show_default=True, 

128 help="Only cancel jobs submitted via bps.") 

129@click.option("--pass-thru", "pass_thru", default=str(), 

130 help="Pass the given string to the WMS service.") 

131@click.option("--global/--no-global", "is_global", default=False, 

132 help="Cancel jobs matching the search criteria from all job queues.") 

133def cancel(*args, **kwargs): 

134 """Cancel submitted workflow(s). 

135 """ 

136 cancel_driver(*args, **kwargs)