6.2 KiB
6.2 KiB
- [P20260219-062736] 2026-02-19 06:27:36 +0800
- summary: CONTEXT TRANSFER: We are continuing a conversation that had gotten too long. Here is a summary: --- ## TASK 1: Admin-web…
- prompt:
CONTEXT TRANSFER: We are continuing a conversation that had gotten too long. Here is a summary:
---
## TASK 1: Admin-web 同步检查与 Bug 修复(ETL 重构后)
**STATUS**: done
**USER QUERIES**: 1 ("检查admin-web是否需要同步更新,检查所有功能,debug")
**DETAILS**:
在大量 ETL 重构后,全面检查并修复了 admin-web 前端与后端的同步问题。以下修复均已完成:
1. `apps/backend/app/config.py` — ETL_PROJECT_PATH 路径从 `pipelines` 修正为 `connectors`
2. `apps/backend/app/services/cli_builder.py` — `--pipeline` 改为 `--flow`
3. `apps/admin-web/src/api/tasks.ts` — validateTaskConfig 请求格式改为 `{ config }`
4. `apps/admin-web/src/pages/LogViewer.tsx` — 读取 `data.output_log` 而非 `data.logs`
5. `apps/admin-web/src/types/index.ts` — 添加 `force_full: boolean`
6. `apps/admin-web/src/pages/TaskConfig.tsx` — `buildTaskConfig()` 添加 `force_full`
7. `apps/admin-web/src/components/ScheduleTab.tsx` — 默认 `force_full: false`
8. `apps/backend/app/schemas/tasks.py` — TaskConfigSchema 添加 `force_full`
9. `apps/backend/app/services/cli_builder.py` — 添加 `--force-full` CLI 参数
10. `apps/etl/connectors/feiqiu/cli/main.py` — 添加 `--force-full` CLI 参数定义
11. `apps/admin-web/vite.config.ts` — `defineConfig` 改为从 `vitest/config` 导入
12. `apps/admin-web/src/store/authStore.ts` — `get` 改为 `_get`
构建验证通过:`pnpm run build` 成功。
**FILEPATHS**: `apps/backend/app/config.py`, `apps/backend/app/services/cli_builder.py`, `apps/backend/app/schemas/tasks.py`, `apps/admin-web/src/api/tasks.ts`, `apps/admin-web/src/pages/LogViewer.tsx`, `apps/admin-web/src/pages/TaskConfig.tsx`, `apps/admin-web/src/types/index.ts`, `apps/admin-web/src/components/ScheduleTab.tsx`, `apps/admin-web/src/store/authStore.ts`, `apps/admin-web/vite.config.ts`, `apps/etl/connectors/feiqiu/cli/main.py`
---
## TASK 2: 从 admin-web 执行 ETL 任务
**STATUS**: in-progress
**USER QUERIES**: 1 ("从admin-web执行任务:api_full, 校验并修复, 从API获取数据, 2025-11-01到2026-02-19, 窗口切分10天, force-full, 全任务全表")
**DETAILS**:
### 已完成的浏览器操作配置:
在 admin-web 任务配置页面完成了所有参数设置并点击了"直接执行":
- Flow: `api_full` ✓
- 处理模式: 校验并修复 ✓
- 校验前从 API 获取 ✓
- 时间窗口: 2025-11-01 ~ 2026-02-19 ✓
- 窗口切分: 10天 ✓
- force-full ✓
- 任务: 52/52 全选 ✓
- DWD 表: 40/40 全选 ✓
### 发现并修复的关键 Bug — Windows 子进程启动失败:
首次执行时任务立即 `failed`(772ms),`exit_code: null`,`output_log` 和 `error_log` 均为空。
**根因**: `asyncio.create_subprocess_exec` 在 Windows 上抛出 `NotImplementedError`。uvicorn 在 Windows 上使用的事件循环不支持 `asyncio.subprocess`。
**修复方案**: 将 `task_executor.py` 中的 `execute` 方法从 `asyncio.create_subprocess_exec` 改为 `subprocess.Popen` + `threading` + `asyncio.run_in_executor`,完全兼容 Windows。
**具体改动**(`apps/backend/app/services/task_executor.py`):
- 添加 `import subprocess, threading`
- `__init__`: `_processes` 类型从 `asyncio.subprocess.Process` 改为 `subprocess.Popen`
- `execute`: 改用 `run_in_executor` 调用新的 `_run_subprocess` 方法
- 新增 `_run_subprocess`: 使用 `subprocess.Popen` + 两个 daemon 线程读取 stdout/stderr
- `_run_subprocess` 中设置 `env["PYTHONIOENCODING"] = "utf-8"` 解决 Windows GBK 乱码
- 删除了原来的 `_read_stream` async 方法(不再需要)
- `is_running`: 改用 `proc.poll()` 判断
- `cancel`: 改用 `proc.poll()` 和 `proc.terminate()`
**验证结果**:
- dry-run 测试执行成功:子进程正常启动,`output_log` 有 8523 字节内容
- 编码问题已通过 `PYTHONIOENCODING=utf-8` 修复
- 状态正确显示为 `running`
### 当前状态:
修复完成后,需要重新在任务配置页面配置参数并执行完整任务。当前浏览器已导航回任务配置页面(`http://localhost:5174/`),所有选项已重置为默认值,需要重新配置。
**NEXT STEPS**:
1. 在任务配置页面重新配置所有参数(与上面相同的配置):
- 选择 `api_full` Flow(radio)
- 选择"校验并修复"处理模式
- 勾选"校验前从 API 获取"
- 切换到"自定义模式"时间窗口
- 输入开始日期 2025-11-01,结束日期 2026-02-19
- 选择窗口切分 10天
- 展开高级选项,勾选 force-full
- 点击任务选择"全选"(52个)
- 点击 DWD 表选择"全选"(40个)
2. 点击"直接执行"
3. 监控执行状态,确认任务正常运行
4. 注意:ETL 在校验 `dim_assistant_ex` 表时会遇到 `ValueError: year -1 is out of range`(数据质量问题,非代码 bug)
**FILEPATHS**: `apps/backend/app/services/task_executor.py`, `apps/admin-web/src/pages/TaskConfig.tsx`
---
## USER CORRECTIONS AND INSTRUCTIONS:
- 所有说明性文字使用简体中文
- 后端用 `uv run` 启动(不是直接 `python`)
- 前端用 `pnpm` 管理
- 用户手动完成了登录(数据库 `test_zqyy_app` 的凭据问题不是代码 bug)
- 后端进程 ID 3 运行在端口 8000(`uv run uvicorn app.main:app --reload --port 8000`,cwd: `apps/backend`)
- 前端进程 ID 4 运行在端口 5174(`pnpm run dev`,cwd: `apps/admin-web`)
- ETL 项目实际路径是 `apps/etl/connectors/feiqiu/`
- 浏览器中 localStorage 的 token key 是 `access_token`(不是 `auth-storage`)
- 可通过 JS evaluate 获取 token 并调用后端 API:`localStorage.getItem('access_token')`
---
## Files to read
- `apps/backend/app/services/task_executor.py`
- `apps/backend/app/services/cli_builder.py`
- `apps/admin-web/src/pages/TaskConfig.tsx`
---
METADATA:
The previous conversation had 2 messages.
INSTRUCTIONS:
Continue working until the user query has been fully addressed. Do not ask for clarification - proceed with the work based on the context provided.
IMPORTANT: you need to read from the files to Read section