pip install sagemaker)Simply importing the sagemaker module alterates the logging module configuration.
Consider the following code:
import logging
logging.basicConfig(level='DEBUG',
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M')
logging.debug("debug")
logging.info('info')
logging.error('error')
logging.warning("WARNING")
When ran, will output:
04-18 09:15 root DEBUG debug
04-18 09:15 root INFO info
04-18 09:15 root ERROR error
04-18 09:15 root WARNING WARNING
as expected. Now, the modified code, the only difference being the import of the sagemaker module:
import logging
import sagemaker
logging.basicConfig(level='DEBUG',
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M')
logging.debug("debug")
logging.info('info')
logging.error('error')
logging.warning("WARNING")
will output:
WARNING:root:pandas failed to import. Analytics features will be impaired or broken.
ERROR:root:error
WARNING:root:WARNING
The logging level and formatting has been overwritten (the warning about pandas is not the problem I'm pointing at).
I think the problem arise because:
import sagemaker before first calling logging.basicConfiglogging.basicConfig()
LOGGER = logging.getLogger('sagemaker')
LOGGER.setLevel(logging.INFO)
which does call logging.basicConfig(). According to the python documentation about logging:
This function does nothing if the root logger already has handlers configured for it.
I don't think a module should configure any logging parameters (i.e.: only the line LOGGER = logging.getLogger('sagemaker') should remain).
Workaround: do not import sagemaker before calling logging.basicConfig() at a higher level.
hi @eprochasson, thanks for the detailed bug report! I've created a PR to address this bug: #757
the changes have now been released. closing this issue.