Download code/_lat.py from ThuongBuiRVC/datariengcuathuongbui: direct link, hf CLI and curl.
- Browser
- Download file 895 Bytes
-
https://huggingface.co/datasets/ThuongBuiRVC/datariengcuathuongbui/resolve/main/code/_lat.py
- Command line
-
hf download hf://datasets/ThuongBuiRVC/datariengcuathuongbui/code/_lat.py
-
curl -L -o _lat.py https://huggingface.co/datasets/ThuongBuiRVC/datariengcuathuongbui/resolve/main/code/_lat.py
895 Bytes
| import os, time, requests, tarfile | |
| e = open('/home/db/ThuongBui/localization/vlr/val_entries.txt').read().split()[5] | |
| url = f'https://huggingface.co/datasets/nureasoning/nuReasoning/resolve/main/data/{e}.tar' | |
| s = requests.Session(); s.headers['Authorization'] = 'Bearer ' + os.environ['HF_TOKEN'] | |
| r = s.get(url, headers={'Range': 'bytes=0-0'}, allow_redirects=False, timeout=60); cdn = r.headers.get('Location'); print(r.status_code, (cdn or '')[:60]) | |
| p = requests.Session(); t = time.time(); off = 0; n = 0; names = [] | |
| while n < 40: | |
| h = p.get(cdn, headers={'Range': f'bytes={off}-{off+511}'}, timeout=60).content | |
| ti = tarfile.TarInfo.frombuf(h, 'utf-8', 'surrogateescape'); names.append((ti.name[-40:], ti.type, ti.size)) | |
| off += 512 + (ti.size + 511) // 512 * 512; n += 1 | |
| print('per request ms', (time.time() - t) / n * 1000, 'size', r.headers.get('Content-Range')) | |
| print(names[:6]) | |