-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_code_execution.py
More file actions
61 lines (50 loc) · 1.75 KB
/
test_code_execution.py
File metadata and controls
61 lines (50 loc) · 1.75 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
#!/usr/bin/env python3
"""
Test script to verify the code execution fix
"""
import requests
import json
import pandas as pd
def test_code_execution():
"""Test the code execution with a simple standardization task"""
# Create sample data
data = {
'A': [1, 2, 3, 4, 5],
'B': [10, 20, 30, 40, 50],
'C': [100, 200, 300, 400, 500]
}
df = pd.DataFrame(data)
# Convert to CSV
csv_data = df.to_csv(index=False)
# Test request
request_data = {
"user_prompt": "Standardize all numeric columns to have mean 0 and standard deviation 1",
"csv_data": csv_data,
"filename": "test_data.csv"
}
try:
response = requests.post(
"http://localhost:8000/process",
json=request_data,
timeout=30
)
if response.status_code == 200:
result = response.json()
print("✅ Request successful!")
print(f"Response: {result.get('response', 'No response')[:200]}...")
if result.get('updated_df'):
print("✅ DataFrame was updated successfully")
else:
print("❌ DataFrame was not updated")
if result.get('code'):
print(f"Generated code:\n{result.get('code')}")
else:
print("❌ No code was generated")
else:
print(f"❌ Request failed with status {response.status_code}")
print(f"Error: {response.text}")
except requests.exceptions.RequestException as e:
print(f"❌ Request failed: {e}")
if __name__ == "__main__":
print("🧪 Testing code execution fix...")
test_code_execution()