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,121 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Script to fix weasel library duplicate validator function error.
|
|
4
|
+
This script patches the weasel schemas.py file to add allow_reuse=True to duplicate validators.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import subprocess
|
|
10
|
+
import shutil
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
import re
|
|
13
|
+
|
|
14
|
+
def get_weasel_path():
|
|
15
|
+
"""Get the weasel package path in the current Python environment."""
|
|
16
|
+
try:
|
|
17
|
+
import weasel
|
|
18
|
+
import inspect
|
|
19
|
+
weasel_file = inspect.getfile(weasel)
|
|
20
|
+
weasel_dir = os.path.dirname(weasel_file)
|
|
21
|
+
return os.path.join(weasel_dir, 'schemas.py')
|
|
22
|
+
except ImportError:
|
|
23
|
+
print("ā Error: weasel package not found")
|
|
24
|
+
print("Please install aiecs with all dependencies")
|
|
25
|
+
return None
|
|
26
|
+
except Exception as e:
|
|
27
|
+
print(f"ā Error finding weasel package: {e}")
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
def backup_file(file_path):
|
|
31
|
+
"""Create a backup of the file."""
|
|
32
|
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
33
|
+
backup_path = f"{file_path}.backup.{timestamp}"
|
|
34
|
+
shutil.copy2(file_path, backup_path)
|
|
35
|
+
return backup_path
|
|
36
|
+
|
|
37
|
+
def fix_weasel_schemas(schemas_file_path):
|
|
38
|
+
"""Fix the weasel schemas.py file by adding allow_reuse=True to validators."""
|
|
39
|
+
|
|
40
|
+
print(f"š Processing file: {schemas_file_path}")
|
|
41
|
+
|
|
42
|
+
# Read the original file
|
|
43
|
+
with open(schemas_file_path, 'r', encoding='utf-8') as f:
|
|
44
|
+
content = f.read()
|
|
45
|
+
|
|
46
|
+
# Check if already patched
|
|
47
|
+
if 'allow_reuse=True' in content:
|
|
48
|
+
print("ā
File already patched with allow_reuse=True")
|
|
49
|
+
return True
|
|
50
|
+
|
|
51
|
+
# Create backup
|
|
52
|
+
backup_path = backup_file(schemas_file_path)
|
|
53
|
+
print(f"š¾ Created backup at: {backup_path}")
|
|
54
|
+
|
|
55
|
+
# Show current problematic area
|
|
56
|
+
lines = content.split('\n')
|
|
57
|
+
print("\nš Current content around line 89:")
|
|
58
|
+
for i, line in enumerate(lines[84:94], 85):
|
|
59
|
+
print(f"{i:3d} | {line}")
|
|
60
|
+
|
|
61
|
+
# Pattern to match both @validator and @root_validator decorators without allow_reuse
|
|
62
|
+
validator_pattern = r'(@(?:root_)?validator\([^)]*)\)(?!\s*,\s*allow_reuse=True)'
|
|
63
|
+
|
|
64
|
+
# Replace @validator(...) or @root_validator(...) with allow_reuse=True if not already present
|
|
65
|
+
def replace_validator(match):
|
|
66
|
+
validator_call = match.group(1)
|
|
67
|
+
# Check if allow_reuse is already in the parameters
|
|
68
|
+
if 'allow_reuse' in validator_call:
|
|
69
|
+
return match.group(0) # Return unchanged
|
|
70
|
+
else:
|
|
71
|
+
return f"{validator_call}, allow_reuse=True)"
|
|
72
|
+
|
|
73
|
+
# Apply the fix
|
|
74
|
+
fixed_content = re.sub(validator_pattern, replace_validator, content)
|
|
75
|
+
|
|
76
|
+
# Write the fixed content back
|
|
77
|
+
with open(schemas_file_path, 'w', encoding='utf-8') as f:
|
|
78
|
+
f.write(fixed_content)
|
|
79
|
+
|
|
80
|
+
# Show the fixed content
|
|
81
|
+
fixed_lines = fixed_content.split('\n')
|
|
82
|
+
print("\nš Patched content around line 89:")
|
|
83
|
+
for i, line in enumerate(fixed_lines[84:94], 85):
|
|
84
|
+
print(f"{i:3d} | {line}")
|
|
85
|
+
|
|
86
|
+
# Verify the fix
|
|
87
|
+
if 'allow_reuse=True' in fixed_content:
|
|
88
|
+
print("ā
Verification successful: allow_reuse=True found in file")
|
|
89
|
+
return True
|
|
90
|
+
else:
|
|
91
|
+
print("ā ļø Warning: allow_reuse=True not found after patching")
|
|
92
|
+
return False
|
|
93
|
+
|
|
94
|
+
def main():
|
|
95
|
+
"""Main function to execute the patch."""
|
|
96
|
+
print("š§ Starting weasel library patch for duplicate validator function...")
|
|
97
|
+
|
|
98
|
+
# Get weasel schemas.py path
|
|
99
|
+
schemas_file = get_weasel_path()
|
|
100
|
+
if not schemas_file:
|
|
101
|
+
sys.exit(1)
|
|
102
|
+
|
|
103
|
+
print(f"š Found weasel schemas.py at: {schemas_file}")
|
|
104
|
+
|
|
105
|
+
if not os.path.exists(schemas_file):
|
|
106
|
+
print(f"ā Error: weasel schemas.py file not found at {schemas_file}")
|
|
107
|
+
sys.exit(1)
|
|
108
|
+
|
|
109
|
+
# Apply the fix
|
|
110
|
+
success = fix_weasel_schemas(schemas_file)
|
|
111
|
+
|
|
112
|
+
if success:
|
|
113
|
+
print("\nš Weasel library patch completed successfully!")
|
|
114
|
+
print("\nYou can now run your tests again.")
|
|
115
|
+
print(f"\nIf you need to revert the changes, restore from the backup file.")
|
|
116
|
+
else:
|
|
117
|
+
print("\nā Patch may not have been applied correctly. Please check manually.")
|
|
118
|
+
sys.exit(1)
|
|
119
|
+
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
main()
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Script to fix weasel library duplicate validator function error
|
|
4
|
+
# This script patches the weasel schemas.py file to add allow_reuse=True
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
echo "š§ Starting weasel library patch for duplicate validator function..."
|
|
9
|
+
|
|
10
|
+
# Get the poetry virtual environment path
|
|
11
|
+
VENV_PATH=$(poetry env info --path 2>/dev/null || echo "")
|
|
12
|
+
|
|
13
|
+
if [ -z "$VENV_PATH" ]; then
|
|
14
|
+
echo "ā Error: Could not find poetry virtual environment"
|
|
15
|
+
echo "Please make sure you're in the project directory and poetry is installed"
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
echo "š Found virtual environment at: $VENV_PATH"
|
|
20
|
+
|
|
21
|
+
# Path to the problematic weasel schemas.py file
|
|
22
|
+
WEASEL_SCHEMAS_FILE="$VENV_PATH/lib/python3.10/site-packages/weasel/schemas.py"
|
|
23
|
+
|
|
24
|
+
if [ ! -f "$WEASEL_SCHEMAS_FILE" ]; then
|
|
25
|
+
echo "ā Error: weasel schemas.py file not found at $WEASEL_SCHEMAS_FILE"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
echo "š Found weasel schemas.py at: $WEASEL_SCHEMAS_FILE"
|
|
30
|
+
|
|
31
|
+
# Create backup of original file
|
|
32
|
+
BACKUP_FILE="${WEASEL_SCHEMAS_FILE}.backup.$(date +%Y%m%d_%H%M%S)"
|
|
33
|
+
cp "$WEASEL_SCHEMAS_FILE" "$BACKUP_FILE"
|
|
34
|
+
echo "š¾ Created backup at: $BACKUP_FILE"
|
|
35
|
+
|
|
36
|
+
# Check if the file already has allow_reuse=True
|
|
37
|
+
if grep -q "allow_reuse=True" "$WEASEL_SCHEMAS_FILE"; then
|
|
38
|
+
echo "ā
File already patched with allow_reuse=True"
|
|
39
|
+
exit 0
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
# Apply the patch using sed
|
|
43
|
+
# Look for @validator and @root_validator decorators and add allow_reuse=True if not present
|
|
44
|
+
echo "šØ Applying patch..."
|
|
45
|
+
|
|
46
|
+
# First, let's check the current content around the problematic line
|
|
47
|
+
echo "š Current content around line 89:"
|
|
48
|
+
sed -n '85,95p' "$WEASEL_SCHEMAS_FILE"
|
|
49
|
+
|
|
50
|
+
# Apply the patch - add allow_reuse=True to validator decorators that don't have it
|
|
51
|
+
sed -i.tmp '
|
|
52
|
+
/^[[:space:]]*@\(root_\)\?validator(/,/^[[:space:]]*def/ {
|
|
53
|
+
/^[[:space:]]*@\(root_\)\?validator(/ {
|
|
54
|
+
# If the line contains @validator or @root_validator but not allow_reuse, add it
|
|
55
|
+
/allow_reuse/! {
|
|
56
|
+
s/@\(root_\)\?validator(\([^)]*\))/@\1validator(\2, allow_reuse=True)/
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
' "$WEASEL_SCHEMAS_FILE"
|
|
61
|
+
|
|
62
|
+
# Remove the temporary file
|
|
63
|
+
rm -f "${WEASEL_SCHEMAS_FILE}.tmp"
|
|
64
|
+
|
|
65
|
+
echo "ā
Patch applied successfully!"
|
|
66
|
+
|
|
67
|
+
# Show the patched content
|
|
68
|
+
echo "š Patched content around line 89:"
|
|
69
|
+
sed -n '85,95p' "$WEASEL_SCHEMAS_FILE"
|
|
70
|
+
|
|
71
|
+
# Verify the patch by checking if allow_reuse=True is now present
|
|
72
|
+
if grep -q "allow_reuse=True" "$WEASEL_SCHEMAS_FILE"; then
|
|
73
|
+
echo "ā
Verification successful: allow_reuse=True found in file"
|
|
74
|
+
else
|
|
75
|
+
echo "ā ļø Warning: allow_reuse=True not found after patching"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
echo "š Weasel library patch completed!"
|
|
79
|
+
echo "š Backup saved at: $BACKUP_FILE"
|
|
80
|
+
echo ""
|
|
81
|
+
echo "You can now run your tests again. If you need to revert the changes:"
|
|
82
|
+
echo "cp '$BACKUP_FILE' '$WEASEL_SCHEMAS_FILE'"
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Comprehensive script to fix weasel library duplicate validator function error
|
|
4
|
+
# This script provides multiple approaches to patch the issue
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
9
|
+
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
10
|
+
|
|
11
|
+
echo "š§ Weasel Library Patcher"
|
|
12
|
+
echo "========================="
|
|
13
|
+
echo "Project directory: $PROJECT_DIR"
|
|
14
|
+
echo ""
|
|
15
|
+
|
|
16
|
+
# Function to check if we're in the right directory
|
|
17
|
+
check_project_structure() {
|
|
18
|
+
if [ ! -f "$PROJECT_DIR/pyproject.toml" ]; then
|
|
19
|
+
echo "ā Error: pyproject.toml not found. Please run this script from the python-middleware directory"
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Function to get poetry virtual environment path
|
|
25
|
+
get_venv_path() {
|
|
26
|
+
cd "$PROJECT_DIR"
|
|
27
|
+
local venv_path
|
|
28
|
+
venv_path=$(poetry env info --path 2>/dev/null || echo "")
|
|
29
|
+
|
|
30
|
+
if [ -z "$venv_path" ]; then
|
|
31
|
+
echo "ā Error: Could not find poetry virtual environment"
|
|
32
|
+
echo "Please make sure poetry is installed and the virtual environment is created"
|
|
33
|
+
echo "Try running: poetry install"
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
echo "$venv_path"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Function to apply the patch
|
|
41
|
+
apply_patch() {
|
|
42
|
+
local venv_path="$1"
|
|
43
|
+
local schemas_file="$venv_path/lib/python3.10/site-packages/weasel/schemas.py"
|
|
44
|
+
|
|
45
|
+
echo "š Target file: $schemas_file"
|
|
46
|
+
|
|
47
|
+
if [ ! -f "$schemas_file" ]; then
|
|
48
|
+
echo "ā Error: weasel schemas.py file not found"
|
|
49
|
+
echo "The weasel package might not be installed or in a different location"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Create backup
|
|
54
|
+
local backup_file="${schemas_file}.backup.$(date +%Y%m%d_%H%M%S)"
|
|
55
|
+
cp "$schemas_file" "$backup_file"
|
|
56
|
+
echo "š¾ Backup created: $backup_file"
|
|
57
|
+
|
|
58
|
+
# Check if already patched
|
|
59
|
+
if grep -q "allow_reuse=True" "$schemas_file"; then
|
|
60
|
+
echo "ā
File already contains allow_reuse=True - may already be patched"
|
|
61
|
+
echo "Checking if the specific issue is resolved..."
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Show current problematic content
|
|
65
|
+
echo ""
|
|
66
|
+
echo "š Current content around the problematic area:"
|
|
67
|
+
echo "------------------------------------------------"
|
|
68
|
+
sed -n '85,95p' "$schemas_file" | nl -ba -v85
|
|
69
|
+
echo "------------------------------------------------"
|
|
70
|
+
echo ""
|
|
71
|
+
|
|
72
|
+
# Apply the patch using Python for more precise control
|
|
73
|
+
python3 << EOF
|
|
74
|
+
import re
|
|
75
|
+
import sys
|
|
76
|
+
|
|
77
|
+
schemas_file = "$schemas_file"
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
with open(schemas_file, 'r') as f:
|
|
81
|
+
content = f.read()
|
|
82
|
+
|
|
83
|
+
# Pattern to find @validator and @root_validator decorators that need allow_reuse=True
|
|
84
|
+
# Look for the specific problematic validator
|
|
85
|
+
pattern = r'(@(?:root_)?validator\([^)]*\))\s*\n(\s*def\s+check_legacy_keys)'
|
|
86
|
+
|
|
87
|
+
def fix_validator(match):
|
|
88
|
+
decorator = match.group(1)
|
|
89
|
+
func_def = match.group(2)
|
|
90
|
+
|
|
91
|
+
# Add allow_reuse=True if not present
|
|
92
|
+
if 'allow_reuse' not in decorator:
|
|
93
|
+
# Remove the closing parenthesis and add allow_reuse=True
|
|
94
|
+
fixed_decorator = decorator[:-1] + ', allow_reuse=True)'
|
|
95
|
+
return fixed_decorator + '\n' + func_def
|
|
96
|
+
return match.group(0)
|
|
97
|
+
|
|
98
|
+
# Apply the fix
|
|
99
|
+
fixed_content = re.sub(pattern, fix_validator, content)
|
|
100
|
+
|
|
101
|
+
# Also fix any other @validator or @root_validator decorators that might have the same issue
|
|
102
|
+
general_pattern = r'(@(?:root_)?validator\([^)]*)\)(?=\s*\n\s*def)'
|
|
103
|
+
|
|
104
|
+
def fix_general_validator(match):
|
|
105
|
+
decorator = match.group(1)
|
|
106
|
+
if 'allow_reuse' not in decorator:
|
|
107
|
+
return decorator + ', allow_reuse=True)'
|
|
108
|
+
return match.group(0)
|
|
109
|
+
|
|
110
|
+
fixed_content = re.sub(general_pattern, fix_general_validator, fixed_content)
|
|
111
|
+
|
|
112
|
+
# Write back the fixed content
|
|
113
|
+
with open(schemas_file, 'w') as f:
|
|
114
|
+
f.write(fixed_content)
|
|
115
|
+
|
|
116
|
+
print("ā
Patch applied successfully")
|
|
117
|
+
|
|
118
|
+
except Exception as e:
|
|
119
|
+
print(f"ā Error applying patch: {e}")
|
|
120
|
+
sys.exit(1)
|
|
121
|
+
EOF
|
|
122
|
+
|
|
123
|
+
# Show the patched content
|
|
124
|
+
echo ""
|
|
125
|
+
echo "š Patched content:"
|
|
126
|
+
echo "-------------------"
|
|
127
|
+
sed -n '85,95p' "$schemas_file" | nl -ba -v85
|
|
128
|
+
echo "-------------------"
|
|
129
|
+
echo ""
|
|
130
|
+
|
|
131
|
+
# Verify the patch
|
|
132
|
+
if grep -q "allow_reuse=True" "$schemas_file"; then
|
|
133
|
+
echo "ā
Verification: allow_reuse=True found in the file"
|
|
134
|
+
else
|
|
135
|
+
echo "ā ļø Warning: allow_reuse=True not found after patching"
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
echo "š¾ Original file backed up to: $backup_file"
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# Function to test the fix
|
|
142
|
+
test_fix() {
|
|
143
|
+
echo ""
|
|
144
|
+
echo "š§Ŗ Testing the fix..."
|
|
145
|
+
cd "$PROJECT_DIR"
|
|
146
|
+
|
|
147
|
+
# Try to import the problematic module
|
|
148
|
+
if python3 -c "
|
|
149
|
+
import sys
|
|
150
|
+
sys.path.insert(0, '.')
|
|
151
|
+
try:
|
|
152
|
+
from app.tools.task_tools.research_tool import *
|
|
153
|
+
print('ā
Import successful - fix appears to work!')
|
|
154
|
+
except Exception as e:
|
|
155
|
+
print(f'ā Import still fails: {e}')
|
|
156
|
+
sys.exit(1)
|
|
157
|
+
" 2>/dev/null; then
|
|
158
|
+
echo "ā
Fix verification successful!"
|
|
159
|
+
else
|
|
160
|
+
echo "ā ļø Fix verification failed - you may need to restart your Python environment"
|
|
161
|
+
fi
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
# Main execution
|
|
165
|
+
main() {
|
|
166
|
+
echo "Starting patch process..."
|
|
167
|
+
|
|
168
|
+
check_project_structure
|
|
169
|
+
|
|
170
|
+
local venv_path
|
|
171
|
+
venv_path=$(get_venv_path)
|
|
172
|
+
echo "š Virtual environment: $venv_path"
|
|
173
|
+
|
|
174
|
+
apply_patch "$venv_path"
|
|
175
|
+
|
|
176
|
+
test_fix
|
|
177
|
+
|
|
178
|
+
echo ""
|
|
179
|
+
echo "š Weasel library patch completed!"
|
|
180
|
+
echo ""
|
|
181
|
+
echo "Next steps:"
|
|
182
|
+
echo "1. Try running your tests again"
|
|
183
|
+
echo "2. If the issue persists, you may need to restart your Python environment"
|
|
184
|
+
echo "3. To revert changes, restore from the backup file shown above"
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
# Run the main function
|
|
188
|
+
main "$@"
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Quick dependency checker for AIECS post-installation.
|
|
4
|
+
|
|
5
|
+
This script performs a fast check of critical dependencies and provides
|
|
6
|
+
installation guidance for missing components.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
import subprocess
|
|
12
|
+
import platform
|
|
13
|
+
import logging
|
|
14
|
+
from typing import Dict, List, Tuple, Optional
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class QuickDependencyChecker:
|
|
18
|
+
"""Quick dependency checker for post-installation."""
|
|
19
|
+
|
|
20
|
+
def __init__(self):
|
|
21
|
+
self.logger = self._setup_logging()
|
|
22
|
+
self.system = platform.system().lower()
|
|
23
|
+
self.issues = []
|
|
24
|
+
self.critical_issues = []
|
|
25
|
+
|
|
26
|
+
def _setup_logging(self) -> logging.Logger:
|
|
27
|
+
"""Setup logging configuration."""
|
|
28
|
+
logging.basicConfig(
|
|
29
|
+
level=logging.INFO,
|
|
30
|
+
format='%(levelname)s: %(message)s'
|
|
31
|
+
)
|
|
32
|
+
return logging.getLogger(__name__)
|
|
33
|
+
|
|
34
|
+
def check_command(self, command: str, version_flag: str = "--version") -> bool:
|
|
35
|
+
"""Check if a system command is available."""
|
|
36
|
+
try:
|
|
37
|
+
result = subprocess.run(
|
|
38
|
+
[command, version_flag],
|
|
39
|
+
capture_output=True,
|
|
40
|
+
text=True,
|
|
41
|
+
timeout=5
|
|
42
|
+
)
|
|
43
|
+
return result.returncode == 0
|
|
44
|
+
except (subprocess.TimeoutExpired, FileNotFoundError, subprocess.CalledProcessError):
|
|
45
|
+
return False
|
|
46
|
+
|
|
47
|
+
def check_python_package(self, package_name: str) -> bool:
|
|
48
|
+
"""Check if a Python package is installed."""
|
|
49
|
+
try:
|
|
50
|
+
__import__(package_name)
|
|
51
|
+
return True
|
|
52
|
+
except ImportError:
|
|
53
|
+
return False
|
|
54
|
+
|
|
55
|
+
def check_critical_dependencies(self) -> Dict[str, bool]:
|
|
56
|
+
"""Check critical dependencies that affect core functionality."""
|
|
57
|
+
results = {}
|
|
58
|
+
|
|
59
|
+
# Core Python packages
|
|
60
|
+
core_packages = [
|
|
61
|
+
"fastapi", "uvicorn", "pydantic", "httpx", "celery", "redis",
|
|
62
|
+
"pandas", "numpy", "scipy", "scikit-learn", "matplotlib"
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
for pkg in core_packages:
|
|
66
|
+
results[f"python_{pkg}"] = self.check_python_package(pkg)
|
|
67
|
+
if not results[f"python_{pkg}"]:
|
|
68
|
+
self.critical_issues.append(f"Missing Python package: {pkg}")
|
|
69
|
+
|
|
70
|
+
# System dependencies for tools
|
|
71
|
+
system_deps = {
|
|
72
|
+
"java": ("Java Runtime Environment", "java", "-version"),
|
|
73
|
+
"tesseract": ("Tesseract OCR", "tesseract", "--version"),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
for key, (name, cmd, flag) in system_deps.items():
|
|
77
|
+
results[f"system_{key}"] = self.check_command(cmd, flag)
|
|
78
|
+
if not results[f"system_{key}"]:
|
|
79
|
+
self.issues.append(f"Missing system dependency: {name}")
|
|
80
|
+
|
|
81
|
+
return results
|
|
82
|
+
|
|
83
|
+
def check_tool_specific_dependencies(self) -> Dict[str, Dict[str, bool]]:
|
|
84
|
+
"""Check dependencies for specific tools."""
|
|
85
|
+
tool_results = {}
|
|
86
|
+
|
|
87
|
+
# Image Tool dependencies
|
|
88
|
+
image_deps = {
|
|
89
|
+
"tesseract": self.check_command("tesseract"),
|
|
90
|
+
"PIL": self.check_python_package("PIL"),
|
|
91
|
+
"pytesseract": self.check_python_package("pytesseract"),
|
|
92
|
+
}
|
|
93
|
+
tool_results["image"] = image_deps
|
|
94
|
+
|
|
95
|
+
# ClassFire Tool dependencies
|
|
96
|
+
classfire_deps = {
|
|
97
|
+
"spacy": self.check_python_package("spacy"),
|
|
98
|
+
"nltk": self.check_python_package("nltk"),
|
|
99
|
+
"transformers": self.check_python_package("transformers"),
|
|
100
|
+
}
|
|
101
|
+
tool_results["classfire"] = classfire_deps
|
|
102
|
+
|
|
103
|
+
# Office Tool dependencies
|
|
104
|
+
office_deps = {
|
|
105
|
+
"java": self.check_command("java"),
|
|
106
|
+
"tika": self.check_python_package("tika"),
|
|
107
|
+
"python-docx": self.check_python_package("python-docx"),
|
|
108
|
+
"openpyxl": self.check_python_package("openpyxl"),
|
|
109
|
+
}
|
|
110
|
+
tool_results["office"] = office_deps
|
|
111
|
+
|
|
112
|
+
# Stats Tool dependencies
|
|
113
|
+
stats_deps = {
|
|
114
|
+
"pandas": self.check_python_package("pandas"),
|
|
115
|
+
"pyreadstat": self.check_python_package("pyreadstat"),
|
|
116
|
+
"statsmodels": self.check_python_package("statsmodels"),
|
|
117
|
+
}
|
|
118
|
+
tool_results["stats"] = stats_deps
|
|
119
|
+
|
|
120
|
+
# Report Tool dependencies
|
|
121
|
+
report_deps = {
|
|
122
|
+
"jinja2": self.check_python_package("jinja2"),
|
|
123
|
+
"matplotlib": self.check_python_package("matplotlib"),
|
|
124
|
+
"weasyprint": self.check_python_package("weasyprint"),
|
|
125
|
+
}
|
|
126
|
+
tool_results["report"] = report_deps
|
|
127
|
+
|
|
128
|
+
# Scraper Tool dependencies
|
|
129
|
+
scraper_deps = {
|
|
130
|
+
"playwright": self.check_python_package("playwright"),
|
|
131
|
+
"beautifulsoup4": self.check_python_package("beautifulsoup4"),
|
|
132
|
+
"scrapy": self.check_python_package("scrapy"),
|
|
133
|
+
}
|
|
134
|
+
tool_results["scraper"] = scraper_deps
|
|
135
|
+
|
|
136
|
+
return tool_results
|
|
137
|
+
|
|
138
|
+
def get_installation_commands(self) -> Dict[str, List[str]]:
|
|
139
|
+
"""Get installation commands for missing dependencies."""
|
|
140
|
+
commands = {
|
|
141
|
+
"system": [],
|
|
142
|
+
"python": [],
|
|
143
|
+
"models": []
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# System dependencies
|
|
147
|
+
if self.system == "linux":
|
|
148
|
+
if not self.check_command("java"):
|
|
149
|
+
commands["system"].append("sudo apt-get install openjdk-11-jdk")
|
|
150
|
+
if not self.check_command("tesseract"):
|
|
151
|
+
commands["system"].append("sudo apt-get install tesseract-ocr tesseract-ocr-eng")
|
|
152
|
+
elif self.system == "darwin":
|
|
153
|
+
if not self.check_command("java"):
|
|
154
|
+
commands["system"].append("brew install openjdk@11")
|
|
155
|
+
if not self.check_command("tesseract"):
|
|
156
|
+
commands["system"].append("brew install tesseract")
|
|
157
|
+
|
|
158
|
+
# Python packages (these should already be installed via pip)
|
|
159
|
+
missing_packages = []
|
|
160
|
+
for issue in self.critical_issues:
|
|
161
|
+
if "Missing Python package:" in issue:
|
|
162
|
+
pkg = issue.split(": ")[1]
|
|
163
|
+
missing_packages.append(pkg)
|
|
164
|
+
|
|
165
|
+
if missing_packages:
|
|
166
|
+
commands["python"].append(f"pip install {' '.join(missing_packages)}")
|
|
167
|
+
|
|
168
|
+
# Models and data
|
|
169
|
+
commands["models"].append("python -m aiecs.scripts.download_nlp_data")
|
|
170
|
+
commands["models"].append("playwright install")
|
|
171
|
+
|
|
172
|
+
return commands
|
|
173
|
+
|
|
174
|
+
def generate_quick_report(self) -> str:
|
|
175
|
+
"""Generate a quick dependency report."""
|
|
176
|
+
report = []
|
|
177
|
+
report.append("š AIECS Quick Dependency Check")
|
|
178
|
+
report.append("=" * 50)
|
|
179
|
+
|
|
180
|
+
# Check critical dependencies
|
|
181
|
+
critical_results = self.check_critical_dependencies()
|
|
182
|
+
tool_results = self.check_tool_specific_dependencies()
|
|
183
|
+
|
|
184
|
+
# Critical dependencies status
|
|
185
|
+
report.append("\nš¦ Critical Dependencies:")
|
|
186
|
+
critical_ok = all(critical_results.values())
|
|
187
|
+
if critical_ok:
|
|
188
|
+
report.append("ā
All critical dependencies are available")
|
|
189
|
+
else:
|
|
190
|
+
report.append("ā Some critical dependencies are missing")
|
|
191
|
+
for key, available in critical_results.items():
|
|
192
|
+
if not available:
|
|
193
|
+
dep_name = key.replace("python_", "").replace("system_", "")
|
|
194
|
+
report.append(f" ā {dep_name}")
|
|
195
|
+
|
|
196
|
+
# Tool-specific dependencies
|
|
197
|
+
report.append("\nš§ Tool-Specific Dependencies:")
|
|
198
|
+
for tool, deps in tool_results.items():
|
|
199
|
+
tool_ok = all(deps.values())
|
|
200
|
+
status = "ā
" if tool_ok else "ā ļø"
|
|
201
|
+
report.append(f" {status} {tool.title()} Tool")
|
|
202
|
+
|
|
203
|
+
if not tool_ok:
|
|
204
|
+
for dep, available in deps.items():
|
|
205
|
+
if not available:
|
|
206
|
+
report.append(f" ā {dep}")
|
|
207
|
+
|
|
208
|
+
# Installation commands
|
|
209
|
+
commands = self.get_installation_commands()
|
|
210
|
+
if any(commands.values()):
|
|
211
|
+
report.append("\nš ļø Installation Commands:")
|
|
212
|
+
|
|
213
|
+
if commands["system"]:
|
|
214
|
+
report.append(" System Dependencies:")
|
|
215
|
+
for cmd in commands["system"]:
|
|
216
|
+
report.append(f" {cmd}")
|
|
217
|
+
|
|
218
|
+
if commands["python"]:
|
|
219
|
+
report.append(" Python Packages:")
|
|
220
|
+
for cmd in commands["python"]:
|
|
221
|
+
report.append(f" {cmd}")
|
|
222
|
+
|
|
223
|
+
if commands["models"]:
|
|
224
|
+
report.append(" Models and Data:")
|
|
225
|
+
for cmd in commands["models"]:
|
|
226
|
+
report.append(f" {cmd}")
|
|
227
|
+
|
|
228
|
+
# Summary
|
|
229
|
+
total_issues = len(self.issues) + len(self.critical_issues)
|
|
230
|
+
if total_issues == 0:
|
|
231
|
+
report.append("\nš All dependencies are available!")
|
|
232
|
+
report.append("AIECS is ready to use with full functionality.")
|
|
233
|
+
else:
|
|
234
|
+
report.append(f"\nā ļø Found {total_issues} dependency issues.")
|
|
235
|
+
if self.critical_issues:
|
|
236
|
+
report.append(f" Critical: {len(self.critical_issues)}")
|
|
237
|
+
if self.issues:
|
|
238
|
+
report.append(f" Optional: {len(self.issues)}")
|
|
239
|
+
report.append("Please install missing dependencies for full functionality.")
|
|
240
|
+
|
|
241
|
+
return "\n".join(report)
|
|
242
|
+
|
|
243
|
+
def run_check(self) -> int:
|
|
244
|
+
"""Run the quick dependency check."""
|
|
245
|
+
print("š Running quick dependency check...")
|
|
246
|
+
|
|
247
|
+
# Generate and display report
|
|
248
|
+
report = self.generate_quick_report()
|
|
249
|
+
print(report)
|
|
250
|
+
|
|
251
|
+
# Return exit code
|
|
252
|
+
if self.critical_issues:
|
|
253
|
+
return 1
|
|
254
|
+
else:
|
|
255
|
+
return 0
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def main():
|
|
259
|
+
"""Main function."""
|
|
260
|
+
checker = QuickDependencyChecker()
|
|
261
|
+
return checker.run_check()
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
if __name__ == "__main__":
|
|
265
|
+
sys.exit(main())
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|