Skip to content

Commit 19f7623

Browse files
authored
Fix tqdm in downloader (#4603)
* fix tqdm * rtol -> atol
1 parent a600b41 commit 19f7623

File tree

5 files changed

+5
-30
lines changed

5 files changed

+5
-30
lines changed

paddlenlp/utils/downloader.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import os
1717
import os.path as osp
1818
import shutil
19-
import sys
2019
import tarfile
2120
import threading
2221
import time
@@ -28,34 +27,10 @@
2827
import requests
2928
from huggingface_hub import get_hf_file_metadata, hf_hub_url
3029
from huggingface_hub.utils import EntryNotFoundError
30+
from tqdm.auto import tqdm
3131

3232
from .env import DOWNLOAD_SERVER, FAILED_STATUS, SUCCESS_STATUS
3333
from .file_lock import FileLock
34-
35-
try:
36-
from tqdm import tqdm
37-
except: # noqa: E722
38-
39-
class tqdm(object):
40-
def __init__(self, total=None, **kwargs):
41-
self.total = total
42-
self.n = 0
43-
44-
def update(self, n):
45-
self.n += n
46-
if self.total is None:
47-
sys.stderr.write("\r{0:.1f} bytes".format(self.n))
48-
else:
49-
sys.stderr.write("\r{0:.1f}%".format(100 * self.n / float(self.total)))
50-
sys.stderr.flush()
51-
52-
def __enter__(self):
53-
return self
54-
55-
def __exit__(self, exc_type, exc_val, exc_tb):
56-
sys.stderr.write("\n")
57-
58-
5934
from .log import logger
6035

6136
__all__ = ["get_weights_path_from_url"]

tests/transformers/bert/test_modeling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ def test_bert_classes_from_local_dir(self, class_name, pytorch_class_name: str |
737737
np.allclose(
738738
paddle_logit.detach().cpu().reshape([-1])[:9].numpy(),
739739
torch_logit.detach().cpu().reshape([-1])[:9].numpy(),
740-
rtol=1e-4,
740+
atol=1e-3,
741741
)
742742
)
743743

tests/transformers/gpt/test_modeling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ def test_gpt_classes_from_local_dir(self, paddle_class_name, pytorch_class_name:
627627
np.allclose(
628628
paddle_logit.detach().cpu().numpy().reshape([-1])[:9],
629629
torch_logit.detach().cpu().numpy().reshape([-1])[:9],
630-
rtol=1e-3,
630+
atol=1e-3,
631631
)
632632
)
633633

tests/transformers/roberta/test_modeling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def test_roberta_classes_from_local_dir(self, class_name):
500500
np.allclose(
501501
paddle_logit.detach().cpu().reshape([-1])[:9].numpy(),
502502
torch_logit.detach().cpu().reshape([-1])[:9].numpy(),
503-
rtol=1e-4,
503+
atol=1e-3,
504504
)
505505
)
506506

tests/transformers/t5/test_modeling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ def test_t5_for_conditional_generation(self):
822822
np.allclose(
823823
paddle_logit.detach().cpu().reshape([-1])[:9].numpy(),
824824
torch_logit.detach().cpu().reshape([-1])[:9].numpy(),
825-
rtol=1e-4,
825+
atol=1e-3,
826826
)
827827
)
828828

0 commit comments

Comments
 (0)