Coverage for python/lsst/obs/base/cli/cmd/commands.py: 91%
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
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
1# This file is part of obs_base.
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/>.
22import click
23from lsst.daf.butler.cli.opt import (
24 config_file_option,
25 config_option,
26 locations_argument,
27 options_file_option,
28 processes_option,
29 regex_option,
30 repo_argument,
31 run_option,
32 transfer_option,
33)
34from lsst.daf.butler.cli.utils import ButlerCommand, split_commas, typeStrAcceptsMultiple
36from ... import script
37from ..opt import instrument_argument
39# regular expression that can be used to find supported fits file extensions.
40fits_re = r"\.fit[s]?\b"
43@click.command(short_help="Convert a gen2 repo to gen3.", cls=ButlerCommand)
44@repo_argument(
45 required=True,
46 help="REPO is the URI or path to the gen3 repository. Will be created if it does not already exist",
47)
48@click.option("--gen2root", required=True, help="Root path of the gen 2 repo to be converted.")
49@click.option("--skymap-name", help="Name of the new gen3 skymap (e.g. 'discrete/ci_hsc').")
50@click.option("--skymap-config", help="Path to skymap config file defining the new gen3 skymap.")
51@click.option(
52 "--calibs", help="Path to the gen 2 calibration repo. It can be absolute or relative to gen2root."
53)
54@click.option(
55 "--reruns",
56 multiple=True,
57 callback=split_commas,
58 metavar=typeStrAcceptsMultiple,
59 help=(
60 "List of rerun paths to convert. Output collection names will be "
61 "guessed, which can fail if the Gen2 repository paths do not follow a "
62 "recognized convention. In this case, the command-line interface cannot "
63 "be used."
64 ),
65)
66@transfer_option(help="Mode to use to transfer files into the new repository.")
67@processes_option()
68@config_file_option(
69 help="Path to a `ConvertRepoConfig` override to be included after the Instrument config "
70 "overrides are applied."
71)
72@options_file_option()
73def convert(*args, **kwargs):
74 """Convert one or more Butler gen 2 repositories into a gen 3 repository.
76 This is a highly simplified interface that should only be used to convert
77 suites of gen 2 repositories that contain at most one calibration repo and
78 has no chained reruns. Custom scripts that call ConvertRepoTask should be
79 used on more complex suites of repositories.
80 """
81 script.convert(*args, **kwargs)
84@click.command(short_help="Define visits from exposures.", cls=ButlerCommand)
85@repo_argument(required=True)
86@instrument_argument(required=True)
87@config_file_option(
88 help="Path to a pex_config override to be included after the Instrument config overrides are applied."
89)
90@click.option(
91 "--collections",
92 help="The collections to be searched (in order) when reading datasets.",
93 multiple=True,
94 callback=split_commas,
95 metavar=typeStrAcceptsMultiple,
96)
97@processes_option()
98@options_file_option()
99def define_visits(*args, **kwargs):
100 """Define visits from exposures in the butler registry.
102 The calibration collection containing the camera geometry can not
103 be specified.
104 """
105 script.defineVisits(*args, **kwargs)
108@click.command(short_help="Ingest raw frames.", cls=ButlerCommand)
109@repo_argument(required=True)
110@locations_argument(
111 help="LOCATIONS specifies files to ingest and/or locations to search for files.", required=True
112)
113@regex_option(
114 default=fits_re,
115 help="Regex string used to find files in directories listed in LOCATIONS. "
116 "Searches for fits files by default.",
117)
118@config_option(metavar="TEXT=TEXT", multiple=True)
119@config_file_option(type=click.Path(exists=True, writable=False, file_okay=True, dir_okay=False))
120@run_option(required=False)
121@transfer_option()
122@processes_option()
123@click.option(
124 "--ingest-task",
125 default="lsst.obs.base.RawIngestTask",
126 help="The fully qualified class name of the ingest task to use.",
127)
128@options_file_option()
129def ingest_raws(*args, **kwargs):
130 """Ingest raw frames into from a directory into the butler registry"""
131 script.ingestRaws(*args, **kwargs)
134@click.command(short_help="Add an instrument to the repository", cls=ButlerCommand)
135@repo_argument(required=True)
136@instrument_argument(required=True, nargs=-1, help="The fully-qualified name of an Instrument subclass.")
137@click.option("--update", is_flag=True)
138def register_instrument(*args, **kwargs):
139 """Add an instrument to the data repository."""
140 script.registerInstrument(*args, **kwargs)
143@click.command(short_help="Add an instrument's curated calibrations.", cls=ButlerCommand)
144@repo_argument(required=True)
145@instrument_argument(required=True)
146@click.option(
147 "--collection",
148 required=False,
149 help="Name of the calibration collection that associates datasets with validity ranges.",
150)
151@click.option(
152 "--label",
153 "labels",
154 multiple=True,
155 help=(
156 "Extra strings to include (with automatic delimiters) in all RUN collection names, "
157 "as well as the calibration collection name if it is not provided via --collection."
158 ),
159)
160@options_file_option()
161def write_curated_calibrations(*args, **kwargs):
162 """Add an instrument's curated calibrations to the data repository."""
163 script.writeCuratedCalibrations(*args, **kwargs)