copernicus-rag-core / scripts /eqc_qa /fetch_reports.py
dmpantiu's picture
Upload folder using huggingface_hub
0ec8fd6 verified
Raw
History Blame Contribute Delete
1.44 kB
#!/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()