Skip to content

Commit 2bd4ff5

Browse files
committed
fix tqdm on colab
1 parent cb87534 commit 2bd4ff5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tqdm_utils.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,17 @@ def __next__(self):
4747
raise StopIteration
4848

4949

50-
def tqdm_notebook_failsafe(*args, **kwargs):
50+
def is_colab():
5151
try:
52-
return tqdm.tqdm_notebook(*args, **kwargs)
53-
except:
52+
import google.colab
53+
return True
54+
except ImportError:
55+
return False
56+
57+
58+
def tqdm_notebook_failsafe(*args, **kwargs):
59+
if is_colab():
5460
# tqdm is broken on Google Colab
5561
return SimpleTqdm(*args, **kwargs)
62+
else:
63+
return tqdm.tqdm_notebook(*args, **kwargs)

0 commit comments

Comments
 (0)