Skip to content

Commit

Permalink
Merge branch 'tickets/DM-25627'
Browse files Browse the repository at this point in the history
  • Loading branch information
n8pease committed Aug 18, 2020
2 parents 6805a3c + fdb103b commit 35a73e1
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 143 deletions.
14 changes: 6 additions & 8 deletions python/lsst/obs/base/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@

from lsst.daf.butler.cli.opt import (repo_argument, config_option, config_file_option, run_option,
transfer_option)
from lsst.daf.butler.cli.utils import (cli_handle_exception, ParameterType, split_commas,
typeStrAcceptsMultiple)
from ..opt import instrument_parameter
from lsst.daf.butler.cli.utils import (cli_handle_exception, split_commas, typeStrAcceptsMultiple)
from ..opt import instrument_argument, instrument_option
from ... import script


Expand Down Expand Up @@ -60,15 +59,15 @@ def convert(*args, **kwargs):
multiple=True,
callback=split_commas,
metavar=typeStrAcceptsMultiple)
@instrument_parameter(required=True)
@instrument_option(required=True)
def define_visits(*args, **kwargs):
"""Define visits from exposures in the butler registry."""
cli_handle_exception(script.defineVisits, *args, **kwargs)


@click.command(short_help="Ingest raw frames.")
@repo_argument(required=True)
@config_option(metavar="TEXT=TEXT", multiple=True, split_kv=True)
@config_option(metavar="TEXT=TEXT", multiple=True)
@config_file_option(type=click.Path(exists=True, writable=False, file_okay=True, dir_okay=False))
@run_option(required=False)
@click.option("-d", "--dir", "directory",
Expand All @@ -84,8 +83,7 @@ def ingest_raws(*args, **kwargs):

@click.command(short_help="Add an instrument to the repository")
@repo_argument(required=True)
@instrument_parameter(parameterType=ParameterType.ARGUMENT, required=True, multiple=True,
help="The fully-qualified name of an Instrument subclass.")
@instrument_argument(required=True, nargs=-1, help="The fully-qualified name of an Instrument subclass.")
def register_instrument(*args, **kwargs):
"""Add an instrument to the data repository.
"""
Expand All @@ -94,7 +92,7 @@ def register_instrument(*args, **kwargs):

@click.command(short_help="Add an instrument's curated calibrations.")
@repo_argument(required=True)
@instrument_parameter(required=True)
@instrument_option(required=True)
@run_option(required=False)
def write_curated_calibrations(*args, **kwargs):
"""Add an instrument's curated calibrations to the data repository.
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/obs/base/cli/opt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .instrument import instrument_parameter
from .arguments import *
from .options import *
26 changes: 26 additions & 0 deletions python/lsst/obs/base/cli/opt/arguments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file is part of obs_base.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (http://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from lsst.daf.butler.cli.utils import MWArgumentDecorator


instrument_argument = MWArgumentDecorator("instrument",
help="The name or fully-qualified class name of an instrument.")
56 changes: 0 additions & 56 deletions python/lsst/obs/base/cli/opt/instrument.py

This file was deleted.

26 changes: 26 additions & 0 deletions python/lsst/obs/base/cli/opt/options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file is part of obs_base.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (http://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from lsst.daf.butler.cli.utils import MWOptionDecorator


instrument_option = MWOptionDecorator("-i", "--instrument",
help="The name or fully-qualified class name of an instrument.")
18 changes: 11 additions & 7 deletions tests/test_cliCmdConvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@

class ConvertTestCase(CliCmdTestBase, unittest.TestCase):

defaultExpected = dict(skymap_name=None,
skymap_config=None,
calibs=None,
reruns=(),
transfer="auto",
config_file=None)
@staticmethod
def defaultExpected():
return dict(skymap_name=None,
skymap_config=None,
calibs=None,
reruns=(),
transfer="auto",
config_file=None)

command = convert
@staticmethod
def command():
return convert

def test_repoInstrGen2root(self):
"""Test the most basic required arguments."""
Expand Down
10 changes: 7 additions & 3 deletions tests/test_cliCmdDefineVisits.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@

class DefineVisitsTest(CliCmdTestBase, unittest.TestCase):

defaultExpected = dict(config_file=None,
collections=())
@staticmethod
def defaultExpected():
return dict(config_file=None,
collections=())

command = define_visits
@staticmethod
def command():
return define_visits

def test_repoBasic(self):
"""Test the most basic required arguments."""
Expand Down
8 changes: 6 additions & 2 deletions tests/test_cliCmdRegisterInstrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@

class RegisterInstrumentTest(CliCmdTestBase, unittest.TestCase):

defaultExpected = dict()
@staticmethod
def defaultExpected():
return dict()

command = register_instrument
@staticmethod
def command():
return register_instrument

def test_repoBasic(self):
"""Test the most basic required arguments."""
Expand Down
18 changes: 11 additions & 7 deletions tests/test_cliCmdTestIngest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@

class IngestRawsTestCase(CliCmdTestBase, unittest.TestCase):

defaultExpected = dict(directory=None,
file=None,
transfer="auto",
ingest_task="lsst.obs.base.RawIngestTask",
config={},
config_file=None)
@staticmethod
def defaultExpected():
return dict(directory=None,
file=None,
transfer="auto",
ingest_task="lsst.obs.base.RawIngestTask",
config={},
config_file=None)

command = ingest_raws
@staticmethod
def command():
return ingest_raws

def test_repoAndOutput(self):
"""Test the most basic required arguments, repo and output run"""
Expand Down
8 changes: 6 additions & 2 deletions tests/test_cliCmdWriteCuratedCalibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@

class WriteCuratedCalibrationsTest(CliCmdTestBase, unittest.TestCase):

defaultExpected = dict()
@staticmethod
def defaultExpected():
return dict()

command = write_curated_calibrations
@staticmethod
def command():
return write_curated_calibrations

def test_repoBasic(self):
"""Test the most basic required arguments."""
Expand Down
57 changes: 0 additions & 57 deletions tests/test_cliOption.py

This file was deleted.

0 comments on commit 35a73e1

Please sign in to comment.