feat: add durable run listing
This commit is contained in:
@@ -10,6 +10,22 @@ from .base import RpcCaller
|
||||
class RpcRunClientMixin:
|
||||
"""JSON-RPC implementation of workflow run lifecycle surface methods."""
|
||||
|
||||
async def list_runs(
|
||||
self: RpcCaller,
|
||||
*,
|
||||
status: str | None = None,
|
||||
cursor: str | None = None,
|
||||
limit: int = 50,
|
||||
) -> dict[str, Any]:
|
||||
return await self._call(
|
||||
"workflow.runs.list",
|
||||
{
|
||||
"status": status,
|
||||
"cursor": cursor,
|
||||
"limit": limit,
|
||||
},
|
||||
)
|
||||
|
||||
async def run_deployment(
|
||||
self: RpcCaller,
|
||||
*,
|
||||
|
||||
@@ -9,6 +9,7 @@ from wf_server import WorkflowServer
|
||||
from ..errors import WorkflowRpcError, raise_workflow_rpc_error
|
||||
from ..models import (
|
||||
InspectRunParams,
|
||||
ListRunsParams,
|
||||
ReadRunTraceParams,
|
||||
ResumeRunParams,
|
||||
StartRunParams,
|
||||
@@ -22,6 +23,19 @@ def register_methods(
|
||||
) -> None:
|
||||
"""Register run lifecycle JSON-RPC methods."""
|
||||
|
||||
@entrypoint.method(name="workflow.runs.list", errors=[WorkflowRpcError])
|
||||
async def workflow_runs_list(
|
||||
params: ListRunsParams = RpcParams(),
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
return await server.api.list_runs(
|
||||
status=params.status,
|
||||
cursor=params.cursor,
|
||||
limit=params.limit,
|
||||
)
|
||||
except (ValueError, KeyError, LookupError, FileNotFoundError) as exc:
|
||||
raise_workflow_rpc_error(exc)
|
||||
|
||||
@entrypoint.method(name="workflow.runs.start", errors=[WorkflowRpcError])
|
||||
async def workflow_runs_start(
|
||||
params: StartRunParams = RpcParams(),
|
||||
|
||||
@@ -174,6 +174,12 @@ class ValidateDeploymentParams(RpcParamsModel):
|
||||
live_check: bool = False
|
||||
|
||||
|
||||
class ListRunsParams(RpcParamsModel):
|
||||
status: Literal["completed", "failed", "interrupted"] | None = None
|
||||
cursor: str | None = None
|
||||
limit: int = Field(default=50, ge=1, le=100)
|
||||
|
||||
|
||||
class StartRunParams(RpcParamsModel):
|
||||
deployment_id: str = Field(min_length=1)
|
||||
workflow_input: dict[str, Any] = Field(default_factory=dict)
|
||||
|
||||
Reference in New Issue
Block a user