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