-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_setup.py
More file actions
executable file
·228 lines (198 loc) · 7.11 KB
/
Copy pathtest_setup.py
File metadata and controls
executable file
·228 lines (198 loc) · 7.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/usr/bin/env python3
"""
Configuration Test Script
This script verifies that your Agent Blackboard environment is properly configured.
Run this before executing any workflows to ensure everything is set up correctly.
Usage:
python test_setup.py
"""
import os
import sys
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent / "src"))
def check_python_version():
"""Check Python version is 3.9+"""
version = sys.version_info
if version.major < 3 or (version.major == 3 and version.minor < 9):
print("❌ Python 3.9+ required")
print(f" Current version: {version.major}.{version.minor}.{version.micro}")
return False
print(f"✅ Python version: {version.major}.{version.minor}.{version.micro}")
return True
def check_dotenv():
"""Check if python-dotenv is available and load .env"""
try:
from dotenv import load_dotenv
load_dotenv()
print("✅ python-dotenv loaded")
return True
except ImportError:
print("⚠️ python-dotenv not installed (optional)")
print(" Install with: pip install python-dotenv")
return True # Not critical
def check_api_key():
"""Check Anthropic API key"""
api_key = os.getenv("ANTHROPIC_API_KEY")
if not api_key:
print("❌ ANTHROPIC_API_KEY: Not found")
print("\n" + "="*60)
print("Please set your Anthropic API key:")
print("="*60)
print("\nOption 1: Create .env file in project root:")
print(' echo "ANTHROPIC_API_KEY=sk-ant-your-key-here" > .env')
print("\nOption 2: Export environment variable:")
print(' export ANTHROPIC_API_KEY="sk-ant-your-key-here"')
print("\nGet your API key at: https://console.anthropic.com")
print("="*60)
return False
# Validate key format
if not api_key.startswith("sk-ant-"):
print(f"⚠️ ANTHROPIC_API_KEY: Invalid format (should start with 'sk-ant-')")
print(f" Current value: {api_key[:20]}...")
return False
print(f"✅ ANTHROPIC_API_KEY: {api_key[:20]}...{api_key[-4:]}")
return True
def check_dependencies():
"""Check required Python packages"""
required_packages = {
"anthropic": "Anthropic API client",
"pydantic": "Data validation",
"asyncio": "Async support (built-in)",
}
missing = []
for package, description in required_packages.items():
try:
if package == "asyncio":
import asyncio
else:
__import__(package)
print(f"✅ {package}: Installed ({description})")
except ImportError:
print(f"❌ {package}: Not installed ({description})")
missing.append(package)
if missing:
print(f"\n❌ Missing packages: {', '.join(missing)}")
print(f" Install with: pip install {' '.join(missing)}")
return False
return True
def check_optional_config():
"""Check optional configuration"""
configs = {
"LOG_LEVEL": ("INFO", "Logging verbosity"),
"MCP_MEMORY_SERVER_PATH": ("./mcp_servers/memory", "MCP server path"),
"EMBEDDING_MODEL": ("all-MiniLM-L6-v2", "Embedding model"),
"BLACKBOARD_PERSISTENCE": ("sqlite", "Persistence backend"),
"BLACKBOARD_DB_PATH": ("./data/blackboard.db", "Database path"),
}
print("\nOptional Configuration:")
for key, (default, description) in configs.items():
value = os.getenv(key, default)
print(f" {key}: {value}")
print(f" ({description})")
def check_directories():
"""Check and create necessary directories"""
dirs = [
"data",
"output",
"mcp_servers/memory",
]
print("\nDirectory Structure:")
for dir_path in dirs:
path = Path(dir_path)
if path.exists():
print(f"✅ {dir_path}/: Exists")
else:
print(f"⚠️ {dir_path}/: Creating...")
path.mkdir(parents=True, exist_ok=True)
print(f"✅ {dir_path}/: Created")
def check_env_file():
"""Check if .env file exists"""
env_path = Path(".env")
if env_path.exists():
print("✅ .env file: Found")
# Check if it contains API key
content = env_path.read_text()
if "ANTHROPIC_API_KEY" in content:
print(" Contains ANTHROPIC_API_KEY configuration")
else:
print("⚠️ .env file exists but missing ANTHROPIC_API_KEY")
return True
else:
print("⚠️ .env file: Not found (using environment variables)")
return False
def test_import_core():
"""Test importing core modules"""
print("\nTesting Core Imports:")
modules = [
("agent_blackboard.core.blackboard", "Blackboard"),
("agent_blackboard.core.coordinator", "Coordinator"),
("agent_blackboard.core.ontology", "Ontology"),
]
for module_name, description in modules:
try:
__import__(module_name)
print(f"✅ {module_name}: OK")
except ImportError as e:
print(f"❌ {module_name}: Failed")
print(f" Error: {e}")
return False
return True
def main():
"""Run all configuration checks"""
print("="*60)
print("Agent Blackboard - Configuration Test")
print("="*60)
print()
# Run checks
checks = [
("Python Version", check_python_version),
("python-dotenv", check_dotenv),
(".env File", check_env_file),
("API Key", check_api_key),
("Dependencies", check_dependencies),
("Core Imports", test_import_core),
]
results = []
for name, check_func in checks:
print(f"\n--- {name} ---")
try:
result = check_func()
results.append((name, result))
except Exception as e:
print(f"❌ Error during {name} check: {e}")
results.append((name, False))
# Optional checks
check_optional_config()
check_directories()
# Summary
print("\n" + "="*60)
print("Configuration Test Summary")
print("="*60)
failed = []
for name, result in results:
status = "✅ PASS" if result else "❌ FAIL"
print(f"{status}: {name}")
if not result:
failed.append(name)
print("="*60)
if not failed:
print("\n🎉 All checks passed!")
print("\nYou're ready to run the workflow:")
print(" python examples/run_ddd_workflow.py")
print("\nOr try other examples:")
print(" python examples/run_ddd_workflow.py healthcare_scheduling")
print(" python examples/run_ddd_workflow.py fintech_lending")
return 0
else:
print(f"\n❌ {len(failed)} check(s) failed:")
for name in failed:
print(f" - {name}")
print("\nPlease fix the issues above and run this test again.")
print("\nFor help, see:")
print(" - QUICK_SETUP.md for API key configuration")
print(" - docs/getting-started.md for installation guide")
print(" - docs/configuration.md for detailed configuration")
return 1
if __name__ == "__main__":
sys.exit(main())