create: InterferenceETL 1c5c32b:只留管理入口、小区信息表解析缓存、移除脚本管理打包
MemRelay-Operation: memory-save:fact-etl-optimization-2026-11-12 MemRelay-Resource: b2eebbc1-1a0e-48fe-84ce-bf400b8e4c20
This commit is contained in:
+53
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: InterferenceETL 1c5c32b:只留管理入口、小区信息表解析缓存、移除脚本管理打包
|
||||
type: fact
|
||||
permalink: main/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/interference-etl-1c5c32b-只留管理入口、小区信息表解析缓存、移除脚本管理打包
|
||||
stable_id: b2eebbc1-1a0e-48fe-84ce-bf400b8e4c20
|
||||
scope: project
|
||||
memory_type: fact
|
||||
project_id: d5a7f581-c442-4554-87b9-ee723b8b0258
|
||||
usage_profile_id: 0c9feb46-d06e-43cd-9ef0-c5813c84a998
|
||||
status: active
|
||||
revision: 1
|
||||
request_id: fact-etl-optimization-2026-11-12
|
||||
created_at: '2026-11-12T04:07:38.279346+00:00'
|
||||
updated_at: '2026-11-12T04:07:38.279346+00:00'
|
||||
tags:
|
||||
- interference-etl
|
||||
- performance
|
||||
- hosted-app
|
||||
---
|
||||
|
||||
InterferenceETL main 1c5c32b(2026-11-12 上线)的改动和现状:
|
||||
|
||||
## 入口
|
||||
- 清单 `user_auth: none`,托管列表只显示「管理」,地址是 /apps/interference-etl/admin;Metrix 对全部路径只放行应用管理员。
|
||||
|
||||
## 运行速度(生产实测)
|
||||
- 每小时入库那次运行原来约 40 秒,其中 5 个小区信息表(共 66048 个小区,约 26 MB)下载只要 0.8 秒,openpyxl 解析要 36.6 秒(每个表约 7 秒)。表按文件名日期每天最多换一次,有时几天不换。
|
||||
- 现在解析结果按表文件内容的 SHA-256 缓存在 /data/cache/cell-data/(main.CellDataCache,JSON,共约 3.3 MB)。每次仍然下载表文件并算哈希,内容变了就重新解析,所以不会读到旧数据。本次运行没用到的缓存文件会被删除。解析逻辑返回值变化时要加大 main.CELL_CACHE_VERSION。
|
||||
- 试运行对比:无缓存 39.7 秒,有缓存 3.2 秒,结果同为 1180 行。
|
||||
- 「无新数据」的运行(占 90%)从 1.37 秒降到约 1.22 秒:openpyxl 和 APScheduler 改为用到时才导入(工作进程导入 582→341 毫秒,开发机实测),历史清理不再每次执行。
|
||||
|
||||
## 历史清理时机
|
||||
- 历史保留(history_keep_days,默认 7,按目录名和文件名日期)改为只在一组新数据入库之后执行(worker.prune_history)。清理失败只写进运行日志 `history_prune_error=`,不会把已入库的运行标成失败。试运行不清理。
|
||||
|
||||
## 页面
|
||||
- 连接建立前显示「正在连接…」,8 秒后显示检查浏览器代理或网络的提示(etl-connecting),不再是空白页。WebSocket 不通时页面可用 HTTP 长轮询正常工作(需要 Metrix 89a51ed 及以后)。
|
||||
|
||||
## 运行记录
|
||||
- 工作进程没能启动等异常会把这次运行记为失败,不再一直停在「运行中」。
|
||||
|
||||
## 已删除
|
||||
- Metrix 脚本管理的打包方式:根目录 Dockerfile、scripts/build_offline_package.py、runtime_config.example.py、requirements.txt、main.py 里的 vendor 路径、runtime_config 导入、ApiSource、ApiHistoryStore、两个没人调用的 ping。
|
||||
- main.py 命令行只剩本地目录处理:`python main.py --source-dir <目录> [--output-dir] [--window]`,不写数据库。
|
||||
- aidocs/project_context.md 不再纳入 git(.gitignore 早已忽略 aidocs/),本地文件保留。
|
||||
- 本地被忽略的 plugins/InterferenceETL/runtime_config.py 已无代码使用,里面还存着一个 Metrix API 令牌,没有删除,等用户决定。
|
||||
|
||||
## 测试
|
||||
- `python -m unittest discover -s tests`(用 plugins/InterferenceETL/.venv,PYTHONPATH 含插件根目录和 tests),67 个用例通过。
|
||||
|
||||
## 没做的
|
||||
- SFTP 不校验主机密钥(paramiko Transport 直接 connect)。
|
||||
- main.py 仍是单文件,没有拆分。
|
||||
- openpyxl 解析本身没有提速,每天换表后的第一次运行仍要约 40 秒。
|
||||
Reference in New Issue
Block a user