nnaisense / evotorch

Advanced evolutionary computation library built directly on top of PyTorch, created at NNAISENSE.
https://evotorch.ai
Apache License 2.0
997 stars 62 forks source link

Able to suppress INFO logs #67

Closed maulberto3 closed 11 months ago

maulberto3 commented 1 year ago

Hi, it seems everytime a user instantiates a SupervisedNE problem, INFO logs appear in jupyter cell and can't seem to disable it with typical methods like logging.basicConfig or .setLevel(logging.WARNING).

maulberto3 commented 1 year ago

Nevermind, worked with logging.disable('WARNING'). I wonder why...

engintoklu commented 1 year ago

Hi @maulberto3!

Sorry for replying to your issue very very late.

While replying to the issue #81, I noticed/remembered that this older issue you posted is mentioning the same thing.

Nevermind, worked with logging.disable('WARNING'). I wonder why...

It works, because logging.disable(WARNING) disables all the reports with levels up to and including WARNING. The regular reports generated by an evotorch.Problem instance are at the INFO level (a level that is below the level of WARNING), and therefore they are disabled by this trick you mentioned.

If you wish to suppress the INFO messages of only EvoTorch and not of any other library, you might want to try this:

from evotorch.tools import set_default_logger_config
import logging

set_default_logger_config(
    logger_level=logging.WARNING,  # only print the message if it is at least a WARNING
    override=True,  # override the previous logging settings of EvoTorch
)

Sorry again for my very late response.

Happy coding, Engin