Skip to content

Commit

Permalink
Use FieldValidationError to improve error reporting for slots
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed Aug 7, 2024
1 parent dd21207 commit 5cde36e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions python/lsst/meas/base/baseMeasurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,30 @@ def validate(self):
if self._ignoreSlotPluginChecks:
return
if self.slots.centroid is not None and self.slots.centroid not in self.plugins.names:
raise ValueError("source centroid slot algorithm is not being run.")
raise lsst.pex.config.FieldValidationError(
self.__class__.slots,
self,
"source centroid slot algorithm is not being run."
)
if self.slots.shape is not None and self.slots.shape not in self.plugins.names:
raise ValueError("source shape slot algorithm '%s' is not being run." % self.slots.shape)
raise lsst.pex.config.FieldValidationError(
self.__class__.slots,
self,
"source shape slot algorithm '%s' is not being run." % self.slots.shape
)
for slot in (self.slots.psfFlux, self.slots.apFlux, self.slots.modelFlux,
self.slots.gaussianFlux, self.slots.calibFlux):
if slot is not None:
for name in self.plugins.names:
if len(name) <= len(slot) and name == slot[:len(name)]:
break
else:
raise ValueError("source instFlux slot algorithm '%s' is not being run." % slot)
raise lsst.pex.config.FieldValidationError(
self.__class__.slots,
self,
f"Source instFlux algorithm '{slot}' is not being run, required from "
f"non-None slots in: {self.slots}."
)


class BaseMeasurementTask(lsst.pipe.base.Task):
Expand Down

0 comments on commit 5cde36e

Please sign in to comment.