-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-24584: create an ingestRaws butler command #241
Changes from all commits
c7956bb
02117c2
da12ba1
68193c7
4f7dec0
b06a585
f746965
6b3c0c2
a75f865
c85de44
3f88267
d6d487f
b6130bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,24 +36,41 @@ class ButlerCmdTestBase(metaclass=abc.ABCMeta): | |
Subclass from this, then `unittest.TestCase` to get a working test suite. | ||
""" | ||
|
||
instrument_class = None | ||
"""The fully qualified instrument class. | ||
""" | ||
@staticmethod | ||
@abc.abstractmethod | ||
def instrumentClass(): | ||
"""Get the fully qualified instrument class. | ||
|
||
Returns | ||
------- | ||
`str` | ||
The fully qualified instrument class. | ||
""" | ||
pass | ||
|
||
@staticmethod | ||
@abc.abstractmethod | ||
def instrumentName(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that the Instrument class itself defines the name, wouldn't it be easier for everyone if a subclass could specify an Instrument class directly (not a string, although a string could be doImported) and the name was retrieve from that directly? It would prevent an obvious case of duplication of information in the tests where the test subclass now needs to specify the name and the class name and ensure that they all match with the name that they already know is defined in the Instrument class. |
||
"""Get the instrument name. | ||
|
||
instrument_name = None | ||
"""The instrument name.""" | ||
Returns | ||
------- | ||
`str` | ||
The name of the instrument. | ||
""" | ||
pass | ||
|
||
def test_cli(self): | ||
runner = click.testing.CliRunner() | ||
with runner.isolated_filesystem(): | ||
result = runner.invoke(butler.cli, ["create", "here"]) | ||
self.assertEqual(result.exit_code, 0, result.output) | ||
self.assertEqual(result.exit_code, 0, f"output: {result.output} exception: {result.exception}") | ||
result = runner.invoke(butler.cli, ["register-instrument", | ||
"here", | ||
"-i", self.instrument_class]) | ||
self.assertEqual(result.exit_code, 0, result.output) | ||
"-i", self.instrumentClass()]) | ||
self.assertEqual(result.exit_code, 0, f"output: {result.output} exception: {result.exception}") | ||
result = runner.invoke(butler.cli, ["write-curated-calibrations", | ||
"here", | ||
"-i", self.instrument_name, | ||
"--output-run", "calib/hsc"]) | ||
self.assertEqual(result.exit_code, 0, result.output) | ||
"-i", self.instrumentName(), | ||
"--output-run", "output_run"]) | ||
self.assertEqual(result.exit_code, 0, f"output: {result.output} exception: {result.exception}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 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/>. | ||
|
||
import click | ||
|
||
from lsst.daf.butler.cli.opt import repo_argument, config_option, config_file_option, run_option | ||
from lsst.daf.butler.cli.utils import cli_handle_exception | ||
from ...script import ingestRaws | ||
|
||
|
||
@click.command() | ||
@repo_argument(required=True) | ||
@config_option() | ||
@config_file_option() | ||
@run_option(required=True) | ||
@click.option("-d", "--dir", "directory", | ||
help="The path to the directory containing the raws to ingest.") | ||
@click.option("-f", "--file", help="The name of a file containing raws to ingest.") | ||
@click.option("-t", "--transfer", help="The external data transfer type.", default="auto") | ||
@click.option("--ingest-task", default="lsst.obs.base.RawIngestTask", help="The fully qualified class name " | ||
"of the ingest task to use.") | ||
def ingest_raws(*args, **kwargs): | ||
cli_handle_exception(ingestRaws, *args, **kwargs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ cmd: | |
commands: | ||
- register-instrument | ||
- write-curated-calibrations | ||
- ingest-raws |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These do indeed force a test implementation to specify the value but in most cases the tests will fail if they do it wrong. It's a shame that a subclass can't implement by doing a simple class property but the use of static method here prevents that.
Also instrumentClass as a name makes you think this is the class but it's not, it's the class name.