Skip to content

Commit

Permalink
Checking ipywidgets is installed for ensure tqdm working (#2417)
Browse files Browse the repository at this point in the history
* Adding importing ipywidgets before importing tqdm.auto to make sure ipywidgets is installed.

* Updated CHANGELOG.md

* Updated ipywidgets importing checks to @awaelchli comments.

Co-authored-by: William Falcon <waf2107@columbia.edu>
  • Loading branch information
olineumann and williamFalcon authored Jun 30, 2020
1 parent 309ed75 commit 1a54ed6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [unreleased] - YYYY-MM-DD

### Fixed

- Fixed crashing or wrong displaying progressbar because of missing ipywidgets ([#2417](https://github.com/PyTorchLightning/pytorch-lightning/pull/2417))

### Added


Expand All @@ -20,7 +24,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed


## [0.8.3] - 2020-06-29

### Fixed
Expand Down
9 changes: 8 additions & 1 deletion pytorch_lightning/callbacks/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
Use or override one of the progress bar callbacks.
"""
import importlib
import sys

from tqdm.auto import tqdm

# check if ipywidgets is installed before importing tqdm.auto
# to ensure it won't fail and a progress bar is displayed
if importlib.util.find_spec('ipywidgets') is not None:
from tqdm.auto import tqdm
else:
from tqdm import tqdm

from pytorch_lightning.callbacks import Callback

Expand Down
12 changes: 10 additions & 2 deletions pytorch_lightning/trainer/lr_finder.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
"""
Trainer Learning Rate Finder
"""
import os
import importlib
from abc import ABC, abstractmethod
from typing import Optional, Sequence, Tuple, List, Union

import numpy as np
import torch
from torch.optim.lr_scheduler import _LRScheduler
from torch.utils.data import DataLoader
from tqdm.auto import tqdm
import os

# check if ipywidgets is installed before importing tqdm.auto
# to ensure it won't fail and a progress bar is displayed
if importlib.util.find_spec('ipywidgets') is not None:
from tqdm.auto import tqdm
else:
from tqdm import tqdm


from pytorch_lightning.core.lightning import LightningModule
from pytorch_lightning.callbacks import Callback
Expand Down

0 comments on commit 1a54ed6

Please sign in to comment.