Logging solution for tqdm may not be appropriate
When implementing tqdm
to have a progression bar in the training loop, the log.info("<message>")
is printed twice as follows:
After looking at the qim3d.io.logger.py
function, it seemed as though the set_simple_output()
in line 135 was the call causing this double warning. I think the problem comes from a root/child issue where the log = logging.getLogger("qim3d")
is a child logger and will therefore messages from log
will be propagated to the root.
Solution found here: https://jdhao.github.io/2020/06/20/python_duplicate_logging_messages/
I found that one can either:
- add
log.propagate = False
intrain_model
. - add
log.handlers = []
intrain_model
.
The resulting output is then:
I guess the log.propagate = False
is the best, but there may be a better alternative.
Edited by s184364