#!/usr/bin/env python3 """ Force refresh dashboard model states to show correct DQN status """ import sys import os import requests import time sys.path.append('.') def force_refresh_dashboard(): """Force refresh the dashboard to show correct model states""" print("=== Forcing Dashboard Refresh ===") # Try to hit the dashboard endpoint to force a refresh dashboard_url = "http://localhost:8050" try: print(f"Attempting to refresh dashboard at {dashboard_url}...") # Try to access the main dashboard page response = requests.get(dashboard_url, timeout=5) if response.status_code == 200: print("✅ Dashboard is accessible and responding") else: print(f"⚠️ Dashboard responded with status code: {response.status_code}") # Try to access the model states API endpoint if it exists try: api_response = requests.get(f"{dashboard_url}/api/model-states", timeout=5) if api_response.status_code == 200: print("✅ Model states API is accessible") else: print(f"⚠️ Model states API responded with: {api_response.status_code}") except: print("ℹ️ No model states API endpoint found (this is normal)") except requests.exceptions.ConnectionError: print("❌ Dashboard is not running or not accessible") print("Please start the dashboard with: python run_clean_dashboard.py") except Exception as e: print(f"❌ Error accessing dashboard: {e}") # Also verify the model states are correct print("\n=== Verifying Model States ===") try: from core.orchestrator import TradingOrchestrator from core.data_provider import DataProvider dp = DataProvider() orch = TradingOrchestrator(data_provider=dp) states = orch.get_model_states() if states and 'dqn' in states: dqn_state = states['dqn'] checkpoint_loaded = dqn_state.get('checkpoint_loaded', False) checkpoint_filename = dqn_state.get('checkpoint_filename', 'None') print(f"✅ DQN checkpoint_loaded: {checkpoint_loaded}") print(f"✅ DQN checkpoint_filename: {checkpoint_filename}") if checkpoint_loaded: print("🎯 DQN should show as ACTIVE with [CKPT], not FRESH") else: print("⚠️ DQN checkpoint not loaded - will show as FRESH") else: print("❌ No DQN state found") except Exception as e: print(f"❌ Error verifying model states: {e}") if __name__ == "__main__": force_refresh_dashboard()