LSSTApplications  21.0.0+1b62c9342b,21.0.0+45a059f35e,21.0.0-1-ga51b5d4+ceb9cf20a3,21.0.0-17-gf9a0284+9e5b25d042,21.0.0-2-g103fe59+513edb8842,21.0.0-2-g1367e85+d9bb5204cb,21.0.0-2-g2909d54+45a059f35e,21.0.0-2-g45278ab+1b62c9342b,21.0.0-2-g4bc9b9f+36532ac5d2,21.0.0-2-g5242d73+d9bb5204cb,21.0.0-2-g54e2caa+ffbb918bba,21.0.0-2-g66bcc37+0525a04256,21.0.0-2-g7f82c8f+8938dec807,21.0.0-2-g8dde007+7bfb5851c8,21.0.0-2-g8f08a60+73884b2cf5,21.0.0-2-g973f35b+f93e1880fd,21.0.0-2-ga326454+8938dec807,21.0.0-2-ga63a54e+deb0f059c3,21.0.0-2-ga885a99+9a92674037,21.0.0-2-gc738bc1+5ce50b2a03,21.0.0-2-gde069b7+5a8f2956b8,21.0.0-2-ge17e5af+d9bb5204cb,21.0.0-2-ge712728+d5c34dc911,21.0.0-2-gecfae73+8bdf007ced,21.0.0-2-gfc62afb+d9bb5204cb,21.0.0-21-g006371a9+c7749adc24,21.0.0-3-g4c5b185+4e2de95c30,21.0.0-3-g6d51c4a+0525a04256,21.0.0-3-gaa929c8+fca53d2b73,21.0.0-3-gd222c45+afc8332dbe,21.0.0-3-gd5de2f2+0525a04256,21.0.0-4-g3300ddd+1b62c9342b,21.0.0-4-g8a80011+808ce5273f,21.0.0-5-gb7080ec+2fa830a448,21.0.0-5-gcff38f6+03a88541ab,21.0.0-6-gd3283ba+fca53d2b73,21.0.0-8-g19111d86+898b2b281f,21.0.0-8-gd9c33f4a0+b58bb1f4d6,w.2021.03
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 (
35  ButlerCommand,
36  split_commas,
37  typeStrAcceptsMultiple
38 )
39 from ..opt import instrument_argument
40 from ... import script
41 
42 
43 # regular expression that can be used to find supported fits file extensions.
44 fits_re = r"\.fit[s]?\b"
45 
46 
47 @click.command(short_help="Convert a gen2 repo to gen3.", cls=ButlerCommand)
48 @repo_argument(required=True,
49  help="REPO is the URI or path to the gen3 repository. Will be created if it does not already "
50  "exist")
51 @click.option("--gen2root", required=True,
52  help="Root path of the gen 2 repo to be converted.")
53 @click.option("--skymap-name",
54  help="Name of the new gen3 skymap (e.g. 'discrete/ci_hsc').")
55 @click.option("--skymap-config",
56  help="Path to skymap config file defining the new gen3 skymap.")
57 @click.option("--calibs",
58  help="Path to the gen 2 calibration repo. It can be absolute or relative to gen2root.")
59 @click.option("--reruns", multiple=True, callback=split_commas, metavar=typeStrAcceptsMultiple,
60  help=("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 @transfer_option(help="Mode to use to transfer files into the new repository.")
65 @processes_option()
66 @config_file_option(help="Path to a `ConvertRepoConfig` override to be included after the Instrument config "
67  "overrides are applied.")
68 @options_file_option()
69 def convert(*args, **kwargs):
70  """Convert one or more Butler gen 2 repositories into a gen 3 repository.
71 
72  This is a highly simplified interface that should only be used to convert
73  suites of gen 2 repositories that contain at most one calibration repo and
74  has no chained reruns. Custom scripts that call ConvertRepoTask should be
75  used on more complex suites of repositories.
76  """
77  script.convert(*args, **kwargs)
78 
79 
80 @click.command(short_help="Define visits from exposures.", cls=ButlerCommand)
81 @repo_argument(required=True)
82 @instrument_argument(required=True)
83 @config_file_option(help="Path to a pex_config override to be included after the Instrument config overrides "
84  "are applied.")
85 @click.option("--collections",
86  help="The collections to be searched (in order) when reading datasets.",
87  multiple=True,
88  callback=split_commas,
89  metavar=typeStrAcceptsMultiple)
90 @processes_option()
91 @options_file_option()
92 def define_visits(*args, **kwargs):
93  """Define visits from exposures in the butler registry."""
94  script.defineVisits(*args, **kwargs)
95 
96 
97 @click.command(short_help="Ingest raw frames.", cls=ButlerCommand)
98 @repo_argument(required=True)
99 @locations_argument(help="LOCATIONS specifies files to ingest and/or locations to search for files.",
100  required=True)
101 @regex_option(default=fits_re,
102  help="Regex string used to find files in directories listed in LOCATIONS. "
103  "Searches for fits files by default.")
104 @config_option(metavar="TEXT=TEXT", multiple=True)
105 @config_file_option(type=click.Path(exists=True, writable=False, file_okay=True, dir_okay=False))
106 @run_option(required=False)
107 @transfer_option()
108 @processes_option()
109 @click.option("--ingest-task", default="lsst.obs.base.RawIngestTask", help="The fully qualified class name "
110  "of the ingest task to use.")
111 @options_file_option()
112 def ingest_raws(*args, **kwargs):
113  """Ingest raw frames into from a directory into the butler registry"""
114  script.ingestRaws(*args, **kwargs)
115 
116 
117 @click.command(short_help="Add an instrument to the repository", cls=ButlerCommand)
118 @repo_argument(required=True)
119 @instrument_argument(required=True, nargs=-1, help="The fully-qualified name of an Instrument subclass.")
120 def register_instrument(*args, **kwargs):
121  """Add an instrument to the data repository.
122  """
123  script.registerInstrument(*args, **kwargs)
124 
125 
126 @click.command(short_help="Add an instrument's curated calibrations.", cls=ButlerCommand)
127 @repo_argument(required=True)
128 @instrument_argument(required=True)
129 @click.option("--collection", required=False,
130  help="Name of the calibration collection that associates datasets with validity ranges.")
131 @click.option("--label", "labels", multiple=True,
132  help=("Extra strings to include (with automatic delimiters) in all RUN collection names, "
133  "as well as the calibration collection name if it is not provided via --collection."))
134 @options_file_option()
135 def write_curated_calibrations(*args, **kwargs):
136  """Add an instrument's curated calibrations to the data repository.
137  """
138  script.writeCuratedCalibrations(*args, **kwargs)
cmd.commands.register_instrument
def register_instrument(*args, **kwargs)
Definition: commands.py:120
cmd.commands.define_visits
def define_visits(*args, **kwargs)
Definition: commands.py:92
cmd.commands.write_curated_calibrations
def write_curated_calibrations(*args, **kwargs)
Definition: commands.py:135
cmd.commands.convert
def convert(*args, **kwargs)
Definition: commands.py:69
cmd.commands.ingest_raws
def ingest_raws(*args, **kwargs)
Definition: commands.py:112
opt.arguments.instrument_argument
instrument_argument
Definition: arguments.py:25