25 lines
1022 B
Python
25 lines
1022 B
Python
"""Test profile_data fix"""
|
|
import sys, os
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'tianxuan.settings'
|
|
import django; django.setup()
|
|
import asyncio
|
|
from analysis.session_store import SessionStore
|
|
from analysis.data_loader import load_csv_directory
|
|
from analysis.tool_registry import handle_call
|
|
|
|
store = SessionStore()
|
|
store.drop_all()
|
|
csv = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', 'complex_test.csv')
|
|
lf, schema, rc, fc, mem = load_csv_directory(csv)
|
|
store.store_dataset('ds', lf, schema=schema, metadata={'row_count': rc, 'csv_glob': csv})
|
|
|
|
result = asyncio.run(handle_call('profile_data', {'dataset_id': 'ds'}))
|
|
if 'error' in result:
|
|
print(f'FAIL: {result["error"]}')
|
|
else:
|
|
cols = result.get('column_stats', {})
|
|
print(f'OK: {len(cols)} columns profiled')
|
|
for name, stats in list(cols.items())[:3]:
|
|
print(f' {name}: dtype={stats.get("dtype")} mean={stats.get("mean","-")}')
|