rerun icon indicating copy to clipboard operation
rerun copied to clipboard

Python text logging: make sure rerun warnings are always written to stderr

Open emilk opened this issue 2 years ago • 1 comments

Unless in strict mode, the Python Rerun SDK ignore errors and prints warnings when used the wrong way (instead of throwing exceptions). It is therefore very important that this warnings are visible to users.

Our warning function is _send_warning and it calls logging.warning, but unless the user has enabled logging, this won't be visible. I think this is bad.

Potential solutions:

  • Always print warnings to stderr
  • Check if logging is hooked up. If not, log to stderr instead.

emilk avatar Jul 14 '23 12:07 emilk

One workaround (for developers) to set the environment variable PYTHONWARNINGS="always" or even PYTHONWARNINGS="error", which causes an exception to be raised in case of a warning being logged.

emilk avatar Mar 26 '25 17:03 emilk