File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
pytorch_lightning/utilities Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
137137- Fixed logger creating directory structure too early in DDP ([ #6380 ] ( https://github.com/PyTorchLightning/pytorch-lightning/pull/6380 ) )
138138
139139
140+ - Fixed comparing required versions ([ #6434 ] ( https://github.com/PyTorchLightning/pytorch-lightning/pull/6434 ) )
141+
142+
140143## [ 1.2.2] - 2021-03-02
141144
142145### Added
Original file line number Diff line number Diff line change 1515_DATASETS_PATH = os .path .join (_PACKAGE_ROOT , 'Datasets' )
1616
1717_TORCHVISION_AVAILABLE = _module_available ("torchvision" )
18- _TORCHVISION_MNIST_AVAILABLE = True
18+ _TORCHVISION_MNIST_AVAILABLE = _TORCHVISION_AVAILABLE
1919_DALI_AVAILABLE = _module_available ("nvidia.dali" )
2020
21- if _TORCHVISION_AVAILABLE :
21+ if _TORCHVISION_MNIST_AVAILABLE :
2222 try :
2323 from torchvision .datasets .mnist import MNIST
2424 MNIST (_DATASETS_PATH , download = True )
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414"""General utilities"""
15+ import importlib
1516import operator
1617import platform
1718import sys
1819from distutils .version import LooseVersion
1920from importlib .util import find_spec
2021
2122import torch
22- from pkg_resources import DistributionNotFound , get_distribution
23+ from pkg_resources import DistributionNotFound
2324
2425
2526def _module_available (module_path : str ) -> bool :
@@ -42,8 +43,17 @@ def _module_available(module_path: str) -> bool:
4243
4344
4445def _compare_version (package : str , op , version ) -> bool :
46+ """Compare package version with some requirements
47+
48+ >>> _compare_version("torch", operator.ge, "0.1")
49+ True
50+ """
51+ if not _module_available (package ):
52+ return False
4553 try :
46- pkg_version = LooseVersion (get_distribution (package ).version )
54+ pkg = importlib .import_module (package )
55+ assert hasattr (pkg , '__version__' )
56+ pkg_version = pkg .__version__
4757 return op (pkg_version , LooseVersion (version ))
4858 except DistributionNotFound :
4959 return False
You can’t perform that action at this time.
0 commit comments