gugarosa / opytimizer

🐦 Opytimizer is a Python library consisting of meta-heuristic optimization algorithms.
https://opytimizer.readthedocs.io
Apache License 2.0
606 stars 41 forks source link

[REG] How to supress DEBUG log message in opytimizer.core.space #20

Closed amir1m closed 3 years ago

amir1m commented 3 years ago

Hello, After inititializing Searchspace there is a debug message that is printed to stdout. How can we turn it off/on? Following is the message. opytimizer.core.space — DEBUG — Agents: 25 |....

I believe its printed because of line #223 in file opytimizer/core/space.py.

For large dimensions it prints all the lower and upper bounds which we may not always require.

Thanks.

gugarosa commented 3 years ago

Hello amir1m! I hope everything is going well with you!

Currently, the only way to supress the debug message is to re-implement the utils/logging.py file and change the #11 line:

LOG_LEVEL = logging.DEBUG

I will add this issue down and add a toggler that will enable users in handling such a problem.

Thanks for your suggestion and best regards, Gustavo.

amir1m commented 3 years ago

Thanks @gugarosa ! Appreciate the quick response!

Take care and stay safe.

Regards.

gugarosa commented 3 years ago

I found a workaround that should be easier and faster! Just add the following after all the imports (SearchSpace, Optimizer, etc):

import logging

# Gathers all instantiated loggers, even the children
loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict]

# Iterates through all loggers and set their level to INFO
for logger in loggers:
    logger.setLevel(logging.INFO)

Best regards, Gustavo.

amir1m commented 3 years ago

Cool.This workaround seems to be working. Thanks @gugarosa !