MCPcopy
hub / github.com/lightningpixel/modly / _poll_workflow_run

Function _poll_workflow_run

tools/modly-cli/agent.py:735–752  ·  view source on GitHub ↗
(args: argparse.Namespace, *, base_url: str, run_id: str, progress_label: str = "workflow-run")

Source from the content-addressed store, hash-verified

733
734
735def _poll_workflow_run(args: argparse.Namespace, *, base_url: str, run_id: str, progress_label: str = "workflow-run") -> tuple[dict[str, Any], str]:
736 deadline = time.monotonic() + args.timeout
737 last_status: dict[str, Any] = {}
738 while time.monotonic() < deadline:
739 status = _request_json("GET", f"{base_url}/workflow-runs/{urllib.parse.quote(str(run_id))}", timeout=args.request_timeout)
740 last_status = status if isinstance(status, dict) else {"raw": status}
741 state = last_status.get("status")
742 if state == "done":
743 return last_status, _workflow_workspace_path(last_status)
744 if state in {"error", "cancelled"}:
745 raise ModlyCliError(f"Workflow run {run_id} ended with status {state}: {last_status}", code="WORKFLOW_RUN_FAILED")
746 if getattr(args, "progress", False) and not getattr(args, "quiet", False):
747 progress = last_status.get("progress", 0)
748 step = last_status.get("step", "")
749 print(json.dumps({"phase": progress_label, "run_id": run_id, "status": state, "progress": progress, "step": step}), file=sys.stderr)
750 time.sleep(args.poll)
751
752 raise ModlyCliError(f"Timed out waiting for workflow run {run_id}. Last status: {last_status}", code="TIMEOUT")
753
754
755def _run_workflow_run(

Callers 1

_run_workflow_runFunction · 0.85

Calls 3

_request_jsonFunction · 0.85
_workflow_workspace_pathFunction · 0.85
ModlyCliErrorClass · 0.85

Tested by

no test coverage detected