Commit 0e91df43 authored by Yuxin Wu's avatar Yuxin Wu

fix progress bar in jupyter with type checking

parent a6394cd9
......@@ -113,14 +113,15 @@ def get_tqdm_kwargs(**kwargs):
)
f = kwargs.get('file', sys.stderr)
# os.isatty and f.isatty give different result under jupyter notebook.
# We use os.isatty when stdout/stderr is used, so that jupyter notebook will be recognized as tty.
if f == sys.stderr:
isatty = os.isatty(2)
elif f == sys.stdout:
isatty = os.isatty(1)
else:
isatty = f.isatty()
isatty = f.isatty()
# Jupyter notebook should be recognized as tty.
# Wait for https://github.com/ipython/ipykernel/issues/268
try:
from ipykernel import iostream
if isinstance(f, iostream.OutStream):
isatty = True
except ImportError:
pass
if isatty:
default['mininterval'] = 0.5
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment