ASTERIZER commited on
Commit
486816d
Β·
1 Parent(s): ad68b7f

Use ASTERIZER/Luna_Dataset: auto-extract zip, update commands

Browse files
Files changed (3) hide show
  1. README.md +4 -2
  2. fetch_data.py +45 -1
  3. setup_and_train.sh +2 -2
README.md CHANGED
@@ -14,9 +14,11 @@ pip install -q -r requirements.txt
14
 
15
  ### 2. Get Dataset + Train (one command)
16
 
 
 
17
  **From HuggingFace (recommended):**
18
  ```bash
19
- bash setup_and_train.sh huggingface ASTERIZER/LUNA-pretrain-data
20
  ```
21
 
22
  **From Google Drive:**
@@ -26,7 +28,7 @@ bash setup_and_train.sh gdrive YOUR_GDRIVE_FOLDER_ID
26
 
27
  **Smoke test (10M tokens only):**
28
  ```bash
29
- bash setup_and_train.sh huggingface ASTERIZER/LUNA-pretrain-data 10000000
30
  ```
31
 
32
  That's it. The script auto-detects your GPU, VRAM, RAM, CPU cores and configures everything for maximum utilization.
 
14
 
15
  ### 2. Get Dataset + Train (one command)
16
 
17
+ The dataset (~4.5B tokens) is hosted as a zip at [ASTERIZER/Luna_Dataset](https://huggingface.co/datasets/ASTERIZER/Luna_Dataset). The script downloads, extracts, and starts training automatically.
18
+
19
  **From HuggingFace (recommended):**
20
  ```bash
21
+ bash setup_and_train.sh huggingface ASTERIZER/Luna_Dataset
22
  ```
23
 
24
  **From Google Drive:**
 
28
 
29
  **Smoke test (10M tokens only):**
30
  ```bash
31
+ bash setup_and_train.sh huggingface ASTERIZER/Luna_Dataset 10000000
32
  ```
33
 
34
  That's it. The script auto-detects your GPU, VRAM, RAM, CPU cores and configures everything for maximum utilization.
fetch_data.py CHANGED
@@ -25,7 +25,7 @@ from pathlib import Path
25
 
26
  def download_huggingface(repo_id: str, out_dir: Path, hf_token: str = None):
27
  try:
28
- from huggingface_hub import snapshot_download, hf_hub_download
29
  except ImportError:
30
  print(" Installing huggingface_hub...")
31
  os.system(f"{sys.executable} -m pip install -q huggingface_hub")
@@ -41,6 +41,13 @@ def download_huggingface(repo_id: str, out_dir: Path, hf_token: str = None):
41
  ignore_patterns=["*.md", ".gitattributes"],
42
  )
43
  print(f" Downloaded to: {out_dir}")
 
 
 
 
 
 
 
44
  _verify(out_dir)
45
 
46
 
@@ -93,6 +100,43 @@ def copy_local(local_path: str, out_dir: Path):
93
  _verify(out_dir)
94
 
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  # ─── Verify ───────────────────────────────────────────────────────────────────
97
 
98
  def _verify(data_dir: Path):
 
25
 
26
  def download_huggingface(repo_id: str, out_dir: Path, hf_token: str = None):
27
  try:
28
+ from huggingface_hub import snapshot_download
29
  except ImportError:
30
  print(" Installing huggingface_hub...")
31
  os.system(f"{sys.executable} -m pip install -q huggingface_hub")
 
41
  ignore_patterns=["*.md", ".gitattributes"],
42
  )
43
  print(f" Downloaded to: {out_dir}")
44
+
45
+ # Auto-extract any zip files found in the download
46
+ _extract_zips(out_dir)
47
+
48
+ # If index.json landed in a subdirectory, move contents up
49
+ _flatten_to_root(out_dir)
50
+
51
  _verify(out_dir)
52
 
53
 
 
100
  _verify(out_dir)
101
 
102
 
103
+ # ─── Zip Extraction & Flattening ──────────────────────────────────────────────
104
+
105
+ def _extract_zips(data_dir: Path):
106
+ """Find and extract all .zip files in data_dir, then delete the zips."""
107
+ import zipfile
108
+ zips = list(data_dir.glob("*.zip"))
109
+ if not zips:
110
+ return
111
+ for zf in zips:
112
+ print(f" Extracting {zf.name} ...")
113
+ with zipfile.ZipFile(zf) as z:
114
+ z.extractall(data_dir)
115
+ zf.unlink()
116
+ print(f" Removed {zf.name}")
117
+
118
+
119
+ def _flatten_to_root(data_dir: Path):
120
+ """If index.json is one level deep (e.g. data_dir/subfolder/index.json),
121
+ move everything from that subfolder up to data_dir."""
122
+ if (data_dir / "index.json").exists():
123
+ return # already at root
124
+ candidates = list(data_dir.glob("*/index.json"))
125
+ if len(candidates) != 1:
126
+ return # ambiguous or not found
127
+ sub = candidates[0].parent
128
+ print(f" Moving contents from {sub.name}/ up to {data_dir.name}/ ...")
129
+ for item in sub.iterdir():
130
+ dest = data_dir / item.name
131
+ if dest.exists():
132
+ if dest.is_dir():
133
+ shutil.rmtree(dest)
134
+ else:
135
+ dest.unlink()
136
+ shutil.move(str(item), str(dest))
137
+ sub.rmdir()
138
+
139
+
140
  # ─── Verify ───────────────────────────────────────────────────────────────────
141
 
142
  def _verify(data_dir: Path):
setup_and_train.sh CHANGED
@@ -11,10 +11,10 @@
11
  # bash setup_and_train.sh gdrive 1AbCdEfGhIjKlMnOpQrStUvWx
12
  #
13
  # # Full dataset from HuggingFace:
14
- # bash setup_and_train.sh huggingface YourName/LUNA-pretrain-data
15
  #
16
  # # Quick smoke test (10M tokens only):
17
- # bash setup_and_train.sh gdrive 1AbCdEfGhIjKlMnOpQrStUvWx 10000000
18
  #
19
  # # Dataset already on disk:
20
  # bash setup_and_train.sh local /workspace/data/litdata_pretrain_final
 
11
  # bash setup_and_train.sh gdrive 1AbCdEfGhIjKlMnOpQrStUvWx
12
  #
13
  # # Full dataset from HuggingFace:
14
+ # bash setup_and_train.sh huggingface ASTERIZER/Luna_Dataset
15
  #
16
  # # Quick smoke test (10M tokens only):
17
+ # bash setup_and_train.sh huggingface ASTERIZER/Luna_Dataset 10000000
18
  #
19
  # # Dataset already on disk:
20
  # bash setup_and_train.sh local /workspace/data/litdata_pretrain_final