When I clear a cache with Memory.clear:
from joblib import Memory
memory = Memory(cachedir=".")
memory.clear()
I get output on the root logger which has apparently now been configured with what looks like logging.basicConfig:
WARNING:root:[Memory(cachedir='./joblib')]: Flushing completely the cache
This goes against Python logging best practices because it's manipulating the root logger which propagates to all other loggers. An example of why this is bad practice can be seen below:
import logging
from joblib import Memory
logger = logging.getLogger("mylogger")
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler())
memory = Memory(cachedir=".")
memory.clear()
logger.info("oops, I'll show up twice")
which gives the output
WARNING:root:[Memory(cachedir='./joblib')]: Flushing completely the cache
oops, I'll show up twice
INFO:mylogger:oops, I'll show up twice
What should be happening instead:
logging.warning but instead create its own logger and call logger.warning insteadNullHandler so as to not interfere with existing loggingIndeed you are correct. This happens in joblib/logger.py.
We would welcome a pull request to fix this.
Thanks!
Still not fixed. Does anyone have a workaround?
Still not fixed. Does anyone have a workaround? [2]
Same problem here. Joblib is messing up all my logging.
This is still an issue.
Any solution to this problem?
Still not fixed. Does anyone have a workaround? [3]
Here's a workaround:
https://github.com/joblib/joblib/issues/634#issuecomment-367321025
Hey, I just submitted a pull request for this issue. It's #1033. But for some reason a bunch of seemingly unrelated things are now failing (things like pickling io objects). The only file I changed was like 5 lines or so from Logger.py. What gives?
Most helpful comment
Still not fixed. Does anyone have a workaround?