26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
"""Debug: test _save_features_to_db with existing store data"""
|
|
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()
|
|
|
|
from analysis.session_store import SessionStore
|
|
from analysis.tool_registry import _save_features_to_db
|
|
|
|
store = SessionStore()
|
|
print(f'Store entries: {len(store._stores)}')
|
|
for k, v in list(store._stores.items())[:5]:
|
|
entry_type = v.get('type')
|
|
if entry_type == 'cluster_result':
|
|
cid = k
|
|
print(f' cluster_result: {cid}, n_clusters={v.get("n_clusters")}')
|
|
print(f' parent_dataset_id={v.get("parent_dataset_id")}')
|
|
|
|
# Try saving
|
|
result = _save_features_to_db(cid, [{
|
|
'feature_name': 'test_feature', 'cluster_label': 0,
|
|
'mean': 1.0, 'std': 0.5, 'global_mean': 0.5, 'global_std': 0.3,
|
|
'distinguishing_score': 2.0, 'distinguishing_method': 'zscore'
|
|
}])
|
|
print(f' _save_features_to_db returned: {result}')
|