Coverage for python/lsst/daf/butler/cli/opt/options.py : 69%

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 daf_butler.
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/>.
23import click
24from functools import partial
26from ..utils import MWOptionDecorator, split_commas, split_kv, unwrap
27from lsst.daf.butler.core.utils import iterable
28from lsst.daf.butler.registry import CollectionType
31class CollectionTypeCallback:
33 collectionTypes = dict(CHAINED=CollectionType.CHAINED,
34 RUN=CollectionType.RUN,
35 TAGGED=CollectionType.TAGGED)
37 @staticmethod
38 def makeCollectionType(context, param, value):
39 if value is None:
40 return value
41 try:
42 return CollectionTypeCallback.collectionTypes[value.upper()]
43 except KeyError:
44 raise ValueError(f"Invalid collection type: {value}")
47collection_type_option = MWOptionDecorator("--collection-type",
48 callback=CollectionTypeCallback.makeCollectionType,
49 help="If provided, only list collections of this type.",
50 type=click.Choice(CollectionTypeCallback.collectionTypes,
51 case_sensitive=False))
53config_option = MWOptionDecorator("-c", "--config",
54 callback=split_kv,
55 help="Config override, as a key-value pair.",
56 multiple=True)
59config_file_option = MWOptionDecorator("-C", "--config-file",
60 help=unwrap("""Path to a pex config override to be included after the
61 Instrument config overrides are applied."""))
64dataset_type_option = MWOptionDecorator("-d", "--dataset-type",
65 callback=split_commas,
66 help="Specific DatasetType(s) to validate.",
67 multiple=True)
70log_level_option = MWOptionDecorator("--log-level",
71 callback=partial(split_kv,
72 choice=click.Choice(["CRITICAL", "ERROR", "WARNING",
73 "INFO", "DEBUG"],
74 case_sensitive=False),
75 normalize=True,
76 unseparated_okay=True),
77 default=iterable("WARNING"),
78 help="The Python log level to use.",
79 is_eager=True,
80 multiple=True)
83long_log_option = MWOptionDecorator("--long-log",
84 help="Make log messages appear in long format.",
85 is_flag=True)
88regex_option = MWOptionDecorator("--regex")
91run_option = MWOptionDecorator("--output-run",
92 help="The name of the run datasets should be output to.")
95transfer_option = MWOptionDecorator("-t", "--transfer",
96 default="auto", # set to `None` if using `required=True`
97 help="The external data transfer mode.",
98 type=click.Choice(["auto", "link", "symlink", "hardlink", "copy", "move",
99 "relsymlink"],
100 case_sensitive=False))
103verbose_option = MWOptionDecorator("-v", "--verbose",
104 help="Increase verbosity.",
105 is_flag=True)