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