LSSTApplications  19.0.0-14-gb0260a2+4cd158d902,20.0.0+126303c00d,20.0.0+2f3d0e5c40,20.0.0+36ef800059,20.0.0+8d0ab3d2aa,20.0.0+bebc1f60e8,20.0.0+e271cb8385,20.0.0+e2e26847c2,20.0.0+eaf69e532d,20.0.0-1-g10df615+d6cc7df41f,20.0.0-1-g253301a+36ef800059,20.0.0-1-g2b7511a+bebc1f60e8,20.0.0-1-g4d801e7+6fee74fd2f,20.0.0-1-g5b95a8c+6c6c03acd5,20.0.0-1-g660595b+f45b7d88f4,20.0.0-1-gc96f8cb+d4517efcba,20.0.0-1-gd1c87d7+85c46248f3,20.0.0-1-gedffbd8+17eaf5db5c,20.0.0-16-g111fe95+d4517efcba,20.0.0-16-g233ea98+c27695f312,20.0.0-17-ga9337b4+cbc55e0393,20.0.0-19-gcdd82e7+317a1f5500,20.0.0-2-g4dae9ad+d4517efcba,20.0.0-2-g7818986+85c46248f3,20.0.0-2-gec03fae+ff10c6d78d,20.0.0-29-g26d13349+2d5e4f2fd7,20.0.0-3-g4cc78c6+63636aeed8,20.0.0-3-g6a8623c+317a1f5500,20.0.0-3-g750bffe+699cb77157,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-5-g357b56b+f45b7d88f4,20.0.0-5-gfcebe35+ef19f498ed,20.0.0-54-gba713e9+a7d430d1e1,20.0.0-7-gcda7bf1+31d79aecbb,20.0.0-9-g61a2a9a3d+14f89e4eca,20.0.0-9-g70cec07d+482e8042f7,w.2020.40
LSSTDataManagementBasePackage
commands.py
Go to the documentation of this file.
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/>.
21 
22 import click
23 
24 from lsst.daf.butler.cli.opt import (repo_argument,
25  config_option,
26  config_file_option,
27  locations_argument,
28  options_file_option,
29  processes_option,
30  regex_option,
31  run_option,
32  transfer_option
33  )
34 from lsst.daf.butler.cli.utils import (cli_handle_exception, split_commas, typeStrAcceptsMultiple)
35 from ..opt import instrument_argument
36 from ... import script
37 
38 
39 # regular expression that can be used to find supported fits file extensions.
40 fits_re = r"\.fit[s]?\b"
41 
42 
43 @click.command(short_help="Convert a gen2 repo to gen3.")
44 @repo_argument(required=True,
45  help="REPO is the URI or path to the gen3 repository. Will be created if it does not already "
46  "exist")
47 @click.option("--gen2root", required=True,
48  help="Root path of the gen 2 repo to be converted.")
49 @click.option("--skymap-name",
50  help="Name of the new gen3 skymap (e.g. 'discrete/ci_hsc').")
51 @click.option("--skymap-config",
52  help="Path to skymap config file defining the new gen3 skymap.")
53 @click.option("--calibs",
54  help="Path to the gen 2 calibration repo. It can be absolute or relative to gen2root.")
55 @click.option("--reruns", multiple=True, callback=split_commas, metavar=typeStrAcceptsMultiple,
56  help="List of gen 2 reruns to convert.")
57 @transfer_option(help="Mode to use to transfer files into the new repository.")
58 @config_file_option(help="Path to a `ConvertRepoConfig` override to be included after the Instrument config "
59  "overrides are applied.")
60 @options_file_option()
61 def convert(*args, **kwargs):
62  """Convert a Butler gen 2 repository into a gen 3 repository."""
63  cli_handle_exception(script.convert, *args, **kwargs)
64 
65 
66 @click.command(short_help="Define visits from exposures.")
67 @repo_argument(required=True)
68 @instrument_argument(required=True)
69 @config_file_option(help="Path to a pex_config override to be included after the Instrument config overrides "
70  "are applied.")
71 @click.option("--collections",
72  help="The collections to be searched (in order) when reading datasets.",
73  multiple=True,
74  callback=split_commas,
75  metavar=typeStrAcceptsMultiple)
76 @options_file_option()
77 def define_visits(*args, **kwargs):
78  """Define visits from exposures in the butler registry."""
79  cli_handle_exception(script.defineVisits, *args, **kwargs)
80 
81 
82 @click.command(short_help="Ingest raw frames.")
83 @repo_argument(required=True)
84 @locations_argument(help="LOCATIONS specifies files to ingest and/or locations to search for files.",
85  required=True)
86 @regex_option(default=fits_re,
87  help="Regex string used to find files in directories listed in LOCATIONS. "
88  "Searches for fits files by default.")
89 @config_option(metavar="TEXT=TEXT", multiple=True)
90 @config_file_option(type=click.Path(exists=True, writable=False, file_okay=True, dir_okay=False))
91 @run_option(required=False)
92 @transfer_option()
93 @processes_option()
94 @click.option("--ingest-task", default="lsst.obs.base.RawIngestTask", help="The fully qualified class name "
95  "of the ingest task to use.")
96 @options_file_option()
97 def ingest_raws(*args, **kwargs):
98  """Ingest raw frames into from a directory into the butler registry"""
99  cli_handle_exception(script.ingestRaws, *args, **kwargs)
100 
101 
102 @click.command(short_help="Add an instrument to the repository")
103 @repo_argument(required=True)
104 @instrument_argument(required=True, nargs=-1, help="The fully-qualified name of an Instrument subclass.")
105 def register_instrument(*args, **kwargs):
106  """Add an instrument to the data repository.
107  """
108  cli_handle_exception(script.registerInstrument, *args, **kwargs)
109 
110 
111 @click.command(short_help="Add an instrument's curated calibrations.")
112 @repo_argument(required=True)
113 @instrument_argument(required=True)
114 @click.option("--collection", required=False,
115  help="Name of the calibration collection that associates datasets with validity ranges.")
116 @click.option("--suffix", required=False,
117  help=("Name suffix to append (with an automatic delimiter) to all RUN collection names "
118  "as well as the calibration collection name if it is not provided via --collection."))
119 @options_file_option()
120 def write_curated_calibrations(*args, **kwargs):
121  """Add an instrument's curated calibrations to the data repository.
122  """
123  cli_handle_exception(script.writeCuratedCalibrations, *args, **kwargs)
cmd.commands.register_instrument
def register_instrument(*args, **kwargs)
Definition: commands.py:105
cmd.commands.define_visits
def define_visits(*args, **kwargs)
Definition: commands.py:77
cmd.commands.write_curated_calibrations
def write_curated_calibrations(*args, **kwargs)
Definition: commands.py:120
cmd.commands.convert
def convert(*args, **kwargs)
Definition: commands.py:61
cmd.commands.ingest_raws
def ingest_raws(*args, **kwargs)
Definition: commands.py:97
opt.arguments.instrument_argument
instrument_argument
Definition: arguments.py:25