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): ...@@ -113,14 +113,15 @@ def get_tqdm_kwargs(**kwargs):
) )
f = kwargs.get('file', sys.stderr) f = kwargs.get('file', sys.stderr)
# os.isatty and f.isatty give different result under jupyter notebook. isatty = f.isatty()
# We use os.isatty when stdout/stderr is used, so that jupyter notebook will be recognized as tty. # Jupyter notebook should be recognized as tty.
if f == sys.stderr: # Wait for https://github.com/ipython/ipykernel/issues/268
isatty = os.isatty(2) try:
elif f == sys.stdout: from ipykernel import iostream
isatty = os.isatty(1) if isinstance(f, iostream.OutStream):
else: isatty = True
isatty = f.isatty() except ImportError:
pass
if isatty: if isatty:
default['mininterval'] = 0.5 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