mrfakename commited on
Commit
ee9224b
·
verified ·
1 Parent(s): 4c50666

Use durable full source manifest

Browse files
Files changed (1) hide show
  1. mirror_worker.py +9 -4
mirror_worker.py CHANGED
@@ -9,9 +9,10 @@ from __future__ import annotations
9
  import os
10
  import shutil
11
  import time
 
12
  from pathlib import Path
13
 
14
- from huggingface_hub import HfApi
15
  from modelscope_hub import HubApi
16
 
17
  SOURCE_REPO = "daimonrobotics/Daimon-Infinity"
@@ -74,9 +75,13 @@ def main() -> None:
74
  source.login(MODELSCOPE_TOKEN)
75
  target = HfApi(token=HF_TOKEN)
76
  uploaded = set(target.list_repo_files(DEST_REPO, repo_type="dataset"))
77
- # The ordinary repository listing is truncated for very large ModelScope
78
- # datasets. Their dataset downloader uses this paginated tree endpoint.
79
- files = paginated_manifest(source)
 
 
 
 
80
  selected = [
81
  item for number, item in enumerate(files)
82
  if number % WORKER_COUNT == WORKER_INDEX
 
9
  import os
10
  import shutil
11
  import time
12
+ import json
13
  from pathlib import Path
14
 
15
+ from huggingface_hub import HfApi, hf_hub_download
16
  from modelscope_hub import HubApi
17
 
18
  SOURCE_REPO = "daimonrobotics/Daimon-Infinity"
 
75
  source.login(MODELSCOPE_TOKEN)
76
  target = HfApi(token=HF_TOKEN)
77
  uploaded = set(target.list_repo_files(DEST_REPO, repo_type="dataset"))
78
+ # A dedicated indexing job writes the full paginated source tree once.
79
+ # Reusing it avoids thousands of duplicate ModelScope listing requests.
80
+ manifest = hf_hub_download(
81
+ DEST_REPO, ".mirror/manifest.jsonl", repo_type="dataset", token=HF_TOKEN
82
+ )
83
+ with open(manifest, encoding="utf-8") as handle:
84
+ files = [json.loads(line) for line in handle]
85
  selected = [
86
  item for number, item in enumerate(files)
87
  if number % WORKER_COUNT == WORKER_INDEX