aiecs 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of aiecs might be problematic. Click here for more details.
- aiecs/__init__.py +75 -0
- aiecs/__main__.py +41 -0
- aiecs/aiecs_client.py +295 -0
- aiecs/application/__init__.py +10 -0
- aiecs/application/executors/__init__.py +10 -0
- aiecs/application/executors/operation_executor.py +341 -0
- aiecs/config/__init__.py +15 -0
- aiecs/config/config.py +117 -0
- aiecs/config/registry.py +19 -0
- aiecs/core/__init__.py +46 -0
- aiecs/core/interface/__init__.py +34 -0
- aiecs/core/interface/execution_interface.py +150 -0
- aiecs/core/interface/storage_interface.py +214 -0
- aiecs/domain/__init__.py +20 -0
- aiecs/domain/context/__init__.py +28 -0
- aiecs/domain/context/content_engine.py +982 -0
- aiecs/domain/context/conversation_models.py +306 -0
- aiecs/domain/execution/__init__.py +12 -0
- aiecs/domain/execution/model.py +49 -0
- aiecs/domain/task/__init__.py +13 -0
- aiecs/domain/task/dsl_processor.py +460 -0
- aiecs/domain/task/model.py +50 -0
- aiecs/domain/task/task_context.py +257 -0
- aiecs/infrastructure/__init__.py +26 -0
- aiecs/infrastructure/messaging/__init__.py +13 -0
- aiecs/infrastructure/messaging/celery_task_manager.py +341 -0
- aiecs/infrastructure/messaging/websocket_manager.py +289 -0
- aiecs/infrastructure/monitoring/__init__.py +12 -0
- aiecs/infrastructure/monitoring/executor_metrics.py +138 -0
- aiecs/infrastructure/monitoring/structured_logger.py +50 -0
- aiecs/infrastructure/monitoring/tracing_manager.py +376 -0
- aiecs/infrastructure/persistence/__init__.py +12 -0
- aiecs/infrastructure/persistence/database_manager.py +286 -0
- aiecs/infrastructure/persistence/file_storage.py +671 -0
- aiecs/infrastructure/persistence/redis_client.py +162 -0
- aiecs/llm/__init__.py +54 -0
- aiecs/llm/base_client.py +99 -0
- aiecs/llm/client_factory.py +339 -0
- aiecs/llm/custom_callbacks.py +228 -0
- aiecs/llm/openai_client.py +125 -0
- aiecs/llm/vertex_client.py +186 -0
- aiecs/llm/xai_client.py +184 -0
- aiecs/main.py +351 -0
- aiecs/scripts/DEPENDENCY_SYSTEM_SUMMARY.md +241 -0
- aiecs/scripts/README_DEPENDENCY_CHECKER.md +309 -0
- aiecs/scripts/README_WEASEL_PATCH.md +126 -0
- aiecs/scripts/__init__.py +3 -0
- aiecs/scripts/dependency_checker.py +825 -0
- aiecs/scripts/dependency_fixer.py +348 -0
- aiecs/scripts/download_nlp_data.py +348 -0
- aiecs/scripts/fix_weasel_validator.py +121 -0
- aiecs/scripts/fix_weasel_validator.sh +82 -0
- aiecs/scripts/patch_weasel_library.sh +188 -0
- aiecs/scripts/quick_dependency_check.py +269 -0
- aiecs/scripts/run_weasel_patch.sh +41 -0
- aiecs/scripts/setup_nlp_data.sh +217 -0
- aiecs/tasks/__init__.py +2 -0
- aiecs/tasks/worker.py +111 -0
- aiecs/tools/__init__.py +196 -0
- aiecs/tools/base_tool.py +202 -0
- aiecs/tools/langchain_adapter.py +361 -0
- aiecs/tools/task_tools/__init__.py +82 -0
- aiecs/tools/task_tools/chart_tool.py +704 -0
- aiecs/tools/task_tools/classfire_tool.py +901 -0
- aiecs/tools/task_tools/image_tool.py +397 -0
- aiecs/tools/task_tools/office_tool.py +600 -0
- aiecs/tools/task_tools/pandas_tool.py +565 -0
- aiecs/tools/task_tools/report_tool.py +499 -0
- aiecs/tools/task_tools/research_tool.py +363 -0
- aiecs/tools/task_tools/scraper_tool.py +548 -0
- aiecs/tools/task_tools/search_api.py +7 -0
- aiecs/tools/task_tools/stats_tool.py +513 -0
- aiecs/tools/temp_file_manager.py +126 -0
- aiecs/tools/tool_executor/__init__.py +35 -0
- aiecs/tools/tool_executor/tool_executor.py +518 -0
- aiecs/utils/LLM_output_structor.py +409 -0
- aiecs/utils/__init__.py +23 -0
- aiecs/utils/base_callback.py +50 -0
- aiecs/utils/execution_utils.py +158 -0
- aiecs/utils/logging.py +1 -0
- aiecs/utils/prompt_loader.py +13 -0
- aiecs/utils/token_usage_repository.py +279 -0
- aiecs/ws/__init__.py +0 -0
- aiecs/ws/socket_server.py +41 -0
- aiecs-1.0.0.dist-info/METADATA +610 -0
- aiecs-1.0.0.dist-info/RECORD +90 -0
- aiecs-1.0.0.dist-info/WHEEL +5 -0
- aiecs-1.0.0.dist-info/entry_points.txt +7 -0
- aiecs-1.0.0.dist-info/licenses/LICENSE +225 -0
- aiecs-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# AIECS 依赖检查系统实现总结
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
基于 `/home/coder1/python-middleware-dev/docs/TOOLS_USED_INSTRUCTION/TOOL_SPECIAL_SPECIAL_INSTRUCTIONS.md` 文档中的工具特殊使用说明,我们为 AIECS 包实现了一个全面的依赖检查系统。
|
|
6
|
+
|
|
7
|
+
## 实现的功能
|
|
8
|
+
|
|
9
|
+
### 1. 综合依赖检查脚本 (`dependency_checker.py`)
|
|
10
|
+
|
|
11
|
+
**功能**:
|
|
12
|
+
- 检查所有 AIECS 工具的系统级依赖、Python包依赖和模型文件
|
|
13
|
+
- 支持 6 个主要工具:Image Tool、ClassFire Tool、Office Tool、Stats Tool、Report Tool、Scraper Tool
|
|
14
|
+
- 生成详细的依赖状态报告
|
|
15
|
+
- 提供安装命令和影响说明
|
|
16
|
+
|
|
17
|
+
**特点**:
|
|
18
|
+
- 跨平台支持 (Linux、macOS、Windows)
|
|
19
|
+
- 详细的错误处理和日志记录
|
|
20
|
+
- 可扩展的架构,易于添加新工具
|
|
21
|
+
|
|
22
|
+
### 2. 快速依赖检查脚本 (`quick_dependency_check.py`)
|
|
23
|
+
|
|
24
|
+
**功能**:
|
|
25
|
+
- 快速检查关键依赖项
|
|
26
|
+
- 适合安装后验证
|
|
27
|
+
- 生成简洁的状态报告
|
|
28
|
+
- 提供基本的安装命令
|
|
29
|
+
|
|
30
|
+
**特点**:
|
|
31
|
+
- 轻量级,执行速度快
|
|
32
|
+
- 专注于关键依赖
|
|
33
|
+
- 适合自动化场景
|
|
34
|
+
|
|
35
|
+
### 3. 自动依赖修复脚本 (`dependency_fixer.py`)
|
|
36
|
+
|
|
37
|
+
**功能**:
|
|
38
|
+
- 自动安装缺失的依赖项
|
|
39
|
+
- 支持交互和非交互模式
|
|
40
|
+
- 智能的依赖分组和安装顺序
|
|
41
|
+
- 详细的修复报告
|
|
42
|
+
|
|
43
|
+
**特点**:
|
|
44
|
+
- 用户友好的确认机制
|
|
45
|
+
- 支持多种包管理器 (apt、brew、pip)
|
|
46
|
+
- 完整的错误处理和回滚
|
|
47
|
+
|
|
48
|
+
### 4. 集成到安装流程
|
|
49
|
+
|
|
50
|
+
**setup.py 更新**:
|
|
51
|
+
- 在 `run_post_install()` 函数中集成依赖检查
|
|
52
|
+
- 添加了 3 个新的命令行工具入口点
|
|
53
|
+
- 提供安装后的自动验证
|
|
54
|
+
|
|
55
|
+
**命令行工具**:
|
|
56
|
+
- `aiecs-check-deps`: 完整依赖检查
|
|
57
|
+
- `aiecs-quick-check`: 快速依赖检查
|
|
58
|
+
- `aiecs-fix-deps`: 自动依赖修复
|
|
59
|
+
|
|
60
|
+
## 支持的依赖类型
|
|
61
|
+
|
|
62
|
+
### 系统级依赖
|
|
63
|
+
|
|
64
|
+
1. **Java 运行时环境** (Office Tool)
|
|
65
|
+
- 用于 Apache Tika 文档解析
|
|
66
|
+
- 支持 OpenJDK 11+
|
|
67
|
+
|
|
68
|
+
2. **Tesseract OCR 引擎** (Image Tool, Office Tool)
|
|
69
|
+
- 图像文字识别
|
|
70
|
+
- 支持多语言包
|
|
71
|
+
|
|
72
|
+
3. **图像处理库** (Image Tool, Report Tool)
|
|
73
|
+
- libjpeg, libpng, libtiff 等
|
|
74
|
+
- Pillow 系统依赖
|
|
75
|
+
|
|
76
|
+
4. **统计文件格式库** (Stats Tool)
|
|
77
|
+
- libreadstat (SAS/SPSS/Stata 文件)
|
|
78
|
+
- Excel 处理库
|
|
79
|
+
|
|
80
|
+
5. **PDF 生成库** (Report Tool)
|
|
81
|
+
- WeasyPrint 系统依赖
|
|
82
|
+
- cairo, pango, gdk-pixbuf 等
|
|
83
|
+
|
|
84
|
+
6. **浏览器自动化库** (Scraper Tool)
|
|
85
|
+
- Playwright 浏览器二进制文件
|
|
86
|
+
- 系统图形库
|
|
87
|
+
|
|
88
|
+
### Python 包依赖
|
|
89
|
+
|
|
90
|
+
- **核心框架**: FastAPI, uvicorn, pydantic, httpx
|
|
91
|
+
- **任务队列**: celery, redis
|
|
92
|
+
- **数据处理**: pandas, numpy, scipy, scikit-learn
|
|
93
|
+
- **文档处理**: python-docx, python-pptx, openpyxl, pdfplumber
|
|
94
|
+
- **NLP 处理**: spacy, transformers, nltk
|
|
95
|
+
- **图像处理**: pillow, pytesseract
|
|
96
|
+
- **网页抓取**: playwright, scrapy, beautifulsoup4
|
|
97
|
+
- **报告生成**: jinja2, matplotlib, weasyprint
|
|
98
|
+
|
|
99
|
+
### 模型文件依赖
|
|
100
|
+
|
|
101
|
+
1. **spaCy 模型**
|
|
102
|
+
- en_core_web_sm (英文)
|
|
103
|
+
- zh_core_web_sm (中文)
|
|
104
|
+
|
|
105
|
+
2. **Transformers 模型**
|
|
106
|
+
- facebook/bart-large-cnn (英文摘要)
|
|
107
|
+
- t5-base (多语言摘要)
|
|
108
|
+
|
|
109
|
+
3. **NLTK 数据包**
|
|
110
|
+
- stopwords, punkt, wordnet, averaged_perceptron_tagger
|
|
111
|
+
|
|
112
|
+
4. **Playwright 浏览器**
|
|
113
|
+
- Chromium, Firefox, WebKit
|
|
114
|
+
|
|
115
|
+
## 安装后自动检查流程
|
|
116
|
+
|
|
117
|
+
当用户运行 `pip install aiecs` 时:
|
|
118
|
+
|
|
119
|
+
1. **Weasel 库补丁应用**
|
|
120
|
+
- 修复 weasel 库的验证问题
|
|
121
|
+
- 确保 spaCy 配置正常工作
|
|
122
|
+
|
|
123
|
+
2. **NLP 数据下载**
|
|
124
|
+
- 下载 NLTK 数据包
|
|
125
|
+
- 下载 spaCy 模型
|
|
126
|
+
|
|
127
|
+
3. **系统依赖检查**
|
|
128
|
+
- 运行快速依赖检查
|
|
129
|
+
- 显示缺失的依赖项
|
|
130
|
+
- 提供安装指导
|
|
131
|
+
|
|
132
|
+
4. **安装总结**
|
|
133
|
+
- 显示所有步骤的状态
|
|
134
|
+
- 提供后续操作建议
|
|
135
|
+
|
|
136
|
+
## 使用方法
|
|
137
|
+
|
|
138
|
+
### 安装后验证
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# 快速检查
|
|
142
|
+
aiecs-quick-check
|
|
143
|
+
|
|
144
|
+
# 完整检查
|
|
145
|
+
aiecs-check-deps
|
|
146
|
+
|
|
147
|
+
# 自动修复
|
|
148
|
+
aiecs-fix-deps
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 开发环境设置
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# 检查所有依赖
|
|
155
|
+
aiecs-check-deps
|
|
156
|
+
|
|
157
|
+
# 自动修复缺失依赖
|
|
158
|
+
aiecs-fix-deps --non-interactive
|
|
159
|
+
|
|
160
|
+
# 仅检查不修复
|
|
161
|
+
aiecs-fix-deps --check-only
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## 故障排除
|
|
165
|
+
|
|
166
|
+
### 常见问题解决
|
|
167
|
+
|
|
168
|
+
1. **Java 未安装**
|
|
169
|
+
```bash
|
|
170
|
+
# Ubuntu/Debian
|
|
171
|
+
sudo apt-get install openjdk-11-jdk
|
|
172
|
+
|
|
173
|
+
# macOS
|
|
174
|
+
brew install openjdk@11
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
2. **Tesseract OCR 未安装**
|
|
178
|
+
```bash
|
|
179
|
+
# Ubuntu/Debian
|
|
180
|
+
sudo apt-get install tesseract-ocr tesseract-ocr-eng
|
|
181
|
+
|
|
182
|
+
# macOS
|
|
183
|
+
brew install tesseract
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
3. **spaCy 模型未下载**
|
|
187
|
+
```bash
|
|
188
|
+
python -m spacy download en_core_web_sm
|
|
189
|
+
python -m spacy download zh_core_web_sm
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
4. **Playwright 浏览器未安装**
|
|
193
|
+
```bash
|
|
194
|
+
playwright install
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## 扩展性
|
|
198
|
+
|
|
199
|
+
### 添加新工具依赖检查
|
|
200
|
+
|
|
201
|
+
1. 在 `DependencyChecker` 类中添加新的检查方法
|
|
202
|
+
2. 在 `check_all_dependencies()` 中注册新工具
|
|
203
|
+
3. 更新安装命令映射
|
|
204
|
+
|
|
205
|
+
### 自定义检查逻辑
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
from aiecs.scripts.dependency_checker import DependencyChecker
|
|
209
|
+
|
|
210
|
+
checker = DependencyChecker()
|
|
211
|
+
tools = checker.check_all_dependencies()
|
|
212
|
+
report = checker.generate_report(tools)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## 文件结构
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
aiecs/scripts/
|
|
219
|
+
├── dependency_checker.py # 完整依赖检查
|
|
220
|
+
├── quick_dependency_check.py # 快速依赖检查
|
|
221
|
+
├── dependency_fixer.py # 自动依赖修复
|
|
222
|
+
├── test_dependency_checker.py # 测试脚本
|
|
223
|
+
├── README_DEPENDENCY_CHECKER.md # 使用说明
|
|
224
|
+
└── DEPENDENCY_SYSTEM_SUMMARY.md # 系统总结
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## 总结
|
|
228
|
+
|
|
229
|
+
这个依赖检查系统解决了 AIECS 包作为项目依赖时的关键问题:
|
|
230
|
+
|
|
231
|
+
1. **自动检查**: 安装后自动验证所有依赖
|
|
232
|
+
2. **详细报告**: 清楚显示缺失的依赖和影响
|
|
233
|
+
3. **自动修复**: 提供一键修复功能
|
|
234
|
+
4. **跨平台支持**: 支持主流操作系统
|
|
235
|
+
5. **易于扩展**: 可以轻松添加新工具的依赖检查
|
|
236
|
+
|
|
237
|
+
通过这个系统,用户可以在安装 AIECS 后立即了解哪些功能可用,哪些需要额外安装依赖,以及如何获得这些依赖。这大大提高了用户体验和包的可用性。
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# AIECS Dependency Checker
|
|
2
|
+
|
|
3
|
+
AIECS 包含一个全面的依赖检查系统,用于验证所有工具所需的系统级依赖、Python包和模型文件。
|
|
4
|
+
|
|
5
|
+
## 概述
|
|
6
|
+
|
|
7
|
+
AIECS 的各个工具需要不同的依赖项才能正常工作:
|
|
8
|
+
|
|
9
|
+
- **系统级依赖**: Java、Tesseract OCR、图像处理库等
|
|
10
|
+
- **Python包依赖**: 各种Python库和框架
|
|
11
|
+
- **模型文件**: spaCy模型、NLTK数据、Transformers模型等
|
|
12
|
+
|
|
13
|
+
## 命令行工具
|
|
14
|
+
|
|
15
|
+
### 1. 快速依赖检查
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
aiecs-quick-check
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
快速检查关键依赖项,适合安装后验证。
|
|
22
|
+
|
|
23
|
+
### 2. 完整依赖检查
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
aiecs-check-deps
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
执行完整的依赖检查,包括所有工具的所有依赖项。
|
|
30
|
+
|
|
31
|
+
### 3. 自动依赖修复
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
aiecs-fix-deps
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
自动安装缺失的依赖项(需要用户确认)。
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
aiecs-fix-deps --non-interactive
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
非交互模式,自动批准所有修复。
|
|
44
|
+
|
|
45
|
+
### 4. 仅检查模式
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
aiecs-fix-deps --check-only
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
只检查依赖项,不执行修复。
|
|
52
|
+
|
|
53
|
+
## 工具特定依赖
|
|
54
|
+
|
|
55
|
+
### Image Tool (图像处理工具)
|
|
56
|
+
|
|
57
|
+
**系统依赖**:
|
|
58
|
+
- Tesseract OCR 引擎
|
|
59
|
+
- Pillow 图像处理库的系统依赖
|
|
60
|
+
|
|
61
|
+
**Python包**:
|
|
62
|
+
- PIL (Pillow)
|
|
63
|
+
- pytesseract
|
|
64
|
+
|
|
65
|
+
**模型文件**:
|
|
66
|
+
- Tesseract 语言包 (eng, chi_sim, chi_tra, 等)
|
|
67
|
+
|
|
68
|
+
**安装命令**:
|
|
69
|
+
```bash
|
|
70
|
+
# Ubuntu/Debian
|
|
71
|
+
sudo apt-get install tesseract-ocr tesseract-ocr-eng
|
|
72
|
+
sudo apt-get install libjpeg-dev zlib1g-dev libpng-dev libtiff-dev libwebp-dev libopenjp2-7-dev
|
|
73
|
+
|
|
74
|
+
# macOS
|
|
75
|
+
brew install tesseract
|
|
76
|
+
brew install libjpeg zlib libpng libtiff webp openjpeg
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### ClassFire Tool (文本分类工具)
|
|
80
|
+
|
|
81
|
+
**Python包**:
|
|
82
|
+
- spacy
|
|
83
|
+
- transformers
|
|
84
|
+
- nltk
|
|
85
|
+
- rake_nltk
|
|
86
|
+
|
|
87
|
+
**模型文件**:
|
|
88
|
+
- spaCy 模型: en_core_web_sm, zh_core_web_sm
|
|
89
|
+
- Transformers 模型: facebook/bart-large-cnn, t5-base
|
|
90
|
+
- NLTK 数据: stopwords, punkt, wordnet, averaged_perceptron_tagger
|
|
91
|
+
|
|
92
|
+
**安装命令**:
|
|
93
|
+
```bash
|
|
94
|
+
# spaCy 模型
|
|
95
|
+
python -m spacy download en_core_web_sm
|
|
96
|
+
python -m spacy download zh_core_web_sm
|
|
97
|
+
|
|
98
|
+
# NLTK 数据
|
|
99
|
+
python -c "import nltk; nltk.download('stopwords')"
|
|
100
|
+
python -c "import nltk; nltk.download('punkt')"
|
|
101
|
+
python -c "import nltk; nltk.download('wordnet')"
|
|
102
|
+
python -c "import nltk; nltk.download('averaged_perceptron_tagger')"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Office Tool (办公文档处理工具)
|
|
106
|
+
|
|
107
|
+
**系统依赖**:
|
|
108
|
+
- Java 运行时环境 (OpenJDK 11+)
|
|
109
|
+
- Tesseract OCR (可选)
|
|
110
|
+
|
|
111
|
+
**Python包**:
|
|
112
|
+
- tika
|
|
113
|
+
- python-docx
|
|
114
|
+
- python-pptx
|
|
115
|
+
- openpyxl
|
|
116
|
+
- pdfplumber
|
|
117
|
+
- pytesseract
|
|
118
|
+
- PIL
|
|
119
|
+
|
|
120
|
+
**安装命令**:
|
|
121
|
+
```bash
|
|
122
|
+
# Ubuntu/Debian
|
|
123
|
+
sudo apt-get install openjdk-11-jdk
|
|
124
|
+
sudo apt-get install tesseract-ocr tesseract-ocr-eng
|
|
125
|
+
|
|
126
|
+
# macOS
|
|
127
|
+
brew install openjdk@11
|
|
128
|
+
brew install tesseract
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Stats Tool (统计分析工具)
|
|
132
|
+
|
|
133
|
+
**系统依赖**:
|
|
134
|
+
- libreadstat (用于SAS/SPSS/Stata文件)
|
|
135
|
+
- Excel处理库
|
|
136
|
+
|
|
137
|
+
**Python包**:
|
|
138
|
+
- pandas
|
|
139
|
+
- numpy
|
|
140
|
+
- scipy
|
|
141
|
+
- scikit-learn
|
|
142
|
+
- statsmodels
|
|
143
|
+
- pyreadstat
|
|
144
|
+
- openpyxl
|
|
145
|
+
|
|
146
|
+
**安装命令**:
|
|
147
|
+
```bash
|
|
148
|
+
# Ubuntu/Debian
|
|
149
|
+
sudo apt-get install libreadstat-dev
|
|
150
|
+
sudo apt-get install libxml2-dev libxslt1-dev
|
|
151
|
+
|
|
152
|
+
# macOS
|
|
153
|
+
brew install readstat
|
|
154
|
+
brew install libxml2 libxslt
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Report Tool (报告生成工具)
|
|
158
|
+
|
|
159
|
+
**系统依赖**:
|
|
160
|
+
- WeasyPrint 依赖 (PDF生成)
|
|
161
|
+
- Matplotlib 依赖 (图表生成)
|
|
162
|
+
|
|
163
|
+
**Python包**:
|
|
164
|
+
- jinja2
|
|
165
|
+
- matplotlib
|
|
166
|
+
- weasyprint
|
|
167
|
+
- bleach
|
|
168
|
+
- markdown
|
|
169
|
+
- pandas
|
|
170
|
+
- openpyxl
|
|
171
|
+
- python-docx
|
|
172
|
+
- python-pptx
|
|
173
|
+
|
|
174
|
+
**安装命令**:
|
|
175
|
+
```bash
|
|
176
|
+
# Ubuntu/Debian
|
|
177
|
+
sudo apt-get install libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libffi-dev shared-mime-info
|
|
178
|
+
sudo apt-get install libfreetype6-dev libpng-dev libjpeg-dev libtiff-dev libwebp-dev
|
|
179
|
+
|
|
180
|
+
# macOS
|
|
181
|
+
brew install cairo pango gdk-pixbuf libffi
|
|
182
|
+
brew install freetype libpng libjpeg libtiff webp
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Scraper Tool (网页抓取工具)
|
|
186
|
+
|
|
187
|
+
**系统依赖**:
|
|
188
|
+
- Playwright 浏览器二进制文件
|
|
189
|
+
- Playwright 系统依赖
|
|
190
|
+
|
|
191
|
+
**Python包**:
|
|
192
|
+
- playwright
|
|
193
|
+
- scrapy
|
|
194
|
+
- httpx
|
|
195
|
+
- beautifulsoup4
|
|
196
|
+
- lxml
|
|
197
|
+
|
|
198
|
+
**安装命令**:
|
|
199
|
+
```bash
|
|
200
|
+
# 安装 Playwright 浏览器
|
|
201
|
+
playwright install
|
|
202
|
+
|
|
203
|
+
# 安装系统依赖
|
|
204
|
+
playwright install-deps
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## 安装后自动检查
|
|
208
|
+
|
|
209
|
+
当您安装 AIECS 时,系统会自动运行依赖检查:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
pip install aiecs
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
安装过程中会显示:
|
|
216
|
+
1. Weasel 库补丁应用
|
|
217
|
+
2. NLP 数据下载
|
|
218
|
+
3. 系统依赖检查
|
|
219
|
+
|
|
220
|
+
## 故障排除
|
|
221
|
+
|
|
222
|
+
### 常见问题
|
|
223
|
+
|
|
224
|
+
1. **Java 未安装**
|
|
225
|
+
```bash
|
|
226
|
+
# 检查 Java 版本
|
|
227
|
+
java -version
|
|
228
|
+
|
|
229
|
+
# 安装 Java
|
|
230
|
+
sudo apt-get install openjdk-11-jdk # Ubuntu/Debian
|
|
231
|
+
brew install openjdk@11 # macOS
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
2. **Tesseract OCR 未安装**
|
|
235
|
+
```bash
|
|
236
|
+
# 检查 Tesseract
|
|
237
|
+
tesseract --version
|
|
238
|
+
|
|
239
|
+
# 安装 Tesseract
|
|
240
|
+
sudo apt-get install tesseract-ocr tesseract-ocr-eng # Ubuntu/Debian
|
|
241
|
+
brew install tesseract # macOS
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
3. **spaCy 模型未下载**
|
|
245
|
+
```bash
|
|
246
|
+
# 下载 spaCy 模型
|
|
247
|
+
python -m spacy download en_core_web_sm
|
|
248
|
+
python -m spacy download zh_core_web_sm
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
4. **Playwright 浏览器未安装**
|
|
252
|
+
```bash
|
|
253
|
+
# 安装 Playwright 浏览器
|
|
254
|
+
playwright install
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 手动修复
|
|
258
|
+
|
|
259
|
+
如果自动修复失败,您可以手动安装缺失的依赖:
|
|
260
|
+
|
|
261
|
+
1. 运行完整检查:
|
|
262
|
+
```bash
|
|
263
|
+
aiecs-check-deps
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
2. 根据报告中的安装命令手动安装
|
|
267
|
+
|
|
268
|
+
3. 重新运行检查验证
|
|
269
|
+
|
|
270
|
+
### 日志文件
|
|
271
|
+
|
|
272
|
+
依赖检查会生成以下日志文件:
|
|
273
|
+
- `dependency_check.log` - 详细检查日志
|
|
274
|
+
- `dependency_fix.log` - 修复过程日志
|
|
275
|
+
- `dependency_report.txt` - 检查报告
|
|
276
|
+
|
|
277
|
+
## 开发人员说明
|
|
278
|
+
|
|
279
|
+
### 添加新的依赖检查
|
|
280
|
+
|
|
281
|
+
1. 在 `dependency_checker.py` 中添加新的检查函数
|
|
282
|
+
2. 在相应的工具依赖检查函数中调用
|
|
283
|
+
3. 更新安装命令映射
|
|
284
|
+
|
|
285
|
+
### 自定义检查
|
|
286
|
+
|
|
287
|
+
您可以创建自定义的依赖检查脚本:
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
from aiecs.scripts.dependency_checker import DependencyChecker
|
|
291
|
+
|
|
292
|
+
checker = DependencyChecker()
|
|
293
|
+
tools = checker.check_all_dependencies()
|
|
294
|
+
report = checker.generate_report(tools)
|
|
295
|
+
print(report)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## 支持
|
|
299
|
+
|
|
300
|
+
如果您遇到依赖问题,请:
|
|
301
|
+
|
|
302
|
+
1. 运行 `aiecs-check-deps` 获取详细报告
|
|
303
|
+
2. 查看生成的日志文件
|
|
304
|
+
3. 尝试使用 `aiecs-fix-deps` 自动修复
|
|
305
|
+
4. 如果问题仍然存在,请提交 issue 到项目仓库
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Weasel Library Patch Scripts
|
|
2
|
+
|
|
3
|
+
这个目录包含用于修复weasel库重复验证器函数错误的脚本,该错误导致测试失败。
|
|
4
|
+
|
|
5
|
+
## 问题描述
|
|
6
|
+
|
|
7
|
+
错误发生是因为weasel库中有重复的验证器函数,但没有`allow_reuse=True`参数:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
pydantic.v1.errors.ConfigError: duplicate validator function "weasel.schemas.ProjectConfigSchema.check_legacy_keys"; if this is intended, set `allow_reuse=True`
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**注意**: 实际的问题是在 `@root_validator` 装饰器中,而不是 `@validator`。
|
|
14
|
+
|
|
15
|
+
## 可用脚本
|
|
16
|
+
|
|
17
|
+
### 1. `run_weasel_patch.sh` (推荐使用)
|
|
18
|
+
最简单的解决方案,通过poetry运行补丁:
|
|
19
|
+
- 自动检测poetry虚拟环境
|
|
20
|
+
- 在正确的环境中运行Python补丁脚本
|
|
21
|
+
- 提供清晰的反馈和说明
|
|
22
|
+
|
|
23
|
+
**使用方法:**
|
|
24
|
+
```bash
|
|
25
|
+
cd python-middleware
|
|
26
|
+
./scripts/run_weasel_patch.sh
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. `fix_weasel_validator.py`
|
|
30
|
+
基于Python的方法:
|
|
31
|
+
- 使用正则表达式模式识别和修复验证器装饰器
|
|
32
|
+
- 提供详细的前后对比
|
|
33
|
+
- 创建带时间戳的备份
|
|
34
|
+
|
|
35
|
+
**使用方法:**
|
|
36
|
+
```bash
|
|
37
|
+
cd python-middleware
|
|
38
|
+
poetry run python3 ./scripts/fix_weasel_validator.py
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. `fix_weasel_validator.sh`
|
|
42
|
+
基于bash的方法,使用sed进行文本替换:
|
|
43
|
+
- 简单的sed文本替换
|
|
44
|
+
- 创建备份
|
|
45
|
+
- 显示前后内容
|
|
46
|
+
|
|
47
|
+
**使用方法:**
|
|
48
|
+
```bash
|
|
49
|
+
cd python-middleware
|
|
50
|
+
./scripts/fix_weasel_validator.sh
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 4. `patch_weasel_library.sh`
|
|
54
|
+
综合解决方案:
|
|
55
|
+
- 结合多种方法
|
|
56
|
+
- 包含测试验证
|
|
57
|
+
- 详细的错误处理
|
|
58
|
+
|
|
59
|
+
**使用方法:**
|
|
60
|
+
```bash
|
|
61
|
+
cd python-middleware
|
|
62
|
+
./scripts/patch_weasel_library.sh
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 脚本功能
|
|
66
|
+
|
|
67
|
+
所有脚本都执行以下操作:
|
|
68
|
+
|
|
69
|
+
1. **定位虚拟环境**: 找到poetry虚拟环境路径
|
|
70
|
+
2. **找到问题文件**: 在site-packages中定位`weasel/schemas.py`
|
|
71
|
+
3. **创建备份**: 制作原始文件的带时间戳备份
|
|
72
|
+
4. **应用补丁**: 向需要的验证器装饰器添加`allow_reuse=True`
|
|
73
|
+
5. **验证修复**: 检查补丁是否正确应用
|
|
74
|
+
|
|
75
|
+
## 修复内容
|
|
76
|
+
|
|
77
|
+
脚本将以下代码:
|
|
78
|
+
```python
|
|
79
|
+
@root_validator(pre=True)
|
|
80
|
+
def check_legacy_keys(cls, obj: Dict[str, Any]) -> Dict[str, Any]:
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
修改为:
|
|
84
|
+
```python
|
|
85
|
+
@root_validator(pre=True, allow_reuse=True)
|
|
86
|
+
def check_legacy_keys(cls, obj: Dict[str, Any]) -> Dict[str, Any]:
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
脚本同时支持 `@validator` 和 `@root_validator` 装饰器的修复。
|
|
90
|
+
|
|
91
|
+
## 回滚
|
|
92
|
+
|
|
93
|
+
如果需要恢复更改,每个脚本都会创建备份文件。您可以使用以下命令恢复:
|
|
94
|
+
```bash
|
|
95
|
+
cp /path/to/backup/file /path/to/original/schemas.py
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
确切的路径将在脚本输出中显示。
|
|
99
|
+
|
|
100
|
+
## 故障排除
|
|
101
|
+
|
|
102
|
+
1. **找不到Poetry**: 确保已安装poetry并且您在项目目录中
|
|
103
|
+
2. **找不到虚拟环境**: 运行`poetry install`创建虚拟环境
|
|
104
|
+
3. **找不到文件**: weasel包可能未安装 - 检查您的依赖项
|
|
105
|
+
4. **权限错误**: 您可能需要使用适当的权限运行
|
|
106
|
+
|
|
107
|
+
## 运行补丁后
|
|
108
|
+
|
|
109
|
+
1. 再次尝试运行您的测试:`poetry run pytest`
|
|
110
|
+
2. 如果问题仍然存在,重启您的Python环境/IDE
|
|
111
|
+
3. 修复应该解决重复验证器函数错误
|
|
112
|
+
|
|
113
|
+
## 注意事项
|
|
114
|
+
|
|
115
|
+
- 这些脚本可以安全地多次运行
|
|
116
|
+
- 它们在进行更改之前检查补丁是否已应用
|
|
117
|
+
- 所有更改都会自动备份
|
|
118
|
+
- 脚本针对特定问题,不会影响其他功能
|
|
119
|
+
|
|
120
|
+
## 推荐使用流程
|
|
121
|
+
|
|
122
|
+
1. 首先尝试使用 `run_weasel_patch.sh`(最简单)
|
|
123
|
+
2. 如果遇到问题,可以尝试直接运行 `poetry run python3 scripts/fix_weasel_validator.py`
|
|
124
|
+
3. 作为最后手段,可以使用 `patch_weasel_library.sh`(最全面)
|
|
125
|
+
|
|
126
|
+
所有脚本都会在修改前创建备份,因此您可以安全地尝试不同的方法。
|