jvonrad commited on
Commit
60c88bd
·
verified ·
1 Parent(s): 73919ed

Upload src/xscript/paths.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/xscript/paths.py +47 -0
src/xscript/paths.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Central path layout.
2
+
3
+ Everything heavy lives on Lustre scratch (override with XSCRIPT_SCRATCH).
4
+ Small, committable outputs (tables, metrics) go to <repo>/results.
5
+ """
6
+ import os
7
+ from pathlib import Path
8
+
9
+ REPO = Path(__file__).resolve().parents[2]
10
+
11
+ # Isambard scratch layout is /scratch/<project>/<user> with user "<name>.<project>".
12
+ _user = os.environ.get("USER", "user")
13
+ _project = _user.rsplit(".", 1)[-1]
14
+ SCRATCH = Path(os.environ.get("XSCRIPT_SCRATCH", f"/scratch/{_project}/{_user}/xscript"))
15
+
16
+ RESULTS = Path(os.environ.get("XSCRIPT_RESULTS", REPO / "results"))
17
+
18
+ # scratch subtrees
19
+ FLORES_DIR = SCRATCH / "flores_plus" # downloaded FLORES+ jsonl files
20
+ MANIFEST_CACHE = SCRATCH / "manifests" # cached HF file/size listings (transient)
21
+ TOK_CORPORA = SCRATCH / "tok_corpora" # tokenizer training corpora
22
+ TOKENIZERS = SCRATCH / "tokenizers" # trained tokenizer artifacts
23
+ POOLS = SCRATCH / "pools" # per-language text pools (zstd jsonl)
24
+ SHARDS = SCRATCH / "shards" # per-(lang, tokenizer) uint16 token shards
25
+ RUNS = SCRATCH / "runs" # checkpoints + training logs
26
+ HOLDOUT = SCRATCH / "holdout" # in-domain eval holdout (excluded from pools)
27
+
28
+
29
+ def ensure(p: Path) -> Path:
30
+ p.mkdir(parents=True, exist_ok=True)
31
+ return p
32
+
33
+
34
+ def tokenizer_dir(name: str) -> Path:
35
+ return TOKENIZERS / name
36
+
37
+
38
+ def pool_dir(lang: str) -> Path:
39
+ return POOLS / lang
40
+
41
+
42
+ def shard_dir(lang: str, tok: str) -> Path:
43
+ return SHARDS / f"{lang}__{tok}"
44
+
45
+
46
+ def run_dir(run_name: str) -> Path:
47
+ return RUNS / run_name