-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_installation.py
More file actions
159 lines (136 loc) ยท 5 KB
/
Copy pathtest_installation.py
File metadata and controls
159 lines (136 loc) ยท 5 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
#!/usr/bin/env python3
"""
Test script to verify the regression analyzer installation and basic functionality.
Run this to make sure everything is set up correctly.
"""
import sys
import traceback
def test_imports():
"""Test that all required packages can be imported."""
print("๐ Testing imports...")
try:
import pandas as pd
print("โ
pandas imported successfully")
except ImportError as e:
print(f"โ pandas import failed: {e}")
return False
try:
import numpy as np
print("โ
numpy imported successfully")
except ImportError as e:
print(f"โ numpy import failed: {e}")
return False
try:
import sklearn
print("โ
scikit-learn imported successfully")
except ImportError as e:
print(f"โ scikit-learn import failed: {e}")
return False
try:
from google.adk.agents import Agent
print("โ
Google ADK imported successfully")
except ImportError as e:
print(f"โ Google ADK import failed: {e}")
return False
return True
def test_agent_creation():
"""Test that the regression analyzer agent can be created."""
print("\n๐ค Testing agent creation...")
try:
from regression_analyzer.agent import root_agent
print(f"โ
Agent created: {root_agent.name}")
print(f" Model: {root_agent.model}")
print(f" Tools: {len(root_agent.tools)} tools available")
return True
except Exception as e:
print(f"โ Agent creation failed: {e}")
traceback.print_exc()
return False
def test_analysis_tools():
"""Test that the analysis tools can be imported and basic functionality works."""
print("\n๐ ๏ธ Testing analysis tools...")
try:
from regression_analyzer.analysis_tools import (
load_and_preprocess_data,
identify_top_factors,
perform_regression_analysis,
generate_formula_and_insights,
create_analysis_summary
)
print("โ
All analysis tools imported successfully")
# Test basic tool functionality with sample data
sample_csv = """feature1,feature2,target
1,2,10
2,4,20
3,6,30
4,8,40
5,10,50"""
result = load_and_preprocess_data(sample_csv, "target")
if result["status"] == "success":
print("โ
Basic data processing test passed")
return True
else:
print(f"โ Basic data processing test failed: {result.get('message', 'Unknown error')}")
return False
except Exception as e:
print(f"โ Analysis tools test failed: {e}")
traceback.print_exc()
return False
def test_environment():
"""Test that the environment is configured for ADK."""
print("\n๐ Testing environment configuration...")
import os
# Check for API key configuration
if os.getenv('GOOGLE_API_KEY'):
print("โ
GOOGLE_API_KEY found in environment")
vertex_ai = os.getenv('GOOGLE_GENAI_USE_VERTEXAI', 'TRUE').upper() == 'FALSE'
print(f"โ
Using Google AI Studio: {vertex_ai}")
return True
elif os.getenv('GOOGLE_CLOUD_PROJECT'):
print("โ
GOOGLE_CLOUD_PROJECT found in environment")
vertex_ai = os.getenv('GOOGLE_GENAI_USE_VERTEXAI', 'FALSE').upper() == 'TRUE'
print(f"โ
Using Vertex AI: {vertex_ai}")
return True
else:
print("โ ๏ธ No Google AI credentials found in environment")
print(" Please set either:")
print(" - GOOGLE_API_KEY (for Google AI Studio)")
print(" - GOOGLE_CLOUD_PROJECT (for Vertex AI)")
return False
def main():
"""Run all tests."""
print("๐งฎ REGRESSION ANALYZER INSTALLATION TEST")
print("=" * 50)
all_passed = True
# Run tests
tests = [
("Package Imports", test_imports),
("Agent Creation", test_agent_creation),
("Analysis Tools", test_analysis_tools),
("Environment Config", test_environment)
]
for test_name, test_func in tests:
try:
passed = test_func()
all_passed = all_passed and passed
except Exception as e:
print(f"โ {test_name} test crashed: {e}")
all_passed = False
print("\n" + "=" * 50)
if all_passed:
print("๐ ALL TESTS PASSED!")
print("Your regression analyzer is ready to use!")
print("\nNext steps:")
print("1. Run the demo: python demo.py")
print("2. Launch web UI: adk web")
print("3. Use CLI: adk run .")
return 0
else:
print("โ SOME TESTS FAILED")
print("Please check the error messages above and:")
print("1. Make sure all dependencies are installed: pip install -r requirements.txt")
print("2. Set up your Google AI credentials (see README.md)")
print("3. Install the package: pip install -e .")
return 1
if __name__ == "__main__":
sys.exit(main())