Skip to content

Commit

Permalink
Add module with the constants that define automatic connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Apr 29, 2023
1 parent 32459b0 commit 070126f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/lsst/pipe/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import connectionTypes, pipelineIR
from . import automatic_connection_constants, connectionTypes, pipelineIR
from ._dataset_handle import *
from ._instrument import *
from ._observation_dimension_packer import *
Expand Down
77 changes: 77 additions & 0 deletions python/lsst/pipe/base/automatic_connection_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This file is part of pipe_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/>.

"""Constants used to define the connections automatically added for each
PipelineTask by the execution system.
"""

from __future__ import annotations

__all__ = (
"CONFIG_INIT_OUTPUT_CONNECTION_NAME",
"CONFIG_INIT_OUTPUT_TEMPLATE",
"CONFIG_INIT_OUTPUT_STORAGE_CLASS",
"LOG_OUTPUT_CONNECTION_NAME",
"LOG_OUTPUT_TEMPLATE",
"LOG_OUTPUT_STORAGE_CLASS",
"METADATA_OUTPUT_CONNECTION_NAME",
"METADATA_OUTPUT_TEMPLATE",
"METADATA_OUTPUT_STORAGE_CLASS",
)


CONFIG_INIT_OUTPUT_CONNECTION_NAME: str = "_config"
"""Internal task-side name for the config dataset connection.
"""

CONFIG_INIT_OUTPUT_TEMPLATE: str = "{label}" + CONFIG_INIT_OUTPUT_CONNECTION_NAME
"""String template used to form the name for config init-output dataset
type names.
"""

CONFIG_INIT_OUTPUT_STORAGE_CLASS: str = "Config"
"""Name of the storage class for config init-output datasets.
"""

LOG_OUTPUT_CONNECTION_NAME: str = "_log"
"""Internal task-side name for the log dataset connection.
"""

LOG_OUTPUT_TEMPLATE: str = "{label}" + LOG_OUTPUT_CONNECTION_NAME
"""String template used to form the name for log output dataset type names.
"""

LOG_OUTPUT_STORAGE_CLASS: str = "ButlerLogRecords"
"""Name of the storage class for log output datasets.
"""

METADATA_OUTPUT_CONNECTION_NAME: str = "_metadata"
"""Internal task-side name for the metadata dataset connection.
"""

METADATA_OUTPUT_TEMPLATE: str = "{label}" + METADATA_OUTPUT_CONNECTION_NAME
"""String template used to form the name for task metadata output dataset
type names.
"""

METADATA_OUTPUT_STORAGE_CLASS: str = "TaskMetadata"
"""Name of the storage class for task metadata output datasets.
"""
7 changes: 4 additions & 3 deletions python/lsst/pipe/base/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from lsst.utils import doImportType
from lsst.utils.introspection import get_full_type_name

from . import automatic_connection_constants as acc
from . import pipelineIR, pipeTools
from ._task_metadata import TaskMetadata
from .config import PipelineTaskConfig
Expand Down Expand Up @@ -172,7 +173,7 @@ def __init__(
@property
def configDatasetName(self) -> str:
"""Name of a dataset type for configuration of this task (`str`)"""
return self.label + "_config"
return acc.CONFIG_INIT_OUTPUT_TEMPLATE.format(label=self.label)

@property
def metadataDatasetName(self) -> Optional[str]:
Expand All @@ -198,15 +199,15 @@ def makeMetadataDatasetName(cls, label: str) -> str:
name : `str`
Name of the task's metadata dataset type.
"""
return f"{label}_metadata"
return acc.METADATA_OUTPUT_TEMPLATE.format(label=label)

@property
def logOutputDatasetName(self) -> Optional[str]:
"""Name of a dataset type for log output from this task, `None` if
logs are not to be saved (`str`)
"""
if cast(PipelineTaskConfig, self.config).saveLogOutput:
return self.label + "_log"
return acc.LOG_OUTPUT_TEMPLATE.format(label=self.label)
else:
return None

Expand Down

0 comments on commit 070126f

Please sign in to comment.