Skip to content

Commit fdc90bb

Browse files
committed
rm tqdm
1 parent 1d7b13a commit fdc90bb

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

docs/guides/model_convert/convert_from_pytorch/tools/validate_pytorch_api_mapping.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import requests
1111
from requests.adapters import HTTPAdapter
12-
from tqdm import tqdm # 用于显示进度条
1312
from urllib3.util.retry import Retry
1413

1514
# 默认文件路径
@@ -608,12 +607,10 @@ def check_urls_exist(urls_with_context, max_workers=10):
608607
f"开始使用多线程检查 {total_urls} 个URL的存在性(线程数:{max_workers})..."
609608
)
610609

611-
with (
612-
tqdm(total=total_urls, desc="检查URL") as pbar,
613-
concurrent.futures.ThreadPoolExecutor(
614-
max_workers=max_workers
615-
) as executor,
616-
):
610+
processed = 0
611+
with concurrent.futures.ThreadPoolExecutor(
612+
max_workers=max_workers
613+
) as executor:
617614
# 为每个线程创建一个会话
618615
sessions = [create_session() for _ in range(max_workers)]
619616

@@ -629,8 +626,14 @@ def check_urls_exist(urls_with_context, max_workers=10):
629626
for future in concurrent.futures.as_completed(future_to_url):
630627
result = future.result()
631628

632-
# 更新进度条
633-
pbar.update(1)
629+
# 更新进度计数
630+
processed += 1
631+
if processed % 10 == 0 or processed == len(urls_with_context):
632+
print(
633+
f"\r检查URL进度: {processed}/{len(urls_with_context)}",
634+
end="",
635+
flush=True,
636+
)
634637

635638
# 如果不是200状态码,则添加到警告列表
636639
if result["status"] != "ok":
@@ -647,7 +650,8 @@ def check_urls_exist(urls_with_context, max_workers=10):
647650
for session in sessions:
648651
session.close()
649652

650-
print(f"URL检查完成,发现 {len(warnings)} 个问题")
653+
# 打印最终进度
654+
print(f"\r检查URL完成,发现 {len(warnings)} 个问题")
651655
return warnings
652656

653657

0 commit comments

Comments
 (0)