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-38601: Couple of small improvements in test methods #315

Merged
merged 3 commits into from
Apr 10, 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
3 changes: 2 additions & 1 deletion python/lsst/pipe/base/tests/no_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def run(self, input: Union[TaskMetadata, Dict[str, int]]) -> Struct: # type: ig
"""
self.log.info("Run method given data of type: %s", get_full_type_name(input))
output = input.copy()
output[self.config.key] = self.config.value
config = cast(NoDimensionsTestConfig, self.config)
output[config.key] = config.value

# Can change the return type via configuration.
if "TaskMetadata" in cast(NoDimensionsTestConfig, self.config).outputSC:
Expand Down
12 changes: 10 additions & 2 deletions python/lsst/pipe/base/tests/simpleQGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from lsst.daf.butler.core.logging import ButlerLogRecords
from lsst.resources import ResourcePath
from lsst.utils import doImportType
from lsst.utils.introspection import get_full_type_name

from .. import connectionTypes as cT
from .._instrument import Instrument
Expand Down Expand Up @@ -300,11 +301,13 @@ def populateButler(
if instrument is not None:
instrument_class = doImportType(instrument)
instrumentName = instrument_class.getName()
instrumentClass = get_full_type_name(instrument_class)
else:
instrumentName = "INSTR"
instrumentClass = None

# Add all needed dimensions to registry
butler.registry.insertDimensionData("instrument", dict(name=instrumentName))
butler.registry.insertDimensionData("instrument", dict(name=instrumentName, class_name=instrumentClass))
butler.registry.insertDimensionData("detector", dict(instrument=instrumentName, id=0, full_name="det0"))

taskDefMap = dict((taskDef.label, taskDef) for taskDef in taskDefs)
Expand Down Expand Up @@ -345,6 +348,7 @@ def makeSimpleQGraph(
root: Optional[str] = None,
callPopulateButler: bool = True,
run: str = "test",
instrument: Optional[str] = None,
skipExistingIn: Any = None,
inMemory: bool = True,
userQuery: str = "",
Expand Down Expand Up @@ -380,6 +384,10 @@ def makeSimpleQGraph(
run : `str`, optional
Name of the RUN collection to add to butler, only used if ``butler``
is None.
instrument : `str` or `None`, optional
The importable name of an instrument to be added to the pipeline or
if no instrument should be added then an empty string or `None`, by
default `None`. Only used if ``pipeline`` is `None`.
skipExistingIn
Expressions representing the collections to search for existing
output datasets that should be skipped. See
Expand Down Expand Up @@ -414,7 +422,7 @@ def makeSimpleQGraph(
"""

if pipeline is None:
pipeline = makeSimplePipeline(nQuanta=nQuanta)
pipeline = makeSimplePipeline(nQuanta=nQuanta, instrument=instrument)

if butler is None:
if root is None:
Expand Down