Skip to content

Commit

Permalink
add experimental tqdm
Browse files Browse the repository at this point in the history
  • Loading branch information
ZEMUSHKA committed Dec 11, 2018
1 parent 2bd4ff5 commit 182db68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion setup_google_colab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def download_github_code(path):


def setup_common():
os.system("pip install tqdm")
if bool(int(os.environ.get("EXPERIMENTAL_TQDM", "0"))):
os.system("pip install --force https://github.com/hse-aml/intro-to-dl/releases/download/ColabTqdm/tqdm-colab.zip")
else:
os.system("pip install tqdm")
os.system("pip install --upgrade Keras==2.0.6") # latest version breaks callbacks
download_github_code("keras_utils.py")
download_github_code("grading.py")
Expand Down
7 changes: 4 additions & 3 deletions tqdm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ def __next__(self):
raise StopIteration


def is_colab():
def use_simple_tqdm():
try:
import google.colab
return True
import os
return not bool(int(os.environ.get("EXPERIMENTAL_TQDM", "0")))
except ImportError:
return False


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

0 comments on commit 182db68

Please sign in to comment.