Skip to content

Commit

Permalink
Change inputName to outputName
Browse files Browse the repository at this point in the history
cannot run multiple objectTableAnalysis Tasks in a single pipeline
that print out the same dataset type name objectTable_tract_metrics.
Need finer granularity, and if it needs to be set on the pipeline,
the user is really setting the outputName here.
  • Loading branch information
yalsayyad committed Jul 22, 2022
1 parent 0a28513 commit 0aaade2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions pipelines/coaddQualityCore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tasks:
class: lsst.analysis.tools.tasks.ObjectTableTractAnalysisTask
config:
bands: ['u', 'g', 'r', 'i', 'z', 'y']
connections.outputName: objectTableCore
plots.shapeSizeFractionalDiffScatter: ShapeSizeFractionalDiffScatter
metrics.shapeSizeFractionalMetric: ShapeSizeFractionalMetric
python: |
Expand Down
1 change: 1 addition & 0 deletions pipelines/coaddQualityExtended.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tasks:
analyzeObjectTableExtended:
class: lsst.analysis.tools.tasks.ObjectTableTractAnalysisTask
config:
connections.outputName: objectTableExtended
bands: ['u', 'g', 'r', 'i', 'z', 'y']
# set plots to run
plots.ap12PsfSkyPlot: Ap12PsfSkyPlot
Expand Down
20 changes: 10 additions & 10 deletions python/lsst/analysis/tools/tasks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@


class AnalysisBaseConnections(
PipelineTaskConnections, dimensions={}, defaultTemplates={"inputName": "Placeholder"}
PipelineTaskConnections, dimensions={}, defaultTemplates={"outputName": "Placeholder"}
):
r"""Base class for Connections used for AnalysisTools PipelineTasks.
This class has a pre-defined output connection for the
MetricMeasurementMapping. The dataset type name for this connection is
determined by the template ``inputName``.
determined by the template ``outputName``.
Output connections for plots created by `AnalysisPlot`\ s are created
dynamically when an instance of the class is created. The init method
Expand All @@ -69,18 +69,18 @@ class AnalysisBaseConnections(

metrics = ct.Output(
doc="Metrics calculated on input dataset type",
name="{inputName}_metrics",
name="{outputName}_metrics",
storageClass="MetricMeasurementBundle",
)

def __init__(self, *, config: AnalysisBaseConfig = None): # type: ignore
# Validate that the inputName template has been set in config. This
# Validate that the outputName template has been set in config. This
# should have been checked early with the configs validate method, but
# it is possible for someone to manually create everything in a script
# without running validate, so also check it late here.
if (inputName := config.connections.inputName) == "Placeholder": # type: ignore
if (outputName := config.connections.outputName) == "Placeholder": # type: ignore
raise RuntimeError(
"Subclasses must specify an alternative value for the defaultTemplate `inputName`"
"Subclasses must specify an alternative value for the defaultTemplate `outputName`"
)
super().__init__(config=config)

Expand Down Expand Up @@ -117,7 +117,7 @@ def __init__(self, *, config: AnalysisBaseConfig = None): # type: ignore

# For each of the names found, create output connections.
for name in names:
name = f"{inputName}_{name}"
name = f"{outputName}_{name}"
if name in self.outputs or name in existingNames:
raise NameError(
f"Plot with name {name} conflicts with existing connection"
Expand Down Expand Up @@ -158,8 +158,8 @@ class AnalysisBaseConfig(PipelineTaskConfig, pipelineConnections=AnalysisBaseCon
def validate(self):
super().validate()
# Validate that the required connections template is set.
if self.connections.inputName == "Placeholder": # type: ignore
raise RuntimeError("Connections class 'inputName' must have a config explicitly set")
if self.connections.outputName == "Placeholder": # type: ignore
raise RuntimeError("Connections class 'outputName' must have a config explicitly set")


class _StandinPlotInfo(dict):
Expand Down Expand Up @@ -242,7 +242,7 @@ def run(self, *, data: KeyedData | None = None, **kwargs) -> Struct:
if data is None:
raise ValueError("data must not be none")
results = Struct()
plotKey = f"{self.config.connections.inputName}_{{name}}" # type: ignore
plotKey = f"{self.config.connections.outputName}_{{name}}" # type: ignore
if "bands" not in kwargs:
kwargs["bands"] = list(self.config.bands)
for name, value in self.runPlots(data, **kwargs).getDict().items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class ObjectTableTractAnalysisConnections(
AnalysisBaseConnections,
dimensions=("skymap", "tract"),
defaultTemplates={"inputName": "objectTable_tract"},
defaultTemplates={"outputName": "objectTable_tract"},
):
data = ct.Input(
doc="Tract based object table to load from the butler",
Expand Down

0 comments on commit 0aaade2

Please sign in to comment.