Coverage for python/lsst/ctrl/bps/cli/cmd/commands.py: 88%
68 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-25 10:48 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-25 10:48 +0000
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
24from lsst.daf.butler.cli.utils import MWCommand
26from ...drivers import (
27 acquire_qgraph_driver,
28 cancel_driver,
29 cluster_qgraph_driver,
30 ping_driver,
31 prepare_driver,
32 report_driver,
33 restart_driver,
34 submit_driver,
35 transform_driver,
36)
37from .. import opt
40class BpsCommand(MWCommand):
41 """Command subclass with bps-command specific overrides."""
43 extra_epilog = "See 'bps --help' for more options."
46@click.command(cls=BpsCommand)
47@opt.config_file_argument(required=True)
48@opt.submission_options()
49def acquire(*args, **kwargs):
50 """Create a new quantum graph or read existing one from a file."""
51 acquire_qgraph_driver(*args, **kwargs)
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 cluster_qgraph_driver(*args, **kwargs)
62@click.command(cls=BpsCommand)
63@opt.config_file_argument(required=True)
64@opt.submission_options()
65def transform(*args, **kwargs):
66 """Transform a quantum graph to a generic workflow."""
67 transform_driver(*args, **kwargs)
70@click.command(cls=BpsCommand)
71@opt.config_file_argument(required=True)
72@opt.wms_service_option()
73@opt.compute_site_option()
74@opt.submission_options()
75def prepare(*args, **kwargs):
76 """Prepare a workflow for submission."""
77 prepare_driver(*args, **kwargs)
80@click.command(cls=BpsCommand)
81@opt.config_file_argument(required=True)
82@opt.wms_service_option()
83@opt.compute_site_option()
84@opt.submission_options()
85def submit(*args, **kwargs):
86 """Submit a workflow for execution."""
87 submit_driver(*args, **kwargs)
90@click.command(cls=BpsCommand)
91@opt.wms_service_option()
92@opt.compute_site_option()
93@click.option("--id", "run_id", help="Run id of workflow to restart.")
94def restart(*args, **kwargs):
95 """Restart a failed workflow."""
96 restart_driver(*args, **kwargs)
99@click.command(cls=BpsCommand)
100@opt.wms_service_option()
101@opt.compute_site_option()
102@click.option("--id", "run_id", help="Restrict report to specific WMS run id.")
103@click.option("--user", help="Restrict report to specific user.")
104@click.option("--hist", "hist_days", default=0.0, help="Search WMS history X days for completed info.")
105@click.option("--pass-thru", help="Pass the given string to the WMS service class.")
106@click.option(
107 "--global/--no-global",
108 "is_global",
109 default=False,
110 help="Query all available job queues for job information.",
111)
112def report(*args, **kwargs):
113 """Display execution status for submitted workflows."""
114 report_driver(*args, **kwargs)
117@click.command(cls=BpsCommand)
118@opt.wms_service_option()
119@opt.compute_site_option()
120@click.option("--id", "run_id", help="Run id of workflow to cancel.")
121@click.option("--user", help="User for which to cancel all submitted workflows.")
122@click.option(
123 "--require-bps/--skip-require-bps",
124 "require_bps",
125 default=True,
126 show_default=True,
127 help="Only cancel jobs submitted via bps.",
128)
129@click.option("--pass-thru", "pass_thru", default=str(), help="Pass the given string to the WMS service.")
130@click.option(
131 "--global/--no-global",
132 "is_global",
133 default=False,
134 help="Cancel jobs matching the search criteria from all job queues.",
135)
136def cancel(*args, **kwargs):
137 """Cancel submitted workflow(s)."""
138 cancel_driver(*args, **kwargs)
141@click.command(cls=BpsCommand)
142@opt.wms_service_option()
143@opt.compute_site_option()
144@click.option("--pass-thru", "pass_thru", default=str(), help="Pass the given string to the WMS service.")
145def ping(*args, **kwargs):
146 """Ping workflow services."""
147 # Note: Using return statement doesn't actually return the value
148 # to the shell. Using click function instead.
149 click.get_current_context().exit(ping_driver(*args, **kwargs))