-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathsetup.py
More file actions
174 lines (137 loc) · 4.64 KB
/
Copy pathsetup.py
File metadata and controls
174 lines (137 loc) · 4.64 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
"""
Setup script for AegisGraph Sentinel 2.0
This script helps set up the environment and verify installation
"""
# Working on environment setup and installation
import sys
import subprocess
from pathlib import Path
import importlib.util
def check_python_version():
"""Check if Python version is compatible"""
print("Checking Python version...")
if sys.version_info < (3, 9):
print("❌ Python 3.9+ is required")
print(f" Your version: {sys.version}")
return False
print(f"✓ Python {sys.version.split()[0]}")
return True
def check_dependencies():
"""Check if required packages can be imported"""
print("\nChecking dependencies...")
required_packages = [
('networkx', 'networkx'),
('numpy', 'numpy'),
('pandas', 'pandas'),
('scipy', 'scipy'),
('torch', 'torch'),
('fastapi', 'fastapi'),
('uvicorn', 'uvicorn'),
('pydantic', 'pydantic'),
('PyYAML', 'yaml'),
('python-dotenv', 'dotenv'),
('slowapi', 'slowapi'),
('httpx', 'httpx'),
('pytest', 'pytest'),
('pytest-cov', 'pytest_cov'),
('google-generativeai', 'google.generativeai'),
]
missing = []
for package_name, import_name in required_packages:
spec = importlib.util.find_spec(import_name)
if spec is None:
missing.append(package_name)
print(f"❌ {package_name}")
else:
print(f"✓ {package_name}")
if missing:
print(f"\n⚠ Missing packages: {', '.join(missing)}")
print("Install with: pip install " + " ".join(missing))
return False
return True
def create_directories():
"""Create necessary directories"""
print("\nCreating directories...")
directories = [
'data/synthetic',
'models',
'logs',
'notebooks',
]
for directory in directories:
path = Path(directory)
path.mkdir(parents=True, exist_ok=True)
print(f"✓ {directory}/")
return True
def verify_config():
"""Verify configuration file exists"""
print("\nVerifying configuration...")
config_path = Path('config/config.yaml')
if config_path.exists():
print(f"✓ config/config.yaml found")
return True
else:
print(f"❌ config/config.yaml not found")
return False
def run_tests():
"""Run basic import tests"""
print("\nRunning import tests...")
try:
from src.models.htgat import HTGAT
print("✓ HTGAT model")
from src.models.risk_model import FraudDetectionModel
print("✓ FraudDetectionModel")
from src.features.behavioral_biometrics import KeystrokeDynamicsAnalyzer
print("✓ Behavioral biometrics")
from src.inference.risk_scorer import RiskScorer
print("✓ Risk scorer")
from src.api.main import app
print("✓ FastAPI app")
return True
except Exception as e:
print(f"❌ Import error: {e}")
return False
def main():
"""Main setup routine"""
print("=" * 80)
print("AegisGraph Sentinel 2.0 - Setup & Verification")
print("=" * 80)
steps = [
("Python version", check_python_version),
("Dependencies", check_dependencies),
("Directories", create_directories),
("Configuration", verify_config),
("Import tests", run_tests),
]
results = []
for name, func in steps:
try:
success = func()
results.append((name, success))
except Exception as e:
print(f"\n❌ Error in {name}: {e}")
results.append((name, False))
# Summary
print("\n" + "=" * 80)
print("Setup Summary")
print("=" * 80)
all_passed = True
for name, success in results:
status = "✓" if success else "❌"
print(f"{status} {name}")
if not success:
all_passed = False
print("=" * 80)
if all_passed:
print("\n🎉 Setup successful! You're ready to use AegisGraph Sentinel 2.0")
print("\nNext steps:")
print("1. Generate synthetic data: python -m src.data.synthetic_data_gen")
print("2. Start API server: uvicorn src.api.main:app --reload")
print("3. Open dashboard: streamlit run app.py")
print("\nDocumentation: http://localhost:8000/docs")
else:
print("\n⚠ Setup incomplete. Please resolve the issues above.")
print("\nFor dependencies, run: pip install -r requirements.txt")
print()
if __name__ == "__main__":
main()