Skip to content

Commit

Permalink
Remove DiaPipelineTask.apdb and all references to it.
Browse files Browse the repository at this point in the history
The apdb nested config was deprecated and replaced with a central
config file in w_2024_18.
  • Loading branch information
kfindeisen committed Jan 8, 2025
1 parent 4f6c595 commit d1c7ff8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 77 deletions.
43 changes: 2 additions & 41 deletions python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
"DiaPipelineConnections")


import warnings

import lsst.dax.apdb as daxApdb
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase
Expand Down Expand Up @@ -234,13 +232,6 @@ class DiaPipelineConfig(pipeBase.PipelineTaskConfig,
dtype=str,
default="deep",
)
apdb = pexConfig.ConfigurableField( # TODO: remove on DM-43419
target=daxApdb.ApdbSql,
doc="Database connection for storing associated DiaSources and "
"DiaObjects. Must already be initialized.",
deprecated="This field has been replaced by ``apdb_config_url``; set "
"``doConfigureApdb=False`` to use it. Will be removed after v28.",
)
apdb_config_url = pexConfig.Field(
dtype=str,
default=None,
Expand Down Expand Up @@ -311,19 +302,8 @@ class DiaPipelineConfig(pipeBase.PipelineTaskConfig,
"diaObjects for association.",
)
idGenerator = DetectorVisitIdGeneratorConfig.make_field()
doConfigureApdb = pexConfig.Field( # TODO: remove on DM-43419
dtype=bool,
default=True,
doc="Use the deprecated ``apdb`` sub-config to set up the APDB, "
"instead of the new config (``apdb_config_url``). This field is "
"provided for backward-compatibility ONLY and will be removed "
"without notice after v28.",
)

def setDefaults(self):
if self.doConfigureApdb:
self.apdb.dia_object_index = "baseline"
self.apdb.dia_object_columns = []
self.diaCalculation.plugins = ["ap_meanPosition",
"ap_nDiaSources",
"ap_meanFlux",
Expand All @@ -340,22 +320,6 @@ def setDefaults(self):
"ap_meanTotFlux",
"ap_sigmaTotFlux"]

# TODO: remove on DM-43419
def validate(self):
# Sidestep Config.validate to avoid validating uninitialized fields we're not using.
skip = {"apdb_config_url"} if self.doConfigureApdb else {"apdb"}
for name, field in self._fields.items():
if name not in skip:
field.validate(self)

# It's possible to use apdb without setting it, bypassing the deprecation warning.
if self.doConfigureApdb:
warnings.warn("Config field DiaPipelineConfig.apdb is deprecated: "
# Workaround for DM-44051
"This field has been replaced by ``apdb_config_url``; set "
"``doConfigureApdb=False`` to use it. Will be removed after v28.",
FutureWarning)


class DiaPipelineTask(pipeBase.PipelineTask):
"""Task for loading, associating and storing Difference Image Analysis
Expand All @@ -366,10 +330,7 @@ class DiaPipelineTask(pipeBase.PipelineTask):

def __init__(self, initInputs=None, **kwargs):
super().__init__(**kwargs)
if self.config.doConfigureApdb:
self.apdb = self.config.apdb.apply()
else:
self.apdb = daxApdb.Apdb.from_uri(self.config.apdb_config_url)
self.apdb = daxApdb.Apdb.from_uri(self.config.apdb_config_url)
self.schema = readSchemaFromApdb(self.apdb)
self.makeSubtask("associator")
self.makeSubtask("diaCalculation")
Expand Down Expand Up @@ -551,7 +512,7 @@ def run(self,

# For historical reasons, apdbMarker is a Config even if it's not meant to be read.
# A default Config is the cheapest way to satisfy the storage class.
marker = self.config.apdb.value if self.config.doConfigureApdb else pexConfig.Config()
marker = pexConfig.Config()
return pipeBase.Struct(apdbMarker=marker,
associatedDiaSources=associatedDiaSources,
diaForcedSources=diaForcedSources,
Expand Down
36 changes: 0 additions & 36 deletions tests/test_diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class TestDiaPipelineTask(unittest.TestCase):
@classmethod
def _makeDefaultConfig(cls, config_file, **kwargs):
config = DiaPipelineTask.ConfigClass()
config.doConfigureApdb = False
config.apdb_config_url = config_file
config.update(**kwargs)
return config
Expand Down Expand Up @@ -89,41 +88,6 @@ def setUp(self):
self.addCleanup(self.config_file.close)
apdb_config.save(self.config_file.name)

# TODO: remove on DM-43419
def testConfigApdbNestedOk(self):
config = DiaPipelineTask.ConfigClass()
config.doConfigureApdb = True
with self.assertWarns(FutureWarning):
config.apdb.db_url = "sqlite://"
config.freeze()
config.validate()

# TODO: remove on DM-43419
def testConfigApdbNestedInvalid(self):
config = DiaPipelineTask.ConfigClass()
config.doConfigureApdb = True
# Don't set db_url
config.freeze()
with self.assertRaises(pexConfig.FieldValidationError):
config.validate()

# TODO: remove on DM-43419
def testConfigApdbFileOk(self):
config = DiaPipelineTask.ConfigClass()
config.doConfigureApdb = False
config.apdb_config_url = "some/file/path.yaml"
config.freeze()
config.validate()

# TODO: remove on DM-43419
def testConfigApdbFileInvalid(self):
config = DiaPipelineTask.ConfigClass()
config.doConfigureApdb = False
# Don't set apdb_config_url
config.freeze()
with self.assertRaises(pexConfig.FieldValidationError):
config.validate()

def testRun(self):
"""Test running while creating and packaging alerts.
"""
Expand Down

0 comments on commit d1c7ff8

Please sign in to comment.