File size: 1,444 Bytes
0ec8fd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
"""
fetch_reports.py — obtain the C3S EQC Quality Assessment notebooks.

Source: public GitHub repo ecmwf-projects/c3s2-eqc-quality-assessment (74 .ipynb).
Strategy: shallow git clone into eqc_qa/repo (idempotent — re-fetches if missing).
Then list every notebook with its top-level category dir + filename.

Text only; no rendering. stderr logging.
"""
import subprocess
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parent
REPO = ROOT / "repo"
URL = "https://github.com/ecmwf-projects/c3s2-eqc-quality-assessment"


def log(*a):
    print(*a, file=sys.stderr, flush=True)


def ensure_repo() -> None:
    if (REPO / ".git").exists():
        log(f"repo already present: {REPO}")
        return
    log(f"cloning {URL} --depth 1 -> {REPO}")
    subprocess.run(
        ["git", "clone", "--depth", "1", URL, str(REPO)],
        check=True,
    )


def list_notebooks() -> list[Path]:
    return sorted(REPO.rglob("*.ipynb"))


def main() -> None:
    ensure_repo()
    nbs = list_notebooks()
    log(f"found {len(nbs)} notebooks")
    from collections import Counter
    cats = Counter(nb.relative_to(REPO).parts[0] for nb in nbs)
    for nb in nbs:
        rel = nb.relative_to(REPO)
        print(f"{rel.parts[0]}\t{nb.name}")
    log("category counts: " + ", ".join(f"{k}={v}" for k, v in sorted(cats.items())))
    log(f"TOTAL {len(nbs)} notebooks")


if __name__ == "__main__":
    main()