aiecs 1.5.1__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.
- aiecs/__init__.py +72 -0
- aiecs/__main__.py +41 -0
- aiecs/aiecs_client.py +469 -0
- aiecs/application/__init__.py +10 -0
- aiecs/application/executors/__init__.py +10 -0
- aiecs/application/executors/operation_executor.py +363 -0
- aiecs/application/knowledge_graph/__init__.py +7 -0
- aiecs/application/knowledge_graph/builder/__init__.py +37 -0
- aiecs/application/knowledge_graph/builder/document_builder.py +375 -0
- aiecs/application/knowledge_graph/builder/graph_builder.py +356 -0
- aiecs/application/knowledge_graph/builder/schema_mapping.py +531 -0
- aiecs/application/knowledge_graph/builder/structured_pipeline.py +443 -0
- aiecs/application/knowledge_graph/builder/text_chunker.py +319 -0
- aiecs/application/knowledge_graph/extractors/__init__.py +27 -0
- aiecs/application/knowledge_graph/extractors/base.py +100 -0
- aiecs/application/knowledge_graph/extractors/llm_entity_extractor.py +327 -0
- aiecs/application/knowledge_graph/extractors/llm_relation_extractor.py +349 -0
- aiecs/application/knowledge_graph/extractors/ner_entity_extractor.py +244 -0
- aiecs/application/knowledge_graph/fusion/__init__.py +23 -0
- aiecs/application/knowledge_graph/fusion/entity_deduplicator.py +387 -0
- aiecs/application/knowledge_graph/fusion/entity_linker.py +343 -0
- aiecs/application/knowledge_graph/fusion/knowledge_fusion.py +580 -0
- aiecs/application/knowledge_graph/fusion/relation_deduplicator.py +189 -0
- aiecs/application/knowledge_graph/pattern_matching/__init__.py +21 -0
- aiecs/application/knowledge_graph/pattern_matching/pattern_matcher.py +344 -0
- aiecs/application/knowledge_graph/pattern_matching/query_executor.py +378 -0
- aiecs/application/knowledge_graph/profiling/__init__.py +12 -0
- aiecs/application/knowledge_graph/profiling/query_plan_visualizer.py +199 -0
- aiecs/application/knowledge_graph/profiling/query_profiler.py +223 -0
- aiecs/application/knowledge_graph/reasoning/__init__.py +27 -0
- aiecs/application/knowledge_graph/reasoning/evidence_synthesis.py +347 -0
- aiecs/application/knowledge_graph/reasoning/inference_engine.py +504 -0
- aiecs/application/knowledge_graph/reasoning/logic_form_parser.py +167 -0
- aiecs/application/knowledge_graph/reasoning/logic_parser/__init__.py +79 -0
- aiecs/application/knowledge_graph/reasoning/logic_parser/ast_builder.py +513 -0
- aiecs/application/knowledge_graph/reasoning/logic_parser/ast_nodes.py +630 -0
- aiecs/application/knowledge_graph/reasoning/logic_parser/ast_validator.py +654 -0
- aiecs/application/knowledge_graph/reasoning/logic_parser/error_handler.py +477 -0
- aiecs/application/knowledge_graph/reasoning/logic_parser/parser.py +390 -0
- aiecs/application/knowledge_graph/reasoning/logic_parser/query_context.py +217 -0
- aiecs/application/knowledge_graph/reasoning/logic_query_integration.py +169 -0
- aiecs/application/knowledge_graph/reasoning/query_planner.py +872 -0
- aiecs/application/knowledge_graph/reasoning/reasoning_engine.py +554 -0
- aiecs/application/knowledge_graph/retrieval/__init__.py +19 -0
- aiecs/application/knowledge_graph/retrieval/retrieval_strategies.py +596 -0
- aiecs/application/knowledge_graph/search/__init__.py +59 -0
- aiecs/application/knowledge_graph/search/hybrid_search.py +423 -0
- aiecs/application/knowledge_graph/search/reranker.py +295 -0
- aiecs/application/knowledge_graph/search/reranker_strategies.py +553 -0
- aiecs/application/knowledge_graph/search/text_similarity.py +398 -0
- aiecs/application/knowledge_graph/traversal/__init__.py +15 -0
- aiecs/application/knowledge_graph/traversal/enhanced_traversal.py +329 -0
- aiecs/application/knowledge_graph/traversal/path_scorer.py +269 -0
- aiecs/application/knowledge_graph/validators/__init__.py +13 -0
- aiecs/application/knowledge_graph/validators/relation_validator.py +189 -0
- aiecs/application/knowledge_graph/visualization/__init__.py +11 -0
- aiecs/application/knowledge_graph/visualization/graph_visualizer.py +321 -0
- aiecs/common/__init__.py +9 -0
- aiecs/common/knowledge_graph/__init__.py +17 -0
- aiecs/common/knowledge_graph/runnable.py +484 -0
- aiecs/config/__init__.py +16 -0
- aiecs/config/config.py +498 -0
- aiecs/config/graph_config.py +137 -0
- aiecs/config/registry.py +23 -0
- aiecs/core/__init__.py +46 -0
- aiecs/core/interface/__init__.py +34 -0
- aiecs/core/interface/execution_interface.py +152 -0
- aiecs/core/interface/storage_interface.py +171 -0
- aiecs/domain/__init__.py +289 -0
- aiecs/domain/agent/__init__.py +189 -0
- aiecs/domain/agent/base_agent.py +697 -0
- aiecs/domain/agent/exceptions.py +103 -0
- aiecs/domain/agent/graph_aware_mixin.py +559 -0
- aiecs/domain/agent/hybrid_agent.py +490 -0
- aiecs/domain/agent/integration/__init__.py +26 -0
- aiecs/domain/agent/integration/context_compressor.py +222 -0
- aiecs/domain/agent/integration/context_engine_adapter.py +252 -0
- aiecs/domain/agent/integration/retry_policy.py +219 -0
- aiecs/domain/agent/integration/role_config.py +213 -0
- aiecs/domain/agent/knowledge_aware_agent.py +646 -0
- aiecs/domain/agent/lifecycle.py +296 -0
- aiecs/domain/agent/llm_agent.py +300 -0
- aiecs/domain/agent/memory/__init__.py +12 -0
- aiecs/domain/agent/memory/conversation.py +197 -0
- aiecs/domain/agent/migration/__init__.py +14 -0
- aiecs/domain/agent/migration/conversion.py +160 -0
- aiecs/domain/agent/migration/legacy_wrapper.py +90 -0
- aiecs/domain/agent/models.py +317 -0
- aiecs/domain/agent/observability.py +407 -0
- aiecs/domain/agent/persistence.py +289 -0
- aiecs/domain/agent/prompts/__init__.py +29 -0
- aiecs/domain/agent/prompts/builder.py +161 -0
- aiecs/domain/agent/prompts/formatters.py +189 -0
- aiecs/domain/agent/prompts/template.py +255 -0
- aiecs/domain/agent/registry.py +260 -0
- aiecs/domain/agent/tool_agent.py +257 -0
- aiecs/domain/agent/tools/__init__.py +12 -0
- aiecs/domain/agent/tools/schema_generator.py +221 -0
- aiecs/domain/community/__init__.py +155 -0
- aiecs/domain/community/agent_adapter.py +477 -0
- aiecs/domain/community/analytics.py +481 -0
- aiecs/domain/community/collaborative_workflow.py +642 -0
- aiecs/domain/community/communication_hub.py +645 -0
- aiecs/domain/community/community_builder.py +320 -0
- aiecs/domain/community/community_integration.py +800 -0
- aiecs/domain/community/community_manager.py +813 -0
- aiecs/domain/community/decision_engine.py +879 -0
- aiecs/domain/community/exceptions.py +225 -0
- aiecs/domain/community/models/__init__.py +33 -0
- aiecs/domain/community/models/community_models.py +268 -0
- aiecs/domain/community/resource_manager.py +457 -0
- aiecs/domain/community/shared_context_manager.py +603 -0
- aiecs/domain/context/__init__.py +58 -0
- aiecs/domain/context/context_engine.py +989 -0
- aiecs/domain/context/conversation_models.py +354 -0
- aiecs/domain/context/graph_memory.py +467 -0
- aiecs/domain/execution/__init__.py +12 -0
- aiecs/domain/execution/model.py +57 -0
- aiecs/domain/knowledge_graph/__init__.py +19 -0
- aiecs/domain/knowledge_graph/models/__init__.py +52 -0
- aiecs/domain/knowledge_graph/models/entity.py +130 -0
- aiecs/domain/knowledge_graph/models/evidence.py +194 -0
- aiecs/domain/knowledge_graph/models/inference_rule.py +186 -0
- aiecs/domain/knowledge_graph/models/path.py +179 -0
- aiecs/domain/knowledge_graph/models/path_pattern.py +173 -0
- aiecs/domain/knowledge_graph/models/query.py +272 -0
- aiecs/domain/knowledge_graph/models/query_plan.py +187 -0
- aiecs/domain/knowledge_graph/models/relation.py +136 -0
- aiecs/domain/knowledge_graph/schema/__init__.py +23 -0
- aiecs/domain/knowledge_graph/schema/entity_type.py +135 -0
- aiecs/domain/knowledge_graph/schema/graph_schema.py +271 -0
- aiecs/domain/knowledge_graph/schema/property_schema.py +155 -0
- aiecs/domain/knowledge_graph/schema/relation_type.py +171 -0
- aiecs/domain/knowledge_graph/schema/schema_manager.py +496 -0
- aiecs/domain/knowledge_graph/schema/type_enums.py +205 -0
- aiecs/domain/task/__init__.py +13 -0
- aiecs/domain/task/dsl_processor.py +613 -0
- aiecs/domain/task/model.py +62 -0
- aiecs/domain/task/task_context.py +268 -0
- aiecs/infrastructure/__init__.py +24 -0
- aiecs/infrastructure/graph_storage/__init__.py +11 -0
- aiecs/infrastructure/graph_storage/base.py +601 -0
- aiecs/infrastructure/graph_storage/batch_operations.py +449 -0
- aiecs/infrastructure/graph_storage/cache.py +429 -0
- aiecs/infrastructure/graph_storage/distributed.py +226 -0
- aiecs/infrastructure/graph_storage/error_handling.py +390 -0
- aiecs/infrastructure/graph_storage/graceful_degradation.py +306 -0
- aiecs/infrastructure/graph_storage/health_checks.py +378 -0
- aiecs/infrastructure/graph_storage/in_memory.py +514 -0
- aiecs/infrastructure/graph_storage/index_optimization.py +483 -0
- aiecs/infrastructure/graph_storage/lazy_loading.py +410 -0
- aiecs/infrastructure/graph_storage/metrics.py +357 -0
- aiecs/infrastructure/graph_storage/migration.py +413 -0
- aiecs/infrastructure/graph_storage/pagination.py +471 -0
- aiecs/infrastructure/graph_storage/performance_monitoring.py +466 -0
- aiecs/infrastructure/graph_storage/postgres.py +871 -0
- aiecs/infrastructure/graph_storage/query_optimizer.py +635 -0
- aiecs/infrastructure/graph_storage/schema_cache.py +290 -0
- aiecs/infrastructure/graph_storage/sqlite.py +623 -0
- aiecs/infrastructure/graph_storage/streaming.py +495 -0
- aiecs/infrastructure/messaging/__init__.py +13 -0
- aiecs/infrastructure/messaging/celery_task_manager.py +383 -0
- aiecs/infrastructure/messaging/websocket_manager.py +298 -0
- aiecs/infrastructure/monitoring/__init__.py +34 -0
- aiecs/infrastructure/monitoring/executor_metrics.py +174 -0
- aiecs/infrastructure/monitoring/global_metrics_manager.py +213 -0
- aiecs/infrastructure/monitoring/structured_logger.py +48 -0
- aiecs/infrastructure/monitoring/tracing_manager.py +410 -0
- aiecs/infrastructure/persistence/__init__.py +24 -0
- aiecs/infrastructure/persistence/context_engine_client.py +187 -0
- aiecs/infrastructure/persistence/database_manager.py +333 -0
- aiecs/infrastructure/persistence/file_storage.py +754 -0
- aiecs/infrastructure/persistence/redis_client.py +220 -0
- aiecs/llm/__init__.py +86 -0
- aiecs/llm/callbacks/__init__.py +11 -0
- aiecs/llm/callbacks/custom_callbacks.py +264 -0
- aiecs/llm/client_factory.py +420 -0
- aiecs/llm/clients/__init__.py +33 -0
- aiecs/llm/clients/base_client.py +193 -0
- aiecs/llm/clients/googleai_client.py +181 -0
- aiecs/llm/clients/openai_client.py +131 -0
- aiecs/llm/clients/vertex_client.py +437 -0
- aiecs/llm/clients/xai_client.py +184 -0
- aiecs/llm/config/__init__.py +51 -0
- aiecs/llm/config/config_loader.py +275 -0
- aiecs/llm/config/config_validator.py +236 -0
- aiecs/llm/config/model_config.py +151 -0
- aiecs/llm/utils/__init__.py +10 -0
- aiecs/llm/utils/validate_config.py +91 -0
- aiecs/main.py +363 -0
- aiecs/scripts/__init__.py +3 -0
- aiecs/scripts/aid/VERSION_MANAGEMENT.md +97 -0
- aiecs/scripts/aid/__init__.py +19 -0
- aiecs/scripts/aid/version_manager.py +215 -0
- aiecs/scripts/dependance_check/DEPENDENCY_SYSTEM_SUMMARY.md +242 -0
- aiecs/scripts/dependance_check/README_DEPENDENCY_CHECKER.md +310 -0
- aiecs/scripts/dependance_check/__init__.py +17 -0
- aiecs/scripts/dependance_check/dependency_checker.py +938 -0
- aiecs/scripts/dependance_check/dependency_fixer.py +391 -0
- aiecs/scripts/dependance_check/download_nlp_data.py +396 -0
- aiecs/scripts/dependance_check/quick_dependency_check.py +270 -0
- aiecs/scripts/dependance_check/setup_nlp_data.sh +217 -0
- aiecs/scripts/dependance_patch/__init__.py +7 -0
- aiecs/scripts/dependance_patch/fix_weasel/README_WEASEL_PATCH.md +126 -0
- aiecs/scripts/dependance_patch/fix_weasel/__init__.py +11 -0
- aiecs/scripts/dependance_patch/fix_weasel/fix_weasel_validator.py +128 -0
- aiecs/scripts/dependance_patch/fix_weasel/fix_weasel_validator.sh +82 -0
- aiecs/scripts/dependance_patch/fix_weasel/patch_weasel_library.sh +188 -0
- aiecs/scripts/dependance_patch/fix_weasel/run_weasel_patch.sh +41 -0
- aiecs/scripts/tools_develop/README.md +449 -0
- aiecs/scripts/tools_develop/TOOL_AUTO_DISCOVERY.md +234 -0
- aiecs/scripts/tools_develop/__init__.py +21 -0
- aiecs/scripts/tools_develop/check_type_annotations.py +259 -0
- aiecs/scripts/tools_develop/validate_tool_schemas.py +422 -0
- aiecs/scripts/tools_develop/verify_tools.py +356 -0
- aiecs/tasks/__init__.py +1 -0
- aiecs/tasks/worker.py +172 -0
- aiecs/tools/__init__.py +299 -0
- aiecs/tools/apisource/__init__.py +99 -0
- aiecs/tools/apisource/intelligence/__init__.py +19 -0
- aiecs/tools/apisource/intelligence/data_fusion.py +381 -0
- aiecs/tools/apisource/intelligence/query_analyzer.py +413 -0
- aiecs/tools/apisource/intelligence/search_enhancer.py +388 -0
- aiecs/tools/apisource/monitoring/__init__.py +9 -0
- aiecs/tools/apisource/monitoring/metrics.py +303 -0
- aiecs/tools/apisource/providers/__init__.py +115 -0
- aiecs/tools/apisource/providers/base.py +664 -0
- aiecs/tools/apisource/providers/census.py +401 -0
- aiecs/tools/apisource/providers/fred.py +564 -0
- aiecs/tools/apisource/providers/newsapi.py +412 -0
- aiecs/tools/apisource/providers/worldbank.py +357 -0
- aiecs/tools/apisource/reliability/__init__.py +12 -0
- aiecs/tools/apisource/reliability/error_handler.py +375 -0
- aiecs/tools/apisource/reliability/fallback_strategy.py +391 -0
- aiecs/tools/apisource/tool.py +850 -0
- aiecs/tools/apisource/utils/__init__.py +9 -0
- aiecs/tools/apisource/utils/validators.py +338 -0
- aiecs/tools/base_tool.py +201 -0
- aiecs/tools/docs/__init__.py +121 -0
- aiecs/tools/docs/ai_document_orchestrator.py +599 -0
- aiecs/tools/docs/ai_document_writer_orchestrator.py +2403 -0
- aiecs/tools/docs/content_insertion_tool.py +1333 -0
- aiecs/tools/docs/document_creator_tool.py +1317 -0
- aiecs/tools/docs/document_layout_tool.py +1166 -0
- aiecs/tools/docs/document_parser_tool.py +994 -0
- aiecs/tools/docs/document_writer_tool.py +1818 -0
- aiecs/tools/knowledge_graph/__init__.py +17 -0
- aiecs/tools/knowledge_graph/graph_reasoning_tool.py +734 -0
- aiecs/tools/knowledge_graph/graph_search_tool.py +923 -0
- aiecs/tools/knowledge_graph/kg_builder_tool.py +476 -0
- aiecs/tools/langchain_adapter.py +542 -0
- aiecs/tools/schema_generator.py +275 -0
- aiecs/tools/search_tool/__init__.py +100 -0
- aiecs/tools/search_tool/analyzers.py +589 -0
- aiecs/tools/search_tool/cache.py +260 -0
- aiecs/tools/search_tool/constants.py +128 -0
- aiecs/tools/search_tool/context.py +216 -0
- aiecs/tools/search_tool/core.py +749 -0
- aiecs/tools/search_tool/deduplicator.py +123 -0
- aiecs/tools/search_tool/error_handler.py +271 -0
- aiecs/tools/search_tool/metrics.py +371 -0
- aiecs/tools/search_tool/rate_limiter.py +178 -0
- aiecs/tools/search_tool/schemas.py +277 -0
- aiecs/tools/statistics/__init__.py +80 -0
- aiecs/tools/statistics/ai_data_analysis_orchestrator.py +643 -0
- aiecs/tools/statistics/ai_insight_generator_tool.py +505 -0
- aiecs/tools/statistics/ai_report_orchestrator_tool.py +694 -0
- aiecs/tools/statistics/data_loader_tool.py +564 -0
- aiecs/tools/statistics/data_profiler_tool.py +658 -0
- aiecs/tools/statistics/data_transformer_tool.py +573 -0
- aiecs/tools/statistics/data_visualizer_tool.py +495 -0
- aiecs/tools/statistics/model_trainer_tool.py +487 -0
- aiecs/tools/statistics/statistical_analyzer_tool.py +459 -0
- aiecs/tools/task_tools/__init__.py +86 -0
- aiecs/tools/task_tools/chart_tool.py +732 -0
- aiecs/tools/task_tools/classfire_tool.py +922 -0
- aiecs/tools/task_tools/image_tool.py +447 -0
- aiecs/tools/task_tools/office_tool.py +684 -0
- aiecs/tools/task_tools/pandas_tool.py +635 -0
- aiecs/tools/task_tools/report_tool.py +635 -0
- aiecs/tools/task_tools/research_tool.py +392 -0
- aiecs/tools/task_tools/scraper_tool.py +715 -0
- aiecs/tools/task_tools/stats_tool.py +688 -0
- aiecs/tools/temp_file_manager.py +130 -0
- aiecs/tools/tool_executor/__init__.py +37 -0
- aiecs/tools/tool_executor/tool_executor.py +881 -0
- aiecs/utils/LLM_output_structor.py +445 -0
- aiecs/utils/__init__.py +34 -0
- aiecs/utils/base_callback.py +47 -0
- aiecs/utils/cache_provider.py +695 -0
- aiecs/utils/execution_utils.py +184 -0
- aiecs/utils/logging.py +1 -0
- aiecs/utils/prompt_loader.py +14 -0
- aiecs/utils/token_usage_repository.py +323 -0
- aiecs/ws/__init__.py +0 -0
- aiecs/ws/socket_server.py +52 -0
- aiecs-1.5.1.dist-info/METADATA +608 -0
- aiecs-1.5.1.dist-info/RECORD +302 -0
- aiecs-1.5.1.dist-info/WHEEL +5 -0
- aiecs-1.5.1.dist-info/entry_points.txt +10 -0
- aiecs-1.5.1.dist-info/licenses/LICENSE +225 -0
- aiecs-1.5.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,938 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Comprehensive dependency checker for AIECS tools.
|
|
4
|
+
|
|
5
|
+
This script checks all system dependencies, Python packages, and model files
|
|
6
|
+
required by various AIECS tools and provides detailed status reports and
|
|
7
|
+
installation instructions.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
import subprocess
|
|
13
|
+
import platform
|
|
14
|
+
import shutil
|
|
15
|
+
import logging
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Dict, List, Optional
|
|
18
|
+
from dataclasses import dataclass
|
|
19
|
+
from enum import Enum
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DependencyStatus(Enum):
|
|
23
|
+
"""Status of a dependency check."""
|
|
24
|
+
|
|
25
|
+
AVAILABLE = "available"
|
|
26
|
+
MISSING = "missing"
|
|
27
|
+
PARTIAL = "partial"
|
|
28
|
+
ERROR = "error"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class DependencyInfo:
|
|
33
|
+
"""Information about a dependency."""
|
|
34
|
+
|
|
35
|
+
name: str
|
|
36
|
+
status: DependencyStatus
|
|
37
|
+
description: str
|
|
38
|
+
install_command: Optional[str] = None
|
|
39
|
+
install_url: Optional[str] = None
|
|
40
|
+
impact: str = ""
|
|
41
|
+
is_critical: bool = True
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class ToolDependencies:
|
|
46
|
+
"""Dependencies for a specific tool."""
|
|
47
|
+
|
|
48
|
+
tool_name: str
|
|
49
|
+
system_deps: List[DependencyInfo]
|
|
50
|
+
python_deps: List[DependencyInfo]
|
|
51
|
+
model_deps: List[DependencyInfo]
|
|
52
|
+
optional_deps: List[DependencyInfo]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class DependencyChecker:
|
|
56
|
+
"""Main dependency checker class."""
|
|
57
|
+
|
|
58
|
+
def __init__(self):
|
|
59
|
+
self.logger = self._setup_logging()
|
|
60
|
+
self.system = platform.system().lower()
|
|
61
|
+
self.architecture = platform.machine().lower()
|
|
62
|
+
self.python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
|
|
63
|
+
|
|
64
|
+
def _setup_logging(self) -> logging.Logger:
|
|
65
|
+
"""Setup logging configuration."""
|
|
66
|
+
logging.basicConfig(
|
|
67
|
+
level=logging.INFO,
|
|
68
|
+
format="%(asctime)s - %(levelname)s - %(message)s",
|
|
69
|
+
handlers=[
|
|
70
|
+
logging.StreamHandler(sys.stdout),
|
|
71
|
+
logging.FileHandler("dependency_check.log"),
|
|
72
|
+
],
|
|
73
|
+
)
|
|
74
|
+
return logging.getLogger(__name__)
|
|
75
|
+
|
|
76
|
+
def check_system_command(
|
|
77
|
+
self, command: str, version_flag: str = "--version"
|
|
78
|
+
) -> DependencyStatus:
|
|
79
|
+
"""Check if a system command is available."""
|
|
80
|
+
try:
|
|
81
|
+
result = subprocess.run(
|
|
82
|
+
[command, version_flag],
|
|
83
|
+
capture_output=True,
|
|
84
|
+
text=True,
|
|
85
|
+
timeout=10,
|
|
86
|
+
)
|
|
87
|
+
if result.returncode == 0:
|
|
88
|
+
return DependencyStatus.AVAILABLE
|
|
89
|
+
else:
|
|
90
|
+
return DependencyStatus.MISSING
|
|
91
|
+
except (
|
|
92
|
+
subprocess.TimeoutExpired,
|
|
93
|
+
FileNotFoundError,
|
|
94
|
+
subprocess.CalledProcessError,
|
|
95
|
+
):
|
|
96
|
+
return DependencyStatus.MISSING
|
|
97
|
+
|
|
98
|
+
def check_python_package(self, package_name: str) -> DependencyStatus:
|
|
99
|
+
"""Check if a Python package is installed."""
|
|
100
|
+
try:
|
|
101
|
+
__import__(package_name)
|
|
102
|
+
return DependencyStatus.AVAILABLE
|
|
103
|
+
except ImportError:
|
|
104
|
+
return DependencyStatus.MISSING
|
|
105
|
+
|
|
106
|
+
def check_file_exists(self, file_path: str) -> DependencyStatus:
|
|
107
|
+
"""Check if a file exists."""
|
|
108
|
+
if os.path.exists(file_path):
|
|
109
|
+
return DependencyStatus.AVAILABLE
|
|
110
|
+
else:
|
|
111
|
+
return DependencyStatus.MISSING
|
|
112
|
+
|
|
113
|
+
def check_directory_exists(self, dir_path: str) -> DependencyStatus:
|
|
114
|
+
"""Check if a directory exists."""
|
|
115
|
+
if os.path.isdir(dir_path):
|
|
116
|
+
return DependencyStatus.AVAILABLE
|
|
117
|
+
else:
|
|
118
|
+
return DependencyStatus.MISSING
|
|
119
|
+
|
|
120
|
+
def get_system_package_manager(self) -> str:
|
|
121
|
+
"""Get the appropriate package manager for the system."""
|
|
122
|
+
if self.system == "linux":
|
|
123
|
+
if shutil.which("apt-get"):
|
|
124
|
+
return "apt-get"
|
|
125
|
+
elif shutil.which("yum"):
|
|
126
|
+
return "yum"
|
|
127
|
+
elif shutil.which("dnf"):
|
|
128
|
+
return "dnf"
|
|
129
|
+
elif shutil.which("pacman"):
|
|
130
|
+
return "pacman"
|
|
131
|
+
elif self.system == "darwin":
|
|
132
|
+
if shutil.which("brew"):
|
|
133
|
+
return "brew"
|
|
134
|
+
elif self.system == "windows":
|
|
135
|
+
return "chocolatey"
|
|
136
|
+
return "unknown"
|
|
137
|
+
|
|
138
|
+
def check_image_tool_dependencies(self) -> ToolDependencies:
|
|
139
|
+
"""Check dependencies for Image Tool."""
|
|
140
|
+
system_deps = []
|
|
141
|
+
python_deps = []
|
|
142
|
+
model_deps = []
|
|
143
|
+
optional_deps = []
|
|
144
|
+
|
|
145
|
+
# Tesseract OCR
|
|
146
|
+
tesseract_status = self.check_system_command("tesseract")
|
|
147
|
+
system_deps.append(
|
|
148
|
+
DependencyInfo(
|
|
149
|
+
name="Tesseract OCR",
|
|
150
|
+
status=tesseract_status,
|
|
151
|
+
description="OCR engine for text extraction from images",
|
|
152
|
+
install_command=self._get_tesseract_install_command(),
|
|
153
|
+
impact="OCR functionality will be unavailable",
|
|
154
|
+
is_critical=True,
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
# Pillow system dependencies
|
|
159
|
+
pillow_status = self._check_pillow_system_deps()
|
|
160
|
+
system_deps.append(
|
|
161
|
+
DependencyInfo(
|
|
162
|
+
name="Pillow System Libraries",
|
|
163
|
+
status=pillow_status,
|
|
164
|
+
description="Image processing system libraries (libjpeg, libpng, etc.)",
|
|
165
|
+
install_command=self._get_pillow_system_deps_command(),
|
|
166
|
+
impact="Image processing may fail or be limited",
|
|
167
|
+
is_critical=True,
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
# Python packages
|
|
172
|
+
python_packages = ["PIL", "pytesseract"]
|
|
173
|
+
for pkg in python_packages:
|
|
174
|
+
status = self.check_python_package(pkg)
|
|
175
|
+
python_deps.append(
|
|
176
|
+
DependencyInfo(
|
|
177
|
+
name=pkg,
|
|
178
|
+
status=status,
|
|
179
|
+
description=f"Python package: {pkg}",
|
|
180
|
+
install_command=f"pip install {pkg}",
|
|
181
|
+
impact=f"{pkg} functionality will be unavailable",
|
|
182
|
+
is_critical=True,
|
|
183
|
+
)
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
# Tesseract language packs
|
|
187
|
+
lang_packs = [
|
|
188
|
+
"eng",
|
|
189
|
+
"chi_sim",
|
|
190
|
+
"chi_tra",
|
|
191
|
+
"fra",
|
|
192
|
+
"deu",
|
|
193
|
+
"jpn",
|
|
194
|
+
"kor",
|
|
195
|
+
"rus",
|
|
196
|
+
"spa",
|
|
197
|
+
]
|
|
198
|
+
for lang in lang_packs:
|
|
199
|
+
status = self._check_tesseract_lang_pack(lang)
|
|
200
|
+
model_deps.append(
|
|
201
|
+
DependencyInfo(
|
|
202
|
+
name=f"Tesseract {lang}",
|
|
203
|
+
status=status,
|
|
204
|
+
description=f"Tesseract language pack for {lang}",
|
|
205
|
+
install_command=self._get_tesseract_lang_install_command(lang),
|
|
206
|
+
impact=f"OCR in {lang} language will be unavailable",
|
|
207
|
+
is_critical=False,
|
|
208
|
+
)
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
return ToolDependencies(
|
|
212
|
+
tool_name="Image Tool",
|
|
213
|
+
system_deps=system_deps,
|
|
214
|
+
python_deps=python_deps,
|
|
215
|
+
model_deps=model_deps,
|
|
216
|
+
optional_deps=optional_deps,
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
def check_classfire_tool_dependencies(self) -> ToolDependencies:
|
|
220
|
+
"""Check dependencies for ClassFire Tool."""
|
|
221
|
+
system_deps = []
|
|
222
|
+
python_deps = []
|
|
223
|
+
model_deps = []
|
|
224
|
+
optional_deps = []
|
|
225
|
+
|
|
226
|
+
# Python packages
|
|
227
|
+
python_packages = [
|
|
228
|
+
"spacy",
|
|
229
|
+
"transformers",
|
|
230
|
+
"nltk",
|
|
231
|
+
"rake_nltk",
|
|
232
|
+
"spacy_pkuseg",
|
|
233
|
+
]
|
|
234
|
+
for pkg in python_packages:
|
|
235
|
+
status = self.check_python_package(pkg)
|
|
236
|
+
is_critical = pkg != "spacy_pkuseg" # spacy_pkuseg is optional
|
|
237
|
+
python_deps.append(
|
|
238
|
+
DependencyInfo(
|
|
239
|
+
name=pkg,
|
|
240
|
+
status=status,
|
|
241
|
+
description=f"Python package: {pkg}",
|
|
242
|
+
install_command=f"pip install {pkg}",
|
|
243
|
+
impact=f"{pkg} functionality will be unavailable",
|
|
244
|
+
is_critical=is_critical,
|
|
245
|
+
)
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
# spaCy models
|
|
249
|
+
spacy_models = ["en_core_web_sm", "zh_core_web_sm"]
|
|
250
|
+
for model in spacy_models:
|
|
251
|
+
status = self._check_spacy_model(model)
|
|
252
|
+
is_critical = model == "en_core_web_sm" # Only English model is critical
|
|
253
|
+
model_deps.append(
|
|
254
|
+
DependencyInfo(
|
|
255
|
+
name=f"spaCy {model}",
|
|
256
|
+
status=status,
|
|
257
|
+
description=f"spaCy model: {model}",
|
|
258
|
+
install_command=f"python -m spacy download {model}",
|
|
259
|
+
impact=f"Text processing in {model.split('_')[0]} language will be unavailable",
|
|
260
|
+
is_critical=is_critical,
|
|
261
|
+
)
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
# spaCy PKUSeg model (optional Chinese segmentation)
|
|
265
|
+
pkuseg_status = self._check_spacy_pkuseg_model()
|
|
266
|
+
model_deps.append(
|
|
267
|
+
DependencyInfo(
|
|
268
|
+
name="spaCy PKUSeg",
|
|
269
|
+
status=pkuseg_status,
|
|
270
|
+
description="Chinese text segmentation model for spaCy",
|
|
271
|
+
install_command="pip install spacy_pkuseg",
|
|
272
|
+
impact="Advanced Chinese text segmentation will be unavailable",
|
|
273
|
+
is_critical=False,
|
|
274
|
+
)
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
# Transformers models
|
|
278
|
+
transformers_models = ["facebook/bart-large-cnn", "t5-base"]
|
|
279
|
+
for model in transformers_models:
|
|
280
|
+
status = self._check_transformers_model(model)
|
|
281
|
+
model_deps.append(
|
|
282
|
+
DependencyInfo(
|
|
283
|
+
name=f"Transformers {model}",
|
|
284
|
+
status=status,
|
|
285
|
+
description=f"Transformers model: {model}",
|
|
286
|
+
install_command="Models download automatically on first use",
|
|
287
|
+
impact=f"Text summarization with {model} will be unavailable",
|
|
288
|
+
is_critical=False,
|
|
289
|
+
)
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
# NLTK data
|
|
293
|
+
nltk_data = [
|
|
294
|
+
"stopwords",
|
|
295
|
+
"punkt",
|
|
296
|
+
"wordnet",
|
|
297
|
+
"averaged_perceptron_tagger",
|
|
298
|
+
]
|
|
299
|
+
for data in nltk_data:
|
|
300
|
+
status = self._check_nltk_data(data)
|
|
301
|
+
model_deps.append(
|
|
302
|
+
DependencyInfo(
|
|
303
|
+
name=f"NLTK {data}",
|
|
304
|
+
status=status,
|
|
305
|
+
description=f"NLTK data: {data}",
|
|
306
|
+
install_command=f"python -c \"import nltk; nltk.download('{data}')\"",
|
|
307
|
+
impact=f"NLTK {data} functionality will be unavailable",
|
|
308
|
+
is_critical=True,
|
|
309
|
+
)
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
return ToolDependencies(
|
|
313
|
+
tool_name="ClassFire Tool",
|
|
314
|
+
system_deps=system_deps,
|
|
315
|
+
python_deps=python_deps,
|
|
316
|
+
model_deps=model_deps,
|
|
317
|
+
optional_deps=optional_deps,
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
def check_office_tool_dependencies(self) -> ToolDependencies:
|
|
321
|
+
"""Check dependencies for Office Tool."""
|
|
322
|
+
system_deps = []
|
|
323
|
+
python_deps = []
|
|
324
|
+
model_deps = []
|
|
325
|
+
optional_deps = []
|
|
326
|
+
|
|
327
|
+
# Java Runtime Environment
|
|
328
|
+
java_status = self.check_system_command("java", "-version")
|
|
329
|
+
system_deps.append(
|
|
330
|
+
DependencyInfo(
|
|
331
|
+
name="Java Runtime Environment",
|
|
332
|
+
status=java_status,
|
|
333
|
+
description="Java runtime for Apache Tika document parsing",
|
|
334
|
+
install_command=self._get_java_install_command(),
|
|
335
|
+
impact="Document parsing with Tika will be unavailable",
|
|
336
|
+
is_critical=True,
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
# Tesseract OCR
|
|
341
|
+
tesseract_status = self.check_system_command("tesseract")
|
|
342
|
+
system_deps.append(
|
|
343
|
+
DependencyInfo(
|
|
344
|
+
name="Tesseract OCR",
|
|
345
|
+
status=tesseract_status,
|
|
346
|
+
description="OCR engine for image text extraction",
|
|
347
|
+
install_command=self._get_tesseract_install_command(),
|
|
348
|
+
impact="OCR functionality will be unavailable",
|
|
349
|
+
is_critical=False,
|
|
350
|
+
)
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
# Python packages (package_name: import_name)
|
|
354
|
+
python_packages = {
|
|
355
|
+
"tika": "tika",
|
|
356
|
+
"python-docx": "docx", # Package name vs import name
|
|
357
|
+
"python-pptx": "pptx", # Package name vs import name
|
|
358
|
+
"openpyxl": "openpyxl",
|
|
359
|
+
"pdfplumber": "pdfplumber",
|
|
360
|
+
"pytesseract": "pytesseract",
|
|
361
|
+
"PIL": "PIL",
|
|
362
|
+
}
|
|
363
|
+
for pkg_name, import_name in python_packages.items():
|
|
364
|
+
status = self.check_python_package(import_name)
|
|
365
|
+
python_deps.append(
|
|
366
|
+
DependencyInfo(
|
|
367
|
+
name=pkg_name,
|
|
368
|
+
status=status,
|
|
369
|
+
description=f"Python package: {pkg_name}",
|
|
370
|
+
install_command=f"pip install {pkg_name}",
|
|
371
|
+
impact=f"{pkg_name} functionality will be unavailable",
|
|
372
|
+
is_critical=True,
|
|
373
|
+
)
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
return ToolDependencies(
|
|
377
|
+
tool_name="Office Tool",
|
|
378
|
+
system_deps=system_deps,
|
|
379
|
+
python_deps=python_deps,
|
|
380
|
+
model_deps=model_deps,
|
|
381
|
+
optional_deps=optional_deps,
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
def check_stats_tool_dependencies(self) -> ToolDependencies:
|
|
385
|
+
"""Check dependencies for Stats Tool."""
|
|
386
|
+
system_deps = []
|
|
387
|
+
python_deps = []
|
|
388
|
+
model_deps = []
|
|
389
|
+
optional_deps = []
|
|
390
|
+
|
|
391
|
+
# pyreadstat system dependencies
|
|
392
|
+
pyreadstat_status = self._check_pyreadstat_system_deps()
|
|
393
|
+
system_deps.append(
|
|
394
|
+
DependencyInfo(
|
|
395
|
+
name="libreadstat",
|
|
396
|
+
status=pyreadstat_status,
|
|
397
|
+
description="System library for reading SAS, SPSS, Stata files",
|
|
398
|
+
install_command=self._get_pyreadstat_install_command(),
|
|
399
|
+
impact="SAS, SPSS, Stata file reading will be unavailable",
|
|
400
|
+
is_critical=False,
|
|
401
|
+
)
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
# Excel system dependencies
|
|
405
|
+
excel_status = self._check_excel_system_deps()
|
|
406
|
+
system_deps.append(
|
|
407
|
+
DependencyInfo(
|
|
408
|
+
name="Excel System Libraries",
|
|
409
|
+
status=excel_status,
|
|
410
|
+
description="System libraries for Excel file processing",
|
|
411
|
+
install_command=self._get_excel_system_deps_command(),
|
|
412
|
+
impact="Excel file processing may be limited",
|
|
413
|
+
is_critical=False,
|
|
414
|
+
)
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
# Python packages (package_name: import_name)
|
|
418
|
+
python_packages = {
|
|
419
|
+
"pandas": "pandas",
|
|
420
|
+
"numpy": "numpy",
|
|
421
|
+
"scipy": "scipy",
|
|
422
|
+
"scikit-learn": "sklearn", # Package name vs import name
|
|
423
|
+
"statsmodels": "statsmodels",
|
|
424
|
+
"pyreadstat": "pyreadstat",
|
|
425
|
+
"openpyxl": "openpyxl",
|
|
426
|
+
}
|
|
427
|
+
for pkg_name, import_name in python_packages.items():
|
|
428
|
+
status = self.check_python_package(import_name)
|
|
429
|
+
python_deps.append(
|
|
430
|
+
DependencyInfo(
|
|
431
|
+
name=pkg_name,
|
|
432
|
+
status=status,
|
|
433
|
+
description=f"Python package: {pkg_name}",
|
|
434
|
+
install_command=f"pip install {pkg_name}",
|
|
435
|
+
impact=f"{pkg_name} functionality will be unavailable",
|
|
436
|
+
is_critical=True,
|
|
437
|
+
)
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
return ToolDependencies(
|
|
441
|
+
tool_name="Stats Tool",
|
|
442
|
+
system_deps=system_deps,
|
|
443
|
+
python_deps=python_deps,
|
|
444
|
+
model_deps=model_deps,
|
|
445
|
+
optional_deps=optional_deps,
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
def check_report_tool_dependencies(self) -> ToolDependencies:
|
|
449
|
+
"""Check dependencies for Report Tool."""
|
|
450
|
+
system_deps = []
|
|
451
|
+
python_deps = []
|
|
452
|
+
model_deps = []
|
|
453
|
+
optional_deps = []
|
|
454
|
+
|
|
455
|
+
# WeasyPrint system dependencies
|
|
456
|
+
weasyprint_status = self._check_weasyprint_system_deps()
|
|
457
|
+
system_deps.append(
|
|
458
|
+
DependencyInfo(
|
|
459
|
+
name="WeasyPrint System Libraries",
|
|
460
|
+
status=weasyprint_status,
|
|
461
|
+
description="System libraries for PDF generation (cairo, pango, etc.)",
|
|
462
|
+
install_command=self._get_weasyprint_install_command(),
|
|
463
|
+
impact="PDF generation will be unavailable",
|
|
464
|
+
is_critical=False,
|
|
465
|
+
)
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
# Matplotlib system dependencies
|
|
469
|
+
matplotlib_status = self._check_matplotlib_system_deps()
|
|
470
|
+
system_deps.append(
|
|
471
|
+
DependencyInfo(
|
|
472
|
+
name="Matplotlib System Libraries",
|
|
473
|
+
status=matplotlib_status,
|
|
474
|
+
description="System libraries for chart generation",
|
|
475
|
+
install_command=self._get_matplotlib_system_deps_command(),
|
|
476
|
+
impact="Chart generation may be limited",
|
|
477
|
+
is_critical=False,
|
|
478
|
+
)
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
# Python packages (package_name: import_name)
|
|
482
|
+
python_packages = {
|
|
483
|
+
"jinja2": "jinja2",
|
|
484
|
+
"matplotlib": "matplotlib",
|
|
485
|
+
"weasyprint": "weasyprint",
|
|
486
|
+
"bleach": "bleach",
|
|
487
|
+
"markdown": "markdown",
|
|
488
|
+
"pandas": "pandas",
|
|
489
|
+
"openpyxl": "openpyxl",
|
|
490
|
+
"python-docx": "docx", # Package name vs import name
|
|
491
|
+
"python-pptx": "pptx", # Package name vs import name
|
|
492
|
+
}
|
|
493
|
+
for pkg_name, import_name in python_packages.items():
|
|
494
|
+
status = self.check_python_package(import_name)
|
|
495
|
+
python_deps.append(
|
|
496
|
+
DependencyInfo(
|
|
497
|
+
name=pkg_name,
|
|
498
|
+
status=status,
|
|
499
|
+
description=f"Python package: {pkg_name}",
|
|
500
|
+
install_command=f"pip install {pkg_name}",
|
|
501
|
+
impact=f"{pkg_name} functionality will be unavailable",
|
|
502
|
+
is_critical=True,
|
|
503
|
+
)
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
return ToolDependencies(
|
|
507
|
+
tool_name="Report Tool",
|
|
508
|
+
system_deps=system_deps,
|
|
509
|
+
python_deps=python_deps,
|
|
510
|
+
model_deps=model_deps,
|
|
511
|
+
optional_deps=optional_deps,
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
def check_scraper_tool_dependencies(self) -> ToolDependencies:
|
|
515
|
+
"""Check dependencies for Scraper Tool."""
|
|
516
|
+
system_deps = []
|
|
517
|
+
python_deps = []
|
|
518
|
+
model_deps = []
|
|
519
|
+
optional_deps = []
|
|
520
|
+
|
|
521
|
+
# Playwright browsers
|
|
522
|
+
playwright_status = self._check_playwright_browsers()
|
|
523
|
+
system_deps.append(
|
|
524
|
+
DependencyInfo(
|
|
525
|
+
name="Playwright Browsers",
|
|
526
|
+
status=playwright_status,
|
|
527
|
+
description="Browser binaries for JavaScript rendering",
|
|
528
|
+
install_command="playwright install",
|
|
529
|
+
impact="JavaScript rendering will be unavailable",
|
|
530
|
+
is_critical=False,
|
|
531
|
+
)
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
# Playwright system dependencies
|
|
535
|
+
playwright_deps_status = self._check_playwright_system_deps()
|
|
536
|
+
system_deps.append(
|
|
537
|
+
DependencyInfo(
|
|
538
|
+
name="Playwright System Dependencies",
|
|
539
|
+
status=playwright_deps_status,
|
|
540
|
+
description="System libraries for browser automation",
|
|
541
|
+
install_command="playwright install-deps",
|
|
542
|
+
impact="Browser automation may fail",
|
|
543
|
+
is_critical=False,
|
|
544
|
+
)
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
# Python packages (package_name: import_name)
|
|
548
|
+
python_packages = {
|
|
549
|
+
"playwright": "playwright",
|
|
550
|
+
"scrapy": "scrapy",
|
|
551
|
+
"httpx": "httpx",
|
|
552
|
+
"beautifulsoup4": "bs4", # Package name vs import name
|
|
553
|
+
"lxml": "lxml",
|
|
554
|
+
}
|
|
555
|
+
for pkg_name, import_name in python_packages.items():
|
|
556
|
+
status = self.check_python_package(import_name)
|
|
557
|
+
python_deps.append(
|
|
558
|
+
DependencyInfo(
|
|
559
|
+
name=pkg_name,
|
|
560
|
+
status=status,
|
|
561
|
+
description=f"Python package: {pkg_name}",
|
|
562
|
+
install_command=f"pip install {pkg_name}",
|
|
563
|
+
impact=f"{pkg_name} functionality will be unavailable",
|
|
564
|
+
is_critical=True,
|
|
565
|
+
)
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
return ToolDependencies(
|
|
569
|
+
tool_name="Scraper Tool",
|
|
570
|
+
system_deps=system_deps,
|
|
571
|
+
python_deps=python_deps,
|
|
572
|
+
model_deps=model_deps,
|
|
573
|
+
optional_deps=optional_deps,
|
|
574
|
+
)
|
|
575
|
+
|
|
576
|
+
def _check_pillow_system_deps(self) -> DependencyStatus:
|
|
577
|
+
"""Check Pillow system dependencies."""
|
|
578
|
+
try:
|
|
579
|
+
from PIL import Image
|
|
580
|
+
|
|
581
|
+
# Try to create a simple image to test system libraries
|
|
582
|
+
img = Image.new("RGB", (10, 10), color="red")
|
|
583
|
+
img.save("/tmp/test_pillow.png")
|
|
584
|
+
os.remove("/tmp/test_pillow.png")
|
|
585
|
+
return DependencyStatus.AVAILABLE
|
|
586
|
+
except Exception:
|
|
587
|
+
return DependencyStatus.MISSING
|
|
588
|
+
|
|
589
|
+
def _check_tesseract_lang_pack(self, lang: str) -> DependencyStatus:
|
|
590
|
+
"""Check if a Tesseract language pack is installed."""
|
|
591
|
+
try:
|
|
592
|
+
result = subprocess.run(
|
|
593
|
+
["tesseract", "--list-langs"],
|
|
594
|
+
capture_output=True,
|
|
595
|
+
text=True,
|
|
596
|
+
timeout=10,
|
|
597
|
+
)
|
|
598
|
+
if result.returncode == 0 and lang in result.stdout:
|
|
599
|
+
return DependencyStatus.AVAILABLE
|
|
600
|
+
else:
|
|
601
|
+
return DependencyStatus.MISSING
|
|
602
|
+
except Exception:
|
|
603
|
+
return DependencyStatus.MISSING
|
|
604
|
+
|
|
605
|
+
def _check_spacy_model(self, model: str) -> DependencyStatus:
|
|
606
|
+
"""Check if a spaCy model is installed."""
|
|
607
|
+
try:
|
|
608
|
+
import spacy
|
|
609
|
+
|
|
610
|
+
spacy.load(model)
|
|
611
|
+
return DependencyStatus.AVAILABLE
|
|
612
|
+
except OSError:
|
|
613
|
+
return DependencyStatus.MISSING
|
|
614
|
+
except Exception:
|
|
615
|
+
return DependencyStatus.ERROR
|
|
616
|
+
|
|
617
|
+
def _check_transformers_model(self, model: str) -> DependencyStatus:
|
|
618
|
+
"""Check if a Transformers model is available."""
|
|
619
|
+
try:
|
|
620
|
+
from transformers import pipeline
|
|
621
|
+
|
|
622
|
+
# Try to load the model (this will download if not present)
|
|
623
|
+
pipeline("summarization", model=model) # Just checking if it loads
|
|
624
|
+
return DependencyStatus.AVAILABLE
|
|
625
|
+
except Exception:
|
|
626
|
+
return DependencyStatus.MISSING
|
|
627
|
+
|
|
628
|
+
def _check_nltk_data(self, data: str) -> DependencyStatus:
|
|
629
|
+
"""Check if NLTK data is available."""
|
|
630
|
+
try:
|
|
631
|
+
import nltk
|
|
632
|
+
|
|
633
|
+
nltk.data.find(f"corpora/{data}")
|
|
634
|
+
return DependencyStatus.AVAILABLE
|
|
635
|
+
except LookupError:
|
|
636
|
+
return DependencyStatus.MISSING
|
|
637
|
+
except Exception:
|
|
638
|
+
return DependencyStatus.ERROR
|
|
639
|
+
|
|
640
|
+
def _check_spacy_pkuseg_model(self) -> DependencyStatus:
|
|
641
|
+
"""Check if spaCy PKUSeg model is available."""
|
|
642
|
+
try:
|
|
643
|
+
import spacy_pkuseg
|
|
644
|
+
|
|
645
|
+
# Test basic functionality
|
|
646
|
+
seg = spacy_pkuseg.pkuseg()
|
|
647
|
+
list(seg.cut("ęµčÆ"))
|
|
648
|
+
return DependencyStatus.AVAILABLE
|
|
649
|
+
except ImportError:
|
|
650
|
+
return DependencyStatus.MISSING
|
|
651
|
+
except Exception:
|
|
652
|
+
return DependencyStatus.ERROR
|
|
653
|
+
|
|
654
|
+
def _check_pyreadstat_system_deps(self) -> DependencyStatus:
|
|
655
|
+
"""Check pyreadstat system dependencies."""
|
|
656
|
+
try:
|
|
657
|
+
return DependencyStatus.AVAILABLE
|
|
658
|
+
except ImportError:
|
|
659
|
+
return DependencyStatus.MISSING
|
|
660
|
+
except Exception:
|
|
661
|
+
return DependencyStatus.ERROR
|
|
662
|
+
|
|
663
|
+
def _check_excel_system_deps(self) -> DependencyStatus:
|
|
664
|
+
"""Check Excel system dependencies."""
|
|
665
|
+
try:
|
|
666
|
+
return DependencyStatus.AVAILABLE
|
|
667
|
+
except ImportError:
|
|
668
|
+
return DependencyStatus.MISSING
|
|
669
|
+
except Exception:
|
|
670
|
+
return DependencyStatus.ERROR
|
|
671
|
+
|
|
672
|
+
def _check_weasyprint_system_deps(self) -> DependencyStatus:
|
|
673
|
+
"""Check WeasyPrint system dependencies."""
|
|
674
|
+
try:
|
|
675
|
+
return DependencyStatus.AVAILABLE
|
|
676
|
+
except ImportError:
|
|
677
|
+
return DependencyStatus.MISSING
|
|
678
|
+
except Exception:
|
|
679
|
+
return DependencyStatus.ERROR
|
|
680
|
+
|
|
681
|
+
def _check_matplotlib_system_deps(self) -> DependencyStatus:
|
|
682
|
+
"""Check Matplotlib system dependencies."""
|
|
683
|
+
try:
|
|
684
|
+
import matplotlib.pyplot as plt
|
|
685
|
+
|
|
686
|
+
plt.figure()
|
|
687
|
+
return DependencyStatus.AVAILABLE
|
|
688
|
+
except Exception:
|
|
689
|
+
return DependencyStatus.MISSING
|
|
690
|
+
|
|
691
|
+
def _check_playwright_browsers(self) -> DependencyStatus:
|
|
692
|
+
"""Check if Playwright browsers are installed."""
|
|
693
|
+
browsers_dir = Path.home() / ".cache" / "ms-playwright"
|
|
694
|
+
if browsers_dir.exists() and any(browsers_dir.iterdir()):
|
|
695
|
+
return DependencyStatus.AVAILABLE
|
|
696
|
+
else:
|
|
697
|
+
return DependencyStatus.MISSING
|
|
698
|
+
|
|
699
|
+
def _check_playwright_system_deps(self) -> DependencyStatus:
|
|
700
|
+
"""Check Playwright system dependencies."""
|
|
701
|
+
try:
|
|
702
|
+
from playwright.sync_api import sync_playwright
|
|
703
|
+
|
|
704
|
+
with sync_playwright() as p:
|
|
705
|
+
browser = p.chromium.launch(headless=True)
|
|
706
|
+
browser.close()
|
|
707
|
+
return DependencyStatus.AVAILABLE
|
|
708
|
+
except Exception:
|
|
709
|
+
return DependencyStatus.MISSING
|
|
710
|
+
|
|
711
|
+
def _get_tesseract_install_command(self) -> str:
|
|
712
|
+
"""Get Tesseract installation command for current system."""
|
|
713
|
+
if self.system == "linux":
|
|
714
|
+
return "sudo apt-get install tesseract-ocr tesseract-ocr-eng"
|
|
715
|
+
elif self.system == "darwin":
|
|
716
|
+
return "brew install tesseract"
|
|
717
|
+
elif self.system == "windows":
|
|
718
|
+
return "choco install tesseract"
|
|
719
|
+
return "Please install Tesseract OCR manually"
|
|
720
|
+
|
|
721
|
+
def _get_pillow_system_deps_command(self) -> str:
|
|
722
|
+
"""Get Pillow system dependencies installation command."""
|
|
723
|
+
if self.system == "linux":
|
|
724
|
+
return "sudo apt-get install libjpeg-dev zlib1g-dev libpng-dev libtiff-dev libwebp-dev libopenjp2-7-dev"
|
|
725
|
+
elif self.system == "darwin":
|
|
726
|
+
return "brew install libjpeg zlib libpng libtiff webp openjpeg"
|
|
727
|
+
return "Please install image processing libraries manually"
|
|
728
|
+
|
|
729
|
+
def _get_tesseract_lang_install_command(self, lang: str) -> str:
|
|
730
|
+
"""Get Tesseract language pack installation command."""
|
|
731
|
+
if self.system == "linux":
|
|
732
|
+
return f"sudo apt-get install tesseract-ocr-{lang}"
|
|
733
|
+
elif self.system == "darwin":
|
|
734
|
+
return f"brew install tesseract-lang-{lang}"
|
|
735
|
+
return f"Please install Tesseract {lang} language pack manually"
|
|
736
|
+
|
|
737
|
+
def _get_java_install_command(self) -> str:
|
|
738
|
+
"""Get Java installation command."""
|
|
739
|
+
if self.system == "linux":
|
|
740
|
+
return "sudo apt-get install openjdk-11-jdk"
|
|
741
|
+
elif self.system == "darwin":
|
|
742
|
+
return "brew install openjdk@11"
|
|
743
|
+
elif self.system == "windows":
|
|
744
|
+
return "choco install openjdk11"
|
|
745
|
+
return "Please install Java 11 or later manually"
|
|
746
|
+
|
|
747
|
+
def _get_pyreadstat_install_command(self) -> str:
|
|
748
|
+
"""Get pyreadstat installation command."""
|
|
749
|
+
if self.system == "linux":
|
|
750
|
+
return "sudo apt-get install libreadstat-dev && pip install pyreadstat"
|
|
751
|
+
elif self.system == "darwin":
|
|
752
|
+
return "brew install readstat && pip install pyreadstat"
|
|
753
|
+
return "Please install libreadstat and pyreadstat manually"
|
|
754
|
+
|
|
755
|
+
def _get_excel_system_deps_command(self) -> str:
|
|
756
|
+
"""Get Excel system dependencies installation command."""
|
|
757
|
+
if self.system == "linux":
|
|
758
|
+
return "sudo apt-get install libxml2-dev libxslt1-dev"
|
|
759
|
+
elif self.system == "darwin":
|
|
760
|
+
return "brew install libxml2 libxslt"
|
|
761
|
+
return "Please install XML processing libraries manually"
|
|
762
|
+
|
|
763
|
+
def _get_weasyprint_install_command(self) -> str:
|
|
764
|
+
"""Get WeasyPrint installation command."""
|
|
765
|
+
if self.system == "linux":
|
|
766
|
+
return "sudo apt-get install libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libffi-dev shared-mime-info"
|
|
767
|
+
elif self.system == "darwin":
|
|
768
|
+
return "brew install cairo pango gdk-pixbuf libffi"
|
|
769
|
+
return "Please install WeasyPrint dependencies manually"
|
|
770
|
+
|
|
771
|
+
def _get_matplotlib_system_deps_command(self) -> str:
|
|
772
|
+
"""Get Matplotlib system dependencies installation command."""
|
|
773
|
+
if self.system == "linux":
|
|
774
|
+
return "sudo apt-get install libfreetype6-dev libpng-dev libjpeg-dev libtiff-dev libwebp-dev"
|
|
775
|
+
elif self.system == "darwin":
|
|
776
|
+
return "brew install freetype libpng libjpeg libtiff webp"
|
|
777
|
+
return "Please install image processing libraries manually"
|
|
778
|
+
|
|
779
|
+
def check_all_dependencies(self) -> Dict[str, ToolDependencies]:
|
|
780
|
+
"""Check all tool dependencies."""
|
|
781
|
+
self.logger.info("Starting comprehensive dependency check...")
|
|
782
|
+
|
|
783
|
+
tools = {
|
|
784
|
+
"image": self.check_image_tool_dependencies(),
|
|
785
|
+
"classfire": self.check_classfire_tool_dependencies(),
|
|
786
|
+
"office": self.check_office_tool_dependencies(),
|
|
787
|
+
"stats": self.check_stats_tool_dependencies(),
|
|
788
|
+
"report": self.check_report_tool_dependencies(),
|
|
789
|
+
"scraper": self.check_scraper_tool_dependencies(),
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
return tools
|
|
793
|
+
|
|
794
|
+
def generate_report(self, tools: Dict[str, ToolDependencies]) -> str:
|
|
795
|
+
"""Generate a comprehensive dependency report."""
|
|
796
|
+
report = []
|
|
797
|
+
report.append("=" * 80)
|
|
798
|
+
report.append("AIECS DEPENDENCY CHECK REPORT")
|
|
799
|
+
report.append("=" * 80)
|
|
800
|
+
report.append(f"System: {self.system.title()} {self.architecture}")
|
|
801
|
+
report.append(f"Python: {self.python_version}")
|
|
802
|
+
report.append(f"Package Manager: {self.get_system_package_manager()}")
|
|
803
|
+
report.append("")
|
|
804
|
+
|
|
805
|
+
total_issues = 0
|
|
806
|
+
critical_issues = 0
|
|
807
|
+
|
|
808
|
+
for tool_name, tool_deps in tools.items():
|
|
809
|
+
report.append(f"š§ {tool_deps.tool_name.upper()}")
|
|
810
|
+
report.append("-" * 40)
|
|
811
|
+
|
|
812
|
+
# System dependencies
|
|
813
|
+
if tool_deps.system_deps:
|
|
814
|
+
report.append("š¦ System Dependencies:")
|
|
815
|
+
for dep in tool_deps.system_deps:
|
|
816
|
+
status_icon = (
|
|
817
|
+
"ā
"
|
|
818
|
+
if dep.status == DependencyStatus.AVAILABLE
|
|
819
|
+
else "ā" if dep.is_critical else "ā ļø"
|
|
820
|
+
)
|
|
821
|
+
report.append(f" {status_icon} {dep.name}: {dep.status.value}")
|
|
822
|
+
if dep.status != DependencyStatus.AVAILABLE:
|
|
823
|
+
total_issues += 1
|
|
824
|
+
if dep.is_critical:
|
|
825
|
+
critical_issues += 1
|
|
826
|
+
if dep.install_command:
|
|
827
|
+
report.append(f" Install: {dep.install_command}")
|
|
828
|
+
if dep.impact:
|
|
829
|
+
report.append(f" Impact: {dep.impact}")
|
|
830
|
+
report.append("")
|
|
831
|
+
|
|
832
|
+
# Python dependencies
|
|
833
|
+
if tool_deps.python_deps:
|
|
834
|
+
report.append("š Python Dependencies:")
|
|
835
|
+
for dep in tool_deps.python_deps:
|
|
836
|
+
status_icon = "ā
" if dep.status == DependencyStatus.AVAILABLE else "ā"
|
|
837
|
+
report.append(f" {status_icon} {dep.name}: {dep.status.value}")
|
|
838
|
+
if dep.status != DependencyStatus.AVAILABLE:
|
|
839
|
+
total_issues += 1
|
|
840
|
+
critical_issues += 1
|
|
841
|
+
if dep.install_command:
|
|
842
|
+
report.append(f" Install: {dep.install_command}")
|
|
843
|
+
if dep.impact:
|
|
844
|
+
report.append(f" Impact: {dep.impact}")
|
|
845
|
+
report.append("")
|
|
846
|
+
|
|
847
|
+
# Model dependencies
|
|
848
|
+
if tool_deps.model_deps:
|
|
849
|
+
report.append("š¤ Model Dependencies:")
|
|
850
|
+
for dep in tool_deps.model_deps:
|
|
851
|
+
status_icon = (
|
|
852
|
+
"ā
"
|
|
853
|
+
if dep.status == DependencyStatus.AVAILABLE
|
|
854
|
+
else "ā" if dep.is_critical else "ā ļø"
|
|
855
|
+
)
|
|
856
|
+
report.append(f" {status_icon} {dep.name}: {dep.status.value}")
|
|
857
|
+
if dep.status != DependencyStatus.AVAILABLE:
|
|
858
|
+
total_issues += 1
|
|
859
|
+
if dep.is_critical:
|
|
860
|
+
critical_issues += 1
|
|
861
|
+
if dep.install_command:
|
|
862
|
+
report.append(f" Install: {dep.install_command}")
|
|
863
|
+
if dep.impact:
|
|
864
|
+
report.append(f" Impact: {dep.impact}")
|
|
865
|
+
report.append("")
|
|
866
|
+
|
|
867
|
+
# Optional dependencies
|
|
868
|
+
if tool_deps.optional_deps:
|
|
869
|
+
report.append("š§ Optional Dependencies:")
|
|
870
|
+
for dep in tool_deps.optional_deps:
|
|
871
|
+
status_icon = "ā
" if dep.status == DependencyStatus.AVAILABLE else "ā ļø"
|
|
872
|
+
report.append(f" {status_icon} {dep.name}: {dep.status.value}")
|
|
873
|
+
if dep.status != DependencyStatus.AVAILABLE and dep.install_command:
|
|
874
|
+
report.append(f" Install: {dep.install_command}")
|
|
875
|
+
report.append("")
|
|
876
|
+
|
|
877
|
+
# Summary
|
|
878
|
+
report.append("=" * 80)
|
|
879
|
+
report.append("SUMMARY")
|
|
880
|
+
report.append("=" * 80)
|
|
881
|
+
report.append(f"Total Issues: {total_issues}")
|
|
882
|
+
report.append(f"Critical Issues: {critical_issues}")
|
|
883
|
+
report.append(f"Optional Issues: {total_issues - critical_issues}")
|
|
884
|
+
|
|
885
|
+
if critical_issues == 0:
|
|
886
|
+
report.append("")
|
|
887
|
+
report.append("š All critical dependencies are available!")
|
|
888
|
+
report.append("AIECS is ready to use with full functionality.")
|
|
889
|
+
else:
|
|
890
|
+
report.append("")
|
|
891
|
+
report.append("ā ļø Some critical dependencies are missing.")
|
|
892
|
+
report.append("Please install the missing dependencies to enable full functionality.")
|
|
893
|
+
|
|
894
|
+
return "\n".join(report)
|
|
895
|
+
|
|
896
|
+
def save_report(self, report: str, filename: str = "dependency_report.txt"):
|
|
897
|
+
"""Save the report to a file."""
|
|
898
|
+
with open(filename, "w", encoding="utf-8") as f:
|
|
899
|
+
f.write(report)
|
|
900
|
+
self.logger.info(f"Report saved to {filename}")
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
def main():
|
|
904
|
+
"""Main function."""
|
|
905
|
+
checker = DependencyChecker()
|
|
906
|
+
|
|
907
|
+
print("š Checking AIECS dependencies...")
|
|
908
|
+
print("This may take a few minutes for model checks...")
|
|
909
|
+
print()
|
|
910
|
+
|
|
911
|
+
# Check all dependencies
|
|
912
|
+
tools = checker.check_all_dependencies()
|
|
913
|
+
|
|
914
|
+
# Generate and display report
|
|
915
|
+
report = checker.generate_report(tools)
|
|
916
|
+
print(report)
|
|
917
|
+
|
|
918
|
+
# Save report
|
|
919
|
+
checker.save_report(report)
|
|
920
|
+
|
|
921
|
+
# Return exit code based on critical issues
|
|
922
|
+
critical_issues = sum(
|
|
923
|
+
1
|
|
924
|
+
for tool_deps in tools.values()
|
|
925
|
+
for dep in tool_deps.system_deps + tool_deps.python_deps + tool_deps.model_deps
|
|
926
|
+
if dep.status != DependencyStatus.AVAILABLE and dep.is_critical
|
|
927
|
+
)
|
|
928
|
+
|
|
929
|
+
if critical_issues == 0:
|
|
930
|
+
print("\nā
All critical dependencies are available!")
|
|
931
|
+
return 0
|
|
932
|
+
else:
|
|
933
|
+
print(f"\nā {critical_issues} critical dependencies are missing.")
|
|
934
|
+
return 1
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
if __name__ == "__main__":
|
|
938
|
+
sys.exit(main())
|