prlq commited on
Commit
5f94a5e
·
verified ·
1 Parent(s): 659a2a8

lora_kit: per-folder download (repo file list capped at 100k)

Browse files
debug/536/lora_kit/README.md CHANGED
@@ -19,6 +19,8 @@ Multi-GPU: all visible GPUs are used (data parallel, global batch stays 32). Env
19
  ## Data (HF `prlq/mobilemanipbench-data`)
20
  Training set of a cell = `<TASK>/<robot>/dr_off/` (original, visual DR off, 50) + `<TASK>/<robot>/dr_on_perturb/` (NEW: visual DR on + DART-style perturbation:
21
  the robot executes the expert command plus temporary offsets, the record keeps the clean expert command; ~50). The original `dr_on/` is NOT used here (owner decision).
 
 
22
  Status on HF at 2026-11-16 03:35 CST (perturbed episodes; collection running, 50 per cell is the target):
23
 
24
  | task | go2_arm | sawyer_umi | stretch3 |
 
19
  ## Data (HF `prlq/mobilemanipbench-data`)
20
  Training set of a cell = `<TASK>/<robot>/dr_off/` (original, visual DR off, 50) + `<TASK>/<robot>/dr_on_perturb/` (NEW: visual DR on + DART-style perturbation:
21
  the robot executes the expert command plus temporary offsets, the record keeps the clean expert command; ~50). The original `dr_on/` is NOT used here (owner decision).
22
+ Download: the script fetches each folder with `hf_fetch.py` (list_repo_tree + 32 parallel hf_hub_download). Do NOT use `snapshot_download(allow_patterns=...)` on this repo:
23
+ the Hub's file list of the repo stops at 100,000 files (it ends inside N021), so later folders (N025+, canonical_action_v2, pi05_v3) come back as "Fetching 0 files" (fixed 2026-11-16 04:45 CST).
24
  Status on HF at 2026-11-16 03:35 CST (perturbed episodes; collection running, 50 per cell is the target):
25
 
26
  | task | go2_arm | sawyer_umi | stretch3 |
debug/536/lora_kit/hf_fetch.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """hf_fetch.py <repo> <local_dir> <prefix>[:<suffixes>] ... Download only the files under each prefix of a HF dataset repo.
2
+
3
+ Why not snapshot_download: the repo has more than 100,000 files and the Hub's repo_info file list stops at 100,000 (it ends inside N021), so
4
+ snapshot_download with allow_patterns on a later folder (N025..., canonical_action_v2, pi05_v3) can "Fetch 0 files" (reported 2026-11-16, N025/stretch3).
5
+ Here each prefix is listed on its own with list_repo_tree, then the files are fetched with 32 parallel hf_hub_download; files already present with the
6
+ right size are skipped. ":<suffixes>" keeps only names ending with one of the comma-separated suffixes, e.g. canonical_action_v2:.py,.json"""
7
+ import os, sys
8
+ from concurrent.futures import ThreadPoolExecutor, as_completed
9
+ from huggingface_hub import HfApi, hf_hub_download
10
+ from huggingface_hub.hf_api import RepoFile
11
+
12
+ repo, local = sys.argv[1], sys.argv[2]
13
+ tok = os.environ.get("HF_TOKEN") or None
14
+ api = HfApi(token=tok)
15
+ want = []
16
+ for arg in sys.argv[3:]:
17
+ pre, _, suf = arg.partition(":")
18
+ sufs = tuple(s for s in suf.split(",") if s)
19
+ files = [x for x in api.list_repo_tree(repo, path_in_repo=pre, repo_type="dataset", recursive=True) if isinstance(x, RepoFile)]
20
+ if sufs:
21
+ files = [x for x in files if x.path.endswith(sufs)]
22
+ print(f"[hf_fetch] {pre}: {len(files)} files", flush=True)
23
+ want += files
24
+ todo = [x for x in want if not (os.path.isfile(os.path.join(local, x.path)) and os.path.getsize(os.path.join(local, x.path)) == x.size)]
25
+ print(f"[hf_fetch] {len(want)} files, {len(todo)} to download", flush=True)
26
+
27
+ def get(x):
28
+ for attempt in range(5):
29
+ try:
30
+ return hf_hub_download(repo, x.path, repo_type="dataset", local_dir=local, token=tok)
31
+ except Exception as e: # transient 429 / timeouts
32
+ err = e
33
+ raise err
34
+
35
+ done = 0
36
+ with ThreadPoolExecutor(int(os.environ.get("HF_FETCH_WORKERS", "32"))) as ex:
37
+ for f in as_completed([ex.submit(get, x) for x in todo]):
38
+ f.result(); done += 1
39
+ if done % 500 == 0:
40
+ print(f"[hf_fetch] {done}/{len(todo)}", flush=True)
41
+ print("[hf_fetch] done", flush=True)