quantcore_circuits.review.server ================================ .. py:module:: quantcore_circuits.review.server .. autoapi-nested-parse:: Live dashboard backend: serves the React app (``reviewer/`` → ``review/static``) and the run state. API (contract: ``reviewer/contract/state.ts``): - ``GET /api/state`` — ``build//state.json`` (a fresh state is created from the design if missing) - ``GET /api/events`` — Server-Sent Events: ``event: state`` whenever ``state.json`` changes, a ping every 15 s - ``GET /files/

`` — files inside the run directory (screenshots under ``shots/``) - ``POST /api/rebuild`` — rebuild the layout, write the OAS (+ klive if KLayout is open), headless screenshot, update the *Layout* step Standard library only; binds to localhost. Attributes ---------- .. autoapisummary:: quantcore_circuits.review.server.STATIC Functions --------- .. autoapisummary:: quantcore_circuits.review.server.live_run_dir quantcore_circuits.review.server.make_handler quantcore_circuits.review.server.rebuild_layout quantcore_circuits.review.server.serve quantcore_circuits.review.server.serve_live quantcore_circuits.review.server.waiting_state Module Contents --------------- .. py:function:: live_run_dir(root: pathlib.Path, run: str | None = None) -> pathlib.Path | None The run directory to show: ``root/`` if named, else the one ``root/_live.json`` points at (the run that saw the latest tracked event), else the most recently updated ``root/*/state.json``. .. py:function:: make_handler(run_dir, design_source, root: pathlib.Path | None = None) ``run_dir``: a Path (one run) or a callable returning the current run directory (or None): follow mode. .. py:function:: rebuild_layout(run, design_source) -> dict Build → OAS (+ sidecar) → klive (if available) → headless KLayout screenshot → state. .. py:function:: serve(design, port: int = 8765, open_browser: bool = True, run_dir: str | pathlib.Path | None = None, background: bool = False) Serve the dashboard for ``design`` on http://127.0.0.1:``port``. ``background=True`` returns the server (running in a daemon thread) instead of blocking, for use from Jupyter. .. py:function:: serve_live(root: str | pathlib.Path | None = None, run: str | None = None, port: int = 8765, open_browser: bool = True, background: bool = False) Serve the dashboard in follow mode: it shows the run named ``run``, or (default) whichever run saw the latest tracked event (``/_live.json``, written by :func:`quantcore_circuits.track.start`), switching by itself when a notebook moves on to another design. Same API as :func:`serve`. .. py:function:: waiting_state(root: pathlib.Path) -> dict What the dashboard shows before any run exists (follow mode): an empty state that says what to do. .. py:data:: STATIC