add service api of get workflow run node executions

pull/19711/head
lizb 1 year ago
parent 1c91736a6d
commit 1320a10a8e

@ -26,6 +26,7 @@ from core.errors.error import (
from core.model_runtime.errors.invoke import InvokeError
from extensions.ext_database import db
from fields.workflow_app_log_fields import workflow_app_log_pagination_fields
from fields.workflow_run_fields import workflow_run_node_execution_list_fields
from libs import helper
from libs.helper import TimestampField
from models.model import App, AppMode, EndUser
@ -33,6 +34,7 @@ from models.workflow import WorkflowRun, WorkflowRunStatus
from services.app_generate_service import AppGenerateService
from services.errors.llm import InvokeRateLimitError
from services.workflow_app_service import WorkflowAppService
from services.workflow_run_service import WorkflowRunService
logger = logging.getLogger(__name__)
@ -162,7 +164,23 @@ class WorkflowAppLogApi(Resource):
return workflow_app_log_pagination
class WorkflowRunNodeExecutionListServiceApi(Resource):
@validate_app_token
@marshal_with(workflow_run_node_execution_list_fields)
def get(self, app_model: App, workflow_run_id: str):
"""
Get workflow run node execution list
"""
run_id = str(workflow_run_id)
workflow_run_service = WorkflowRunService()
node_executions = workflow_run_service.get_workflow_run_node_executions(app_model=app_model, run_id=run_id)
return {"data": node_executions}
api.add_resource(WorkflowRunApi, "/workflows/run")
api.add_resource(WorkflowRunDetailApi, "/workflows/run/<string:workflow_run_id>")
api.add_resource(WorkflowTaskStopApi, "/workflows/tasks/<string:task_id>/stop")
api.add_resource(WorkflowAppLogApi, "/workflows/logs")
api.add_resource(WorkflowRunNodeExecutionListServiceApi, "/workflows/run/<string:workflow_run_id>/node-executions")

@ -611,6 +611,92 @@ Workflow applications offers non-session support and is ideal for translation, a
</Row>
---
<Heading
url='/workflows/run/:workflow_run_id/node-executions'
method='GET'
title='Get node execution information of a workflow'
name='#Get-Workflow-Run-Node-Executions'
/>
<Row>
<Col>
Returns the node execution information of a workflow in descending order
### Response
- `data` (array[object])
- `id` (string) Identifier
- `created_at` (timestamp) Creation time
- `created_by_account` (object) Account information that created the node
- `email` (string) Email
- `id` (string) Identifier
- `name` (string) Name
- `created_by_end_user` (object|null) End user
- `created_by_role` (string) Role, e.g. `account`
- `elapsed_time` (float) Elapsed time in seconds
- `error` (string|null) Error message
- `execution_metadata` (object|null) Execution metadata
- `extras` (object) Additional information
- `finished_at` (timestamp) Finish time
- `index` (int) Node index
- `inputs` (any|null) Input data
- `node_id` (string) Node identifier
- `node_type` (string) Node type, e.g. `end`
- `outputs` (any|null) Output data
- `predecessor_node_id` (string|null) Predecessor node identifier
- `process_data` (object|null) Processing data
- `status` (string) Execution status, `running` / `succeeded` / `failed` / `stopped`
- `title` (string) Node title
</Col>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/workflows/run/:workflow_run_id/node-executions" targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id/node-executions'\\\n --header 'Authorization: Bearer {api_key}'`}>
```bash {{ title: 'cURL' }}
curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id/node-executions'
--header 'Authorization: Bearer {api_key}'
```
</CodeGroup>
### Response Example
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"data": [
{
"created_at": 1747244722,
"created_by_account":
{
"email": "lizb@test.com",
"id": "17f71940-a7b5-4c77-b60f-2bd645c1ffa0",
"name": "lizb"
},
"created_by_end_user": None,
"created_by_role": "account",
"elapsed_time": 0.838795,
"error": None,
"execution_metadata": None,
"extras": {},
"finished_at": 1747244722,
"id": "bffa2838-0e2c-4cba-bc9c-9abbcc38d001",
"index": 3,
"inputs": None,
"node_id": "1747273509709",
"node_type": "end",
"outputs": None,
"predecessor_node_id": "1745917690204",
"process_data": None,
"status": "succeeded",
"title": "Finish",
},
...
]
}
```
</CodeGroup>
</Col>
</Row>
---
<Heading
url='/info'
method='GET'

@ -614,6 +614,92 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
</Row>
---
<Heading
url='/workflows/run/:workflow_run_id/node-executions'
method='GET'
title='特定のワークフローのノード実行情報を取得'
name='#Get-Workflow-Run-Node-Executions'
/>
<Row>
<Col>
ワークフローのノード実行情報を降順で返します
### Response
- `data` (array[object])
- `id` (string) 識別子
- `created_at` (timestamp) 作成時間
- `created_by_account` (object) このノードを作成したアカウント情報
- `email` (string) メールアドレス
- `id` (string) 識別子
- `name` (string) 名前
- `created_by_end_user` (object|null) ユーザー
- `created_by_role` (string) 役割、例:'account`
- `elapsed_time` (float) 経過時間(単位:秒)
- `error` (string|null) エラーメッセージ
- `execution_metadata` (object|null) 実行メタデータ
- `extras` (object) 追加情報
- `finished_at` (timestamp) 終了時間
- `index` (int) ノードインデックス
- `inputs` (any|null) 入力データ
- `node_id` (string) ノード識別子
- `node_type` (string) ノードタイプ、例:'end`
- `outputs` (any|null) 出力データ
- `predecessor_node_id` (string|null) 先行ノード識別子
- `process_data` (object|null) 処理データ
- `status` (string) 実行状態、'running` / `succeeded` / `failed` / `stopped`
- `title` (string) ノードのタイトル
</Col>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/workflows/run/:workflow_run_id/node-executions" targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id/node-executions'\\\n --header 'Authorization: Bearer {api_key}'`}>
```bash {{ title: 'cURL' }}
curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id/node-executions'
--header 'Authorization: Bearer {api_key}'
```
</CodeGroup>
### Response Example
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"data": [
{
"created_at": 1747244722,
"created_by_account":
{
"email": "lizb@test.com",
"id": "17f71940-a7b5-4c77-b60f-2bd645c1ffa0",
"name": "lizb"
},
"created_by_end_user": None,
"created_by_role": "account",
"elapsed_time": 0.838795,
"error": None,
"execution_metadata": None,
"extras": {},
"finished_at": 1747244722,
"id": "bffa2838-0e2c-4cba-bc9c-9abbcc38d001",
"index": 3,
"inputs": None,
"node_id": "1747273509709",
"node_type": "end",
"outputs": None,
"predecessor_node_id": "1745917690204",
"process_data": None,
"status": "succeeded",
"title": "Finish",
},
...
]
}
```
</CodeGroup>
</Col>
</Row>
---
<Heading
url='/info'
method='GET'

@ -602,6 +602,92 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
</Row>
---
<Heading
url='/workflows/run/:workflow_run_id/node-executions'
method='GET'
title='获取某个workflow的节点执行情况'
name='#Get-Workflow-Run-Node-Executions'
/>
<Row>
<Col>
倒序返回workflow的节点执行情况
### Response
- `data` (array[object])
- `id` (string) 标识
- `created_at` (timestamp) 创建时间
- `created_by_account` (object) 创建该节点的账户信息
- `email` (string) 邮箱
- `id` (string) 标识
- `name` (string) 名称
- `created_by_end_user` (object|null) 用户
- `created_by_role` (string) 角色,例如 `account`
- `elapsed_time` (float) 耗时,单位秒
- `error` (string|null) 错误信息
- `execution_metadata` (object|null) 执行元数据
- `extras` (object) 附加信息
- `finished_at` (timestamp) 结束时间
- `index` (int) 节点索引
- `inputs` (any|null) 输入数据
- `node_id` (string) 节点标识
- `node_type` (string) 节点类型,例如 `end`
- `outputs` (any|null) 输出数据
- `predecessor_node_id` (string|null) 前置节点标识
- `process_data` (object|null) 处理数据
- `status` (string) 执行状态,'running` / `succeeded` / `failed` / `stopped`
- `title` (string) 节点标题
</Col>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/workflows/run/:workflow_run_id/node-executions" targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id/node-executions'\\\n --header 'Authorization: Bearer {api_key}'`}>
```bash {{ title: 'cURL' }}
curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id/node-executions'
--header 'Authorization: Bearer {api_key}'
```
</CodeGroup>
### Response Example
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"data": [
{
"created_at": 1747244722,
"created_by_account":
{
"email": "lizb@test.com",
"id": "17f71940-a7b5-4c77-b60f-2bd645c1ffa0",
"name": "lizb"
},
"created_by_end_user": None,
"created_by_role": "account",
"elapsed_time": 0.838795,
"error": None,
"execution_metadata": None,
"extras": {},
"finished_at": 1747244722,
"id": "bffa2838-0e2c-4cba-bc9c-9abbcc38d001",
"index": 3,
"inputs": None,
"node_id": "1747273509709",
"node_type": "end",
"outputs": None,
"predecessor_node_id": "1745917690204",
"process_data": None,
"status": "succeeded",
"title": "Finish",
},
...
]
}
```
</CodeGroup>
</Col>
</Row>
---
<Heading
url='/info'
method='GET'

Loading…
Cancel
Save