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

Silence "converting a masked element to nan" warning #924

Merged
merged 11 commits into from
Oct 24, 2023
Merged

Conversation

ericboucher
Copy link
Collaborator

Silence "converting a masked element to nan" logs warnings after the first occurrence to avoid spamming the logs

@github-actions
Copy link

github-actions bot commented Jul 25, 2023

Build succeeded and deployed at https://prism-924.surge.sh
(hash e5ffac8 deployed at 2023-10-23T20:28:01)

api/app/utils.py Outdated
warning_recorded = False


def custom_warning_handler(message, category, filename, lineno, file=None, line=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know if it's an issue for you, but https://docs.python.org/3/library/warnings.html#warnings.showwarning write to a file which is sys.stderr by default.

We could call the default _showwarnmsg_impl for messages we don't want to filter to be clother to existings behavior ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an intenal function and looks like it has different signature based on the pyhton version. I'll use a standard logger instead, wdyt?

@ericboucher ericboucher merged commit 81013ef into master Oct 24, 2023
6 checks passed
@ericboucher ericboucher deleted the silence-logs branch October 24, 2023 10:08
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.

2 participants