cookiecutter-scverse
cookiecutter-scverse copied to clipboard
Unified logging and settings
Should we propose a default mechanism for logging and settings?
Benefits IMO would be consistent behaviour for all ecosystem packages. Ideally there would be a way to set the logging level for all scverse packages globally.
This could either be implemented as
- a bunch of vendored code
- a separate "scverse-tools" package that can be imported as dependency.
In the long run, a "scverse-tools" package could make sense. We kinda have something like that already with scanpydoc, but could extend the scope to other helper functions.
Big yes.
Should include a function to get the session_info as in
scanpy.loggin.print_versions()
We should likely just use the standard logging module? We have a very basic setup with scvi-tools that uses rich to format the messages.
https://github.com/Delgan/loguru looks interesting also
Another interesting alternative that looks easier to understand (less magic API) and just as easy to use while encouraging to attach data to your log entries: https://www.structlog.org/en/stable/getting-started.html
If you have rich or better-exceptions installed, exceptions will be rendered in colors and with additional helpful information.
It also promotes logging json by default if the stdlib isn’t a TTY which I really like: https://www.structlog.org/en/stable/logging-best-practices.html#pretty-printing-vs-structured-output
See here how it integrates with the stdlib: https://www.structlog.org/en/stable/getting-started.html#structlog-and-standard-library-s-logging