Add GET workflows/runs/run_id endpoint (#973)
This commit is contained in:
@@ -641,6 +641,26 @@ async def get_workflow_run(
|
||||
)
|
||||
|
||||
|
||||
@base_router.get(
|
||||
"/workflows/runs/{workflow_run_id}",
|
||||
response_model=WorkflowRunStatusResponse,
|
||||
)
|
||||
@base_router.get(
|
||||
"/workflows/runs/{workflow_run_id}/",
|
||||
response_model=WorkflowRunStatusResponse,
|
||||
include_in_schema=False,
|
||||
)
|
||||
async def get_workflow_run_by_run_id(
|
||||
workflow_run_id: str,
|
||||
current_org: Organization = Depends(org_auth_service.get_current_org),
|
||||
) -> WorkflowRunStatusResponse:
|
||||
analytics.capture("skyvern-oss-agent-workflow-run-get")
|
||||
return await app.WORKFLOW_SERVICE.build_workflow_run_status_response_by_workflow_id(
|
||||
workflow_run_id=workflow_run_id,
|
||||
organization_id=current_org.organization_id,
|
||||
)
|
||||
|
||||
|
||||
@base_router.post(
|
||||
"/workflows",
|
||||
openapi_extra={
|
||||
|
||||
@@ -612,6 +612,22 @@ class WorkflowService:
|
||||
async def get_tasks_by_workflow_run_id(self, workflow_run_id: str) -> list[Task]:
|
||||
return await app.DATABASE.get_tasks_by_workflow_run_id(workflow_run_id=workflow_run_id)
|
||||
|
||||
async def build_workflow_run_status_response_by_workflow_id(
|
||||
self,
|
||||
workflow_run_id: str,
|
||||
organization_id: str,
|
||||
) -> WorkflowRunStatusResponse:
|
||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id)
|
||||
if workflow_run is None:
|
||||
LOG.error(f"Workflow run {workflow_run_id} not found")
|
||||
raise WorkflowRunNotFound(workflow_run_id=workflow_run_id)
|
||||
workflow_permanent_id = workflow_run.workflow_permanent_id
|
||||
return await self.build_workflow_run_status_response(
|
||||
workflow_permanent_id=workflow_permanent_id,
|
||||
workflow_run_id=workflow_run_id,
|
||||
organization_id=organization_id,
|
||||
)
|
||||
|
||||
async def build_workflow_run_status_response(
|
||||
self,
|
||||
workflow_permanent_id: str,
|
||||
|
||||
Reference in New Issue
Block a user