File size: 919 Bytes
7dcbd04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Écrit config.json (preset par défaut ou celui demandé) à la racine du dépôt."""
import argparse
import json
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from mouh.model import DEFAULT_PRESET, PRESETS, estimate_params, preset_config  # noqa: E402


def main() -> None:
    ap = argparse.ArgumentParser()
    ap.add_argument("--preset", default=DEFAULT_PRESET, choices=sorted(PRESETS))
    ap.add_argument("--out", default=str(Path(__file__).resolve().parents[1] / "config.json"))
    a = ap.parse_args()
    cfg = preset_config(a.preset)
    d = cfg.to_dict()
    d.pop("transformers_version", None)
    d["mouh_preset"] = a.preset
    d["mouh_parameter_report"] = estimate_params(cfg).as_dict()
    Path(a.out).write_text(json.dumps(d, indent=2, sort_keys=True) + "\n", encoding="utf-8")
    print(f"écrit {a.out}")


if __name__ == "__main__":
    main()