Unverified Commit c9ab808d authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

symphony/client: use console for incremental output

parent 801523fc
...@@ -328,24 +328,26 @@ class SimBricksClient: ...@@ -328,24 +328,26 @@ class SimBricksClient:
console = Console() console = Console()
with console.status(f"[bold green]Waiting for run {run_id} to finish...") as status: with console.status(f"[bold green]Waiting for run {run_id} to finish...") as status:
last_run = None last_run = None
output = []
prev_len = 0 prev_len = 0
while True: while True:
run = await self.get_run(run_id) run = await self.get_run(run_id)
output = await self.get_run_console(run_id)
if not last_run or last_run["state"] != run["state"]: if not last_run or last_run["state"] != run["state"]:
console.log(f"Run State:", run["state"]) console.log(f"Run State:", run["state"])
if not last_run or (len(last_run["output"]) != len(run["output"]) and len(run["output"]) != 0): if len(output) != prev_len:
prev_len = len(last_run["output"]) if last_run else 0 for l in output[prev_len]:
# console.log(run["output"][prev_len:]) console.log(l["simulator"] + ':' + l["output"])
console.log(run["output"]) # TODO: FIXME prev_len = len(output)
# did we finish? # did we finish?
if run["state"] != "pending" and run["state"] != "running": if run["state"] != "pending" and run["state"] != "running":
break break
last_run = run last_run = run
await asyncio.sleep(15) await asyncio.sleep(1)
console.log("Run {run_id} finished") console.log("Run {run_id} finished")
...@@ -373,6 +375,10 @@ class SimBricksClient: ...@@ -373,6 +375,10 @@ class SimBricksClient:
with open(store_path, "wb") as f: with open(store_path, "wb") as f:
f.write(content) f.write(content)
async def get_run_console(self, rid: int) -> list[dict]:
async with self._ns_client.get(url=f"/runs/{rid}/console") as resp:
return await resp.json()
class RunnerClient: class RunnerClient:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment