Skip to content

Importing the sagemaker module change the logging setup #755

@eprochasson

Description

@eprochasson

System Information

  • Framework (e.g. TensorFlow) / Algorithm (e.g. KMeans): NA
  • Framework Version: NA
  • Python Version: 3.6.3
  • CPU or GPU: NA
  • Python SDK Version: sagemaker-1.18.14.post1 (current version served by pip install sagemaker)
  • Are you using a custom image: no

Describe the problem

Simply importing the sagemaker module alterates the logging module configuration.

Minimal repro / logs

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions