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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging to STDERR #3052

Closed
voidmagic opened this issue Dec 21, 2020 · 1 comment
Closed

Logging to STDERR #3052

voidmagic opened this issue Dec 21, 2020 · 1 comment
Assignees

Comments

@voidmagic
Copy link
Contributor

馃悰 Bug

The output stream should be STDOUT by default, as shown in train.py:

logging.basicConfig(
    format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S",
    level=os.environ.get("LOGLEVEL", "INFO").upper(),
    stream=sys.stdout,
)

However after import fairseq, the default output stream becomes STDERR. I cannot figure out why.

To Reproduce

Steps to reproduce the behavior (always include the command you ran):

  1. Run cmd fairseq-train ... > output.txt
  2. See error cat output.txt with empty content.

Code sample

A simple way to reproduce:

log_test1.py:

import logging, sys
logging.basicConfig(level='INFO', stream=sys.stdout)
logging.info('hello')

Run python log_test1.py > output.txt, the content in output.txt is INFO:root:hello.

log_test2.py:

import logging, sys, fairseq
logging.basicConfig(level='INFO', stream=sys.stdout)
logging.info('hello')

Run python log_test1.py > output.txt, the content in output.txt is empty while the stderr prints 2020-12-21 10:48:39 | INFO | root | hello.

Expected behavior

Redirect all loggings to STDOUT so that we can distinguish infos and errors with different logging files.

Environment

  • fairseq Version (0.10.1):
  • PyTorch Version (e.g., 1.0)
  • OS (e.g., Linux):
  • How you installed fairseq (pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

@myleott
Copy link
Contributor

myleott commented Jan 5, 2021

Fixed in 0.10.2

@myleott myleott closed this as completed Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants