Download scripts/relanzar.py from Changetheblock/LicitaBench: direct link, hf CLI and curl.
- Browser
- Download file 3.51 kB
-
https://huggingface.co/datasets/Changetheblock/LicitaBench/resolve/main/scripts/relanzar.py
- Command line
-
hf download hf://datasets/Changetheblock/LicitaBench/scripts/relanzar.py
-
curl -L -o relanzar.py https://huggingface.co/datasets/Changetheblock/LicitaBench/resolve/main/scripts/relanzar.py
3.51 kB
| """Relanza en orden los lotes que llaman a Claude, reanudando donde quedaron, y tras cada lote | |
| regenera REVISAR.md, RESULTADOS.md y las cifras del README y hace commit. | |
| Si un lote se detiene por acceso o límite de uso ("ABORTADO" o "LOTE DETENIDO" en su salida), | |
| la cadena para ahí: no se reintenta en bucle. Relanzar este mismo script más tarde continúa. | |
| .venv/bin/python scripts/relanzar.py [--trabajadores 3] | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import subprocess | |
| import sys | |
| import time | |
| from pathlib import Path | |
| RAIZ = Path(__file__).resolve().parent.parent | |
| PY = str(RAIZ / ".venv/bin/python") | |
| def correr(nombre: str, cmd: list, log) -> str: | |
| print(f"\n===== {nombre} ===== {time.strftime('%H:%M:%S')}", flush=True) | |
| log.write(f"\n===== {nombre} ===== {time.strftime('%Y-%m-%d %H:%M:%S')}\n{' '.join(cmd)}\n"); log.flush() | |
| proc = subprocess.run(cmd, cwd=RAIZ, capture_output=True, text=True) | |
| salida = (proc.stdout or "") + "\n" + (proc.stderr or "") | |
| log.write(salida); log.flush() | |
| for linea in salida.splitlines(): | |
| if any(k in linea for k in ("INFO", "ERROR", "WARNING", "ABORTADO", "nuevos", "n_items")): | |
| print(linea[:220], flush=True) | |
| if proc.returncode != 0 or "ABORTADO" in salida or "LOTE DETENIDO" in salida: | |
| return "detenido" | |
| return "ok" | |
| def regenerar_y_commit(nombre: str, log) -> None: | |
| for cmd in ([PY, "scripts/cifras_readme.py"], [PY, "scripts/revisar.py"], [PY, "-m", "licitabench.evaluate", "--tabla"]): | |
| r = subprocess.run(cmd, cwd=RAIZ, capture_output=True, text=True) | |
| log.write(f"$ {' '.join(cmd)}\n{r.stdout[-400:]}\n{r.stderr[-400:]}\n") | |
| subprocess.run(["git", "add", "-A"], cwd=RAIZ, check=False) | |
| cambios = subprocess.run(["git", "status", "--porcelain"], cwd=RAIZ, capture_output=True, text=True).stdout.strip() | |
| if cambios: | |
| subprocess.run(["git", "commit", "-q", "-m", | |
| f"Lote {nombre} con la suscripción: resultados, cola y documentos regenerados\n\nCo-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>"], | |
| cwd=RAIZ, check=False) | |
| print(f"commit hecho tras {nombre}", flush=True) | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--trabajadores", type=int, default=3) | |
| a = ap.parse_args() | |
| w = str(a.trabajadores) | |
| pasos = [ | |
| ("T1 línea base", [PY, "-m", "licitabench.evaluate", "--tarea", "T1", "--modelo", "claude:claude-opus-5-5", | |
| "--n", "100", "--idioma", "es", "--semilla", "42", "--trabajadores", w]), | |
| ("T2 etiquetado", [PY, "-m", "licitabench.etiquetar", "--tarea", "T2", "--n", "60", "--trabajadores", w]), | |
| ("T3 etiquetado", [PY, "-m", "licitabench.etiquetar", "--tarea", "T3", "--n", "60", "--trabajadores", w]), | |
| ("T4 etiquetado", [PY, "-m", "licitabench.etiquetar", "--tarea", "T4", "--n", "30", "--trabajadores", w]), | |
| ] | |
| (RAIZ / "results/raw").mkdir(parents=True, exist_ok=True) | |
| with (RAIZ / "results/raw/relanzar.log").open("a", encoding="utf-8") as log: | |
| for nombre, cmd in pasos: | |
| estado = correr(nombre, cmd, log) | |
| regenerar_y_commit(nombre, log) | |
| if estado == "detenido": | |
| print(f"\nCADENA DETENIDA en {nombre}: ver results/raw/relanzar.log. Relanzar este script más tarde continúa donde quedó.", flush=True) | |
| sys.exit(2) | |
| print("\nCADENA COMPLETA", flush=True) | |
| if __name__ == "__main__": | |
| main() | |