-
Notifications
You must be signed in to change notification settings - Fork 51
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
Use loguru #303
Use loguru #303
Changes from 7 commits
6d813a3
14e8448
abbfc92
2b48051
9dfbc2a
63f316e
a986ca9
49a2f40
02e8997
cdf8f2d
40c6611
f14a500
3b909bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ dependencies: | |
- scipy | ||
- scikit-learn | ||
- matplotlib | ||
- loguru | ||
- pyarrow | ||
|
||
# Testing | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Miscellaneous | ||
============= | ||
|
||
This page includes aspects that would improve your usage of **alchemlyb**. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Miscellaneous | ||
|
||
miscellaneous/logging | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.. _logging_section: | ||
|
||
Logging | ||
======= | ||
|
||
In **alchemlyb**, we use :mod:`loguru` for logging. By default, the | ||
orbeckst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:mod:`loguru` will print the logging information into the `stderr`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you link to |
||
|
||
orbeckst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Print to the stderr | ||
------------------- | ||
|
||
If you want to customise the printing to the `stderr`, you could remove the | ||
existing sink first :: | ||
|
||
from loguru import logger | ||
logger.remove() | ||
|
||
Then add other custom sink :: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Link to a page that explains what the format does, filter etc — basically the docs for |
||
|
||
logger.add(sys.stderr, format="{time} {level} {message}", filter="my_module", level="INFO") | ||
|
||
Save to a file | ||
-------------- | ||
|
||
Alternatively, one could save to a file simply with :: | ||
|
||
from loguru import logger | ||
logger.add("file_{time}.log") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ | |
"scipy", | ||
"scikit-learn", | ||
"matplotlib", | ||
"loguru", | ||
"pyarrow", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import logging | ||
|
||
import pandas as pd | ||
import pymbar | ||
from sklearn.base import BaseEstimator | ||
|
@@ -25,12 +23,12 @@ class MBAR(BaseEstimator, _EstimatorMixOut): | |
|
||
method : str, optional, default="robust" | ||
The optimization routine to use. This can be any of the methods | ||
available via :func:`scipy.optimize.minimize` or | ||
available via :func:`scipy.optimize.minimize` or | ||
:func:`scipy.optimize.root`. | ||
|
||
verbose : bool, optional | ||
Set to ``True`` if verbose debug output from :mod:`pymbar` is desired. | ||
Output from alchemlyb is logged via :mod:`logging`. | ||
Output from alchemlyb is logged via :mod:`loguru`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove as no logging done here? |
||
|
||
Attributes | ||
---------- | ||
|
@@ -77,7 +75,6 @@ def __init__( | |
self.initial_f_k = initial_f_k | ||
self.method = method | ||
self.verbose = verbose | ||
self.logger = logging.getLogger("alchemlyb.estimators.MBAR") | ||
|
||
# handle for pymbar.MBAR object | ||
self._mbar = None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the TOC caption — looks superfluous as it is repeated, see https://alchemlyb--303.org.readthedocs.build/en/303/miscellaneous.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what do you mean by this? I could change the
:maxdepth: 2
to 1, if Print to the stderr and Save to a file is superfluous?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see.