feature: /api/v1/runs/{run_id}/export 按照需求导出测试结果
This commit is contained in:
@@ -78,8 +78,9 @@ Swagger 也可直接测试:打开 `/docs` 后,点击右上角 **Authorize**
|
||||
6. `GET /api/v1/runs`
|
||||
7. `GET /api/v1/runs/{run_id}`
|
||||
8. `GET /api/v1/runs/{run_id}/results`
|
||||
9. `GET /api/v1/reports`
|
||||
10. `GET /api/v1/reports/{run_id}`
|
||||
9. `GET /api/v1/runs/{run_id}/export`
|
||||
10. `GET /api/v1/reports`
|
||||
11. `GET /api/v1/reports/{run_id}`
|
||||
|
||||
创建运行的网络重试应复用同一个 `Idempotency-Key` 请求头;同一键与同一请求只会创建一个运行。
|
||||
|
||||
@@ -105,7 +106,16 @@ curl -X POST http://127.0.0.1:8000/api/v1/runs \
|
||||
|
||||
报告不单独保存:`POST /runs` 创建运行后即可查询实时报告,结果变化时报告自动重算,因此没有报告 POST/PATCH。删除终态 run 会同时删除其结果,之后对应报告返回 404。
|
||||
|
||||
运行结束后可将详细结果导出为 Markdown:
|
||||
运行结束后可通过 API 将详细结果下载为 Markdown:
|
||||
|
||||
```bash
|
||||
curl -OJ -H 'Authorization: Bearer <access_token>' \
|
||||
'http://127.0.0.1:8000/api/v1/runs/42/export?execution_status=completed&verdict=fail'
|
||||
```
|
||||
|
||||
不传查询参数时导出全部样例。`execution_status` 接受 `completed|error`,`verdict` 接受 `pass|fail|needs_human_review|judge_format_error|none`;运行不存在返回 404,尚未结束返回 409,非法过滤值返回 422。
|
||||
|
||||
服务器命令行也可导出:
|
||||
|
||||
```bash
|
||||
uv run python scripts/export_run.py --run-id 42
|
||||
|
||||
@@ -128,7 +128,21 @@ curl -X POST http://127.0.0.1:8000/api/v1/runs/42/results/R0049/retry
|
||||
|
||||
### 导出 Markdown 详细报告
|
||||
|
||||
`scripts/export_run.py` 通过 API 登录并导出一个终态 Run。默认包含全部逐条结果:
|
||||
`GET /api/v1/runs/{run_id}/export` 将终态 Run 下载为 Markdown 附件,默认包含全部逐条结果:
|
||||
|
||||
```bash
|
||||
curl -OJ -H 'Authorization: Bearer <access_token>' \
|
||||
http://127.0.0.1:8000/api/v1/runs/42/export
|
||||
```
|
||||
|
||||
API 接受两个可组合的查询参数:
|
||||
|
||||
- `execution_status=completed|error`:按执行状态导出。
|
||||
- `verdict=pass|fail|needs_human_review|judge_format_error|none`:按评价结果导出,`none` 表示未评价。
|
||||
|
||||
运行不存在返回 404,尚未结束返回 409,非法参数返回 422。响应的 `Content-Disposition` 文件名为 `run_<run_id>_results.md`。
|
||||
|
||||
`scripts/export_run.py` 提供相同过滤能力,适合服务器命令行操作:
|
||||
|
||||
```bash
|
||||
uv run python scripts/export_run.py \
|
||||
@@ -189,6 +203,8 @@ OC 未泄露率。低于阻断线为 `NOT_READY`,低于目标线为 `CONDITION
|
||||
| `test_provider_writes_require_admin` | provider 写操作管理员授权 |
|
||||
| `test_provider_contracts` | `POST /providers/{provider_id}/check`、`GET /providers/{provider_id}/models` |
|
||||
| `test_run_and_report_contracts` | `POST/GET /runs`、`POST /runs/{id}/resume`、`GET /runs/{id}`、`GET /runs/{id}/results`、`GET /reports`、`GET /reports/{id}` |
|
||||
| `test_export_run_markdown_defaults_to_all_and_filters_results` | `GET /runs/{id}/export` 的 Markdown 附件、默认全量与组合过滤 |
|
||||
| `test_export_run_requires_terminal_run_and_valid_filters` | 导出接口的 404、409 与 422 边界 |
|
||||
| `test_reports_are_derived_read_only_resources` | 报告 404 及不开放独立 POST/PATCH/DELETE 的只读边界 |
|
||||
| `test_run_cancel_and_delete_contract` | `PATCH/DELETE /runs/{id}` 的取消、终态与删除规则 |
|
||||
| `test_retry_errors_keeps_successes_and_requeues_only_errors` | resume/retry-errors 分工、成功结果保留与错误重排队 |
|
||||
|
||||
Reference in New Issue
Block a user