INNER CODE UNIT · Python
_run_with_dashboard
i3T4AN/KADATH · kadath/cli.py:282
def _run_with_dashboard(kernel: Kernel, run_id: str, epochs: int | None) -> int:
result: dict[str, object] = {}
def run() -> None:
try: result["count"] = kernel.run(run_id, epochs)
except BaseException as exc: result["error"] = exc
thread = threading.Thread(target=run, daemon=True)
thread.start()
interactive = sys.stdout.isatty()
while thread.is_alive():
output = _render_dashboard(kernel.status(run_id), styled=interactive)
print(("\033[H\033[2J" if interactive else "") + output, flush=True)
thread.join(.75)
if "error" in result:
raise result["error"]
return int(result["count"])
if __name__ == "__main__":