File size: 979 Bytes
cfa2024
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os, time, requests
from concurrent.futures import ThreadPoolExecutor
ents = open('/home/db/ThuongBui/localization/vlr/val_entries.txt').read().split()
s = requests.Session(); s.headers['Authorization'] = 'Bearer ' + os.environ['HF_TOKEN']
def cdn(e):
    r = s.get(f'https://huggingface.co/datasets/nureasoning/nuReasoning/resolve/main/data/{e}.tar', headers={'Range': 'bytes=0-0'}, allow_redirects=False, timeout=60)
    return r.headers['Location']
def pull(e, n=200 << 20):
    u = cdn(e); t = time.time(); got = 0
    with requests.get(u, headers={'Range': f'bytes=0-{n-1}'}, stream=True, timeout=60) as r:
        for ch in r.iter_content(1 << 20):
            got += len(ch)
    return got / (time.time() - t) / 1e6
print('1 stream MB/s', round(pull(ents[10]), 1))
t = time.time()
with ThreadPoolExecutor(8) as p:
    rs = list(p.map(pull, ents[11:19]))
print('8 streams MB/s each', [round(x) for x in rs], 'total', round(8 * 200 * 1.048576 / (time.time() - t), 1))