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-35722: Catch errors in setting the HeavyFootprint peak flux #59

Merged
merged 1 commit into from Sep 8, 2022

Conversation

fred3m
Copy link
Contributor

@fred3m fred3m commented Sep 7, 2022

No description provided.

srcId = sourceRecord.getId()
x = peak["i_x"]
y = peak["i_y"]
warnings.warn(f"Source {srcId} at {x},{y} could not set the peak flux with error:")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to use LSST's logging rather than warnings?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this looks more like a log.warning() -- warnings to get converted to log messages but they won't be found as easily because the wrong logger will be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work to import the logger using

import logging
logger = logging.getLogger("lsst.meas.extensions.scarlet")
logger.warning("Log message here")

or do I have to pass it the logger from a task?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought measurement plugins had access to a logger so does logging.getLogger(self.logName) work to get the logger? That seems to work in some meas_extensions packages.

If that doesn't work use logger = logging.getLogger(__name__) so you don't have to hard code the full name in there.

@fred3m fred3m merged commit d8057db into main Sep 8, 2022
@fred3m fred3m deleted the tickets/DM-35722 branch September 8, 2022 18:56
x = peak["i_x"]
y = peak["i_y"]
logger.warn(f"Source {srcId} at {x},{y} could not set the peak flux with error:")
traceback.print_exc()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be called because it won't go to the logging system and we can't tell where it will turn up. Instead you should use logger.exception() and that would print your log message above and also include the exception traceback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants