From e209925256277dd4c58314729782800cba4c7a31 Mon Sep 17 00:00:00 2001 From: ChenXin Date: Sun, 5 May 2019 22:28:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=20tqdm.autonotebook=20=E6=8D=A2?= =?UTF-8?q?=E6=88=90tqdm.auto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastNLP/api/utils.py | 8 ++++---- fastNLP/automl/enas_trainer.py | 2 +- fastNLP/core/trainer.py | 2 +- fastNLP/io/dataset_loader.py | 5 ++++- fastNLP/models/enas_trainer.py | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fastNLP/api/utils.py b/fastNLP/api/utils.py index a54a53d9..e8e7c42a 100644 --- a/fastNLP/api/utils.py +++ b/fastNLP/api/utils.py @@ -20,10 +20,10 @@ except ImportError: from urllib.request import urlopen from urllib.parse import urlparse try: - from tqdm import tqdm -except ImportError: - tqdm = None # defined below - + from tqdm.auto import tqdm +except: + from ..core.utils import _pseudo_tqdm as tqdm + # matches bfd8deac from resnet18-bfd8deac.pth HASH_REGEX = re.compile(r'-([a-f0-9]*)\.') diff --git a/fastNLP/automl/enas_trainer.py b/fastNLP/automl/enas_trainer.py index a9b1b8c3..8f51c2cd 100644 --- a/fastNLP/automl/enas_trainer.py +++ b/fastNLP/automl/enas_trainer.py @@ -9,7 +9,7 @@ import numpy as np import torch try: - from tqdm.autonotebook import tqdm + from tqdm.auto import tqdm except: from ..core.utils import _pseudo_tqdm as tqdm diff --git a/fastNLP/core/trainer.py b/fastNLP/core/trainer.py index 90aa0c19..40eea4a5 100644 --- a/fastNLP/core/trainer.py +++ b/fastNLP/core/trainer.py @@ -311,7 +311,7 @@ import torch from torch import nn try: - from tqdm.autonotebook import tqdm + from tqdm.auto import tqdm except: from .utils import _pseudo_tqdm as tqdm diff --git a/fastNLP/io/dataset_loader.py b/fastNLP/io/dataset_loader.py index 6d64ede2..1fe92e23 100644 --- a/fastNLP/io/dataset_loader.py +++ b/fastNLP/io/dataset_loader.py @@ -20,7 +20,10 @@ from .file_reader import _read_csv, _read_json, _read_conll def _download_from_url(url, path): - from tqdm import tqdm + try: + from tqdm.auto import tqdm + except: + from ..core.utils import _pseudo_tqdm as tqdm import requests """Download file""" diff --git a/fastNLP/models/enas_trainer.py b/fastNLP/models/enas_trainer.py index 824b8184..cce93556 100644 --- a/fastNLP/models/enas_trainer.py +++ b/fastNLP/models/enas_trainer.py @@ -9,7 +9,7 @@ import torch import math try: - from tqdm.autonotebook import tqdm + from tqdm.auto import tqdm except: from ..core.utils import _pseudo_tqdm as tqdm