Skip to content
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-37950: Allow the raw definition to be specified in the instrument class #305

Merged
merged 3 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/changes/DM-37950.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An ``Instrument`` can now specify the dataset type definition that it would like to use for raw data.
This can be done by setting the ``raw_definition`` class property to a tuple of the dataset type name, the dimensions to use for this dataset type, and the storage class name.
5 changes: 5 additions & 0 deletions python/lsst/pipe/base/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class Instrument(metaclass=ABCMeta):
"""Instrument specific name to use when locating a policy or configuration
file in the file system."""

raw_definition: tuple[str, tuple[str, ...], str] | None = None
"""Dataset type definition to use for "raw" datasets. This is a tuple
of the dataset type name, a tuple of dimension names, and the storage class
name. If `None` the ingest system will use its default definition."""

def __init__(self, collection_prefix: Optional[str] = None):
if collection_prefix is None:
collection_prefix = self.getName()
Expand Down
5 changes: 5 additions & 0 deletions tests/test_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def getRawFormatter(self, dataId):
class BadInstrument(DummyInstrument):
"""Instrument with wrong class name."""

raw_definition = ("raw2", ("instrument", "detector", "exposure"), "StructuredDataDict")

@classmethod
def getName(cls):
return "BadInstrument"
Expand Down Expand Up @@ -94,6 +96,9 @@ def setUp(self):
def test_basics(self):
self.assertEqual(self.instrument.getName(), self.name)
self.assertEqual(self.instrument.getRawFormatter({}), JsonFormatter)
self.assertIsNone(DummyInstrument.raw_definition)
raw = BadInstrument.raw_definition
self.assertEqual(raw[2], "StructuredDataDict")

def test_register(self):
"""Test that register() sets appropriate Dimensions."""
Expand Down
11 changes: 0 additions & 11 deletions tests/test_quantumGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@
from lsst.pipe.base.graph.quantumNode import QuantumNode
from lsst.utils.introspection import get_full_type_name

try:
import boto3
from moto import mock_s3
except ImportError:
boto3 = None

def mock_s3(cls):
"""A no-op decorator in case moto mock_s3 can not be imported."""
return cls


METADATA = {"a": [1, 2, 3]}


Expand Down