diff --git a/paddlenlp/utils/downloader.py b/paddlenlp/utils/downloader.py index 6c3204044535..b452feff37b2 100644 --- a/paddlenlp/utils/downloader.py +++ b/paddlenlp/utils/downloader.py @@ -16,7 +16,6 @@ import os import os.path as osp import shutil -import sys import tarfile import threading import time @@ -28,34 +27,10 @@ import requests from huggingface_hub import get_hf_file_metadata, hf_hub_url from huggingface_hub.utils import EntryNotFoundError +from tqdm.auto import tqdm from .env import DOWNLOAD_SERVER, FAILED_STATUS, SUCCESS_STATUS from .file_lock import FileLock - -try: - from tqdm import tqdm -except: # noqa: E722 - - class tqdm(object): - def __init__(self, total=None, **kwargs): - self.total = total - self.n = 0 - - def update(self, n): - self.n += n - if self.total is None: - sys.stderr.write("\r{0:.1f} bytes".format(self.n)) - else: - sys.stderr.write("\r{0:.1f}%".format(100 * self.n / float(self.total))) - sys.stderr.flush() - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_val, exc_tb): - sys.stderr.write("\n") - - from .log import logger __all__ = ["get_weights_path_from_url"] diff --git a/tests/transformers/bert/test_modeling.py b/tests/transformers/bert/test_modeling.py index 947a768d8efb..f3fdab2645d1 100644 --- a/tests/transformers/bert/test_modeling.py +++ b/tests/transformers/bert/test_modeling.py @@ -737,7 +737,7 @@ def test_bert_classes_from_local_dir(self, class_name, pytorch_class_name: str | np.allclose( paddle_logit.detach().cpu().reshape([-1])[:9].numpy(), torch_logit.detach().cpu().reshape([-1])[:9].numpy(), - rtol=1e-4, + atol=1e-3, ) ) diff --git a/tests/transformers/gpt/test_modeling.py b/tests/transformers/gpt/test_modeling.py index dae78494e6bc..fa2e8c1c2b2b 100644 --- a/tests/transformers/gpt/test_modeling.py +++ b/tests/transformers/gpt/test_modeling.py @@ -627,7 +627,7 @@ def test_gpt_classes_from_local_dir(self, paddle_class_name, pytorch_class_name: np.allclose( paddle_logit.detach().cpu().numpy().reshape([-1])[:9], torch_logit.detach().cpu().numpy().reshape([-1])[:9], - rtol=1e-3, + atol=1e-3, ) ) diff --git a/tests/transformers/roberta/test_modeling.py b/tests/transformers/roberta/test_modeling.py index b2dd1e06c642..ee665ec17a57 100644 --- a/tests/transformers/roberta/test_modeling.py +++ b/tests/transformers/roberta/test_modeling.py @@ -500,7 +500,7 @@ def test_roberta_classes_from_local_dir(self, class_name): np.allclose( paddle_logit.detach().cpu().reshape([-1])[:9].numpy(), torch_logit.detach().cpu().reshape([-1])[:9].numpy(), - rtol=1e-4, + atol=1e-3, ) ) diff --git a/tests/transformers/t5/test_modeling.py b/tests/transformers/t5/test_modeling.py index f8776dcf069e..4ecc7c5424d4 100644 --- a/tests/transformers/t5/test_modeling.py +++ b/tests/transformers/t5/test_modeling.py @@ -822,7 +822,7 @@ def test_t5_for_conditional_generation(self): np.allclose( paddle_logit.detach().cpu().reshape([-1])[:9].numpy(), torch_logit.detach().cpu().reshape([-1])[:9].numpy(), - rtol=1e-4, + atol=1e-3, ) )