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-39377: Deprecate PipelineTaskConfig.saveMetadata field #341

Merged
merged 4 commits into from
Jun 6, 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-39377.removal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `PipelineTaskConfig.saveMetadata` field is now deprecated, will be removed after v26. Its value is ignored and task metadata is always saved.
- `ResourceConfig` class is removed, it was never used.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering :: Astronomy",
]
keywords=["lsst"]
Expand Down
26 changes: 2 additions & 24 deletions python/lsst/pipe/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from __future__ import annotations

__all__ = ["ResourceConfig", "PipelineTaskConfig"]
__all__ = ["PipelineTaskConfig"]

# -------------------------------
# Imports of standard modules --
Expand Down Expand Up @@ -200,6 +200,7 @@ class to allow configuration of the connections class. This dynamically
default=True,
optional=False,
doc="Flag to enable/disable metadata saving for a task, enabled by default.",
deprecated="This field is deprecated and will be removed after v26.",
)
saveLogOutput = pexConfig.Field[bool](
default=True,
Expand Down Expand Up @@ -254,26 +255,3 @@ def applyConfigOverrides(
for key, value in subConfig.rest.items():
overrides.addValueOverride(key, value)
overrides.applyTo(self)


class ResourceConfig(pexConfig.Config):
"""Configuration for resource requirements.

This configuration class will be used by some activators to estimate
resource use by pipeline. Additionally some tasks could use it to adjust
their resource use (e.g. reduce the number of threads).

For some resources their limit can be estimated by corresponding task,
in that case task could set the field value. For many fields defined in
this class their associated resource used by a task will depend on the
size of the data and is not known in advance. For these resources their
value will be configured through overrides based on some external
estimates.
"""

minMemoryMB = pexConfig.Field[int](
default=None,
optional=True,
doc="Minimal memory needed by task, can be None if estimate is unknown.",
)
minNumCores = pexConfig.Field[int](default=1, doc="Minimal number of cores needed by task.")
39 changes: 17 additions & 22 deletions python/lsst/pipe/base/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,9 @@ def configDatasetName(self) -> str:
return acc.CONFIG_INIT_OUTPUT_TEMPLATE.format(label=self.label)

@property
def metadataDatasetName(self) -> Optional[str]:
"""Name of a dataset type for metadata of this task, `None` if
metadata is not to be saved (`str`)
"""
if self.config.saveMetadata:
return self.makeMetadataDatasetName(self.label)
else:
return None
def metadataDatasetName(self) -> str:
"""Name of a dataset type for metadata of this task (`str`)"""
return self.makeMetadataDatasetName(self.label)

@classmethod
def makeMetadataDatasetName(cls, label: str) -> str:
Expand Down Expand Up @@ -1067,22 +1062,22 @@ def makeDatasetTypesSet(

# optionally add output dataset for metadata
outputs = makeDatasetTypesSet("outputs", is_input=False, freeze=False)
if taskDef.metadataDatasetName is not None:
# Metadata is supposed to be of the TaskMetadata type, its
# dimensions correspond to a task quantum.
dimensions = registry.dimensions.extract(taskDef.connections.dimensions)

# Allow the storage class definition to be read from the existing
# dataset type definition if present.
try:
current = registry.getDatasetType(taskDef.metadataDatasetName)
except KeyError:
# No previous definition so use the default.
storageClass = "TaskMetadata" if _TASK_METADATA_TYPE is TaskMetadata else "PropertySet"
else:
storageClass = current.storageClass.name
# Metadata is supposed to be of the TaskMetadata type, its dimensions
# correspond to a task quantum.
dimensions = registry.dimensions.extract(taskDef.connections.dimensions)

# Allow the storage class definition to be read from the existing
# dataset type definition if present.
try:
current = registry.getDatasetType(taskDef.metadataDatasetName)
except KeyError:
# No previous definition so use the default.
storageClass = "TaskMetadata" if _TASK_METADATA_TYPE is TaskMetadata else "PropertySet"
else:
storageClass = current.storageClass.name
outputs.update({DatasetType(taskDef.metadataDatasetName, dimensions, storageClass)})

outputs.update({DatasetType(taskDef.metadataDatasetName, dimensions, storageClass)})
if taskDef.logOutputDatasetName is not None:
# Log output dimensions correspond to a task quantum.
dimensions = registry.dimensions.extract(taskDef.connections.dimensions)
Expand Down
12 changes: 1 addition & 11 deletions python/lsst/pipe/base/pipelineTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from lsst.utils.logging import LsstLogAdapter

from .butlerQuantumContext import ButlerQuantumContext
from .config import PipelineTaskConfig, ResourceConfig
from .config import PipelineTaskConfig

Check warning on line 40 in python/lsst/pipe/base/pipelineTask.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/pipelineTask.py#L40

Added line #L40 was not covered by tests
from .struct import Struct


Expand Down Expand Up @@ -179,13 +179,3 @@
inputs = butlerQC.get(inputRefs)
outputs = self.run(**inputs)
butlerQC.put(outputs, outputRefs)

def getResourceConfig(self) -> Optional[ResourceConfig]:
"""Return resource configuration for this task.

Returns
-------
Object of type `~config.ResourceConfig` or ``None`` if resource
configuration is not defined for this task.
"""
return getattr(self.config, "resources", None)
105 changes: 0 additions & 105 deletions tests/test_config.py

This file was deleted.