Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library logs to stdout on import #4387

Open
derricw opened this issue Jan 23, 2024 · 1 comment
Open

Library logs to stdout on import #4387

derricw opened this issue Jan 23, 2024 · 1 comment
Labels

Comments

@derricw
Copy link

derricw commented Jan 23, 2024

Describe the bug

Logging to stdout is an undesirable default for a library, especially since tools that use the library will want to control what is written to stdout. For example, imagine a command line program that fetches records from FeatureStore or metadata about training runs and writes the data to stdout so that it can be parsed by other tools like grep or jq or awk.

This is most likely caused by this line.

To reproduce

import sagemaker

This writes to stdout:

>>> import sagemaker
sagemaker.config INFO - Not applying SDK defaults from location: /etc/xdg/sagemaker/config.yaml
sagemaker.config INFO - Not applying SDK defaults from location: /home/username/.config/sagemaker/config.yaml

Expected behavior
I would expect this to be written to stderr so that it doesn't interfere with regular program output.

Screenshots or logs
If applicable, add screenshots or logs to help explain your problem.

System information
A description of your system. Please provide:

  • SageMaker Python SDK version: '2.198.0'
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): N/A
  • Framework version: N/A
  • Python version: 3.8
  • CPU or GPU: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
  • Custom Docker image (Y/N): N

Additional context
Add any other context about the problem here.

@derricw derricw added the bug label Jan 23, 2024
@derricw
Copy link
Author

derricw commented Jan 23, 2024

Workaround I used:

import logging

# have to do this before importing sagemaker otherwise it logs
# config info to stdout
logging.getLogger("sagemaker.config").addHandler(logging.NullHandler())
logging.getLogger("sagemaker").addHandler(logging.NullHandler())

import sagemaker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant