Skip to content

Commit

Permalink
fix tqdm on colab
Browse files Browse the repository at this point in the history
  • Loading branch information
ZEMUSHKA committed Dec 11, 2018
1 parent cb87534 commit 2bd4ff5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tqdm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ def __next__(self):
raise StopIteration


def tqdm_notebook_failsafe(*args, **kwargs):
def is_colab():
try:
return tqdm.tqdm_notebook(*args, **kwargs)
except:
import google.colab
return True
except ImportError:
return False


def tqdm_notebook_failsafe(*args, **kwargs):
if is_colab():
# tqdm is broken on Google Colab
return SimpleTqdm(*args, **kwargs)
else:
return tqdm.tqdm_notebook(*args, **kwargs)

0 comments on commit 2bd4ff5

Please # to comment.