dash and training wip
This commit is contained in:
@@ -642,6 +642,35 @@ class CleanTradingDashboard:
|
||||
logger.error(f"Error updating trades table: {e}")
|
||||
return html.P(f"Error: {str(e)}", className="text-danger")
|
||||
|
||||
@self.app.callback(
|
||||
Output('training-status', 'children'),
|
||||
[Input('start-training-btn', 'n_clicks'),
|
||||
Input('stop-training-btn', 'n_clicks')],
|
||||
prevent_initial_call=True
|
||||
)
|
||||
def control_training(start_clicks, stop_clicks):
|
||||
try:
|
||||
from utils.training_integration import get_unified_training_manager
|
||||
manager = get_unified_training_manager(
|
||||
orchestrator=self.orchestrator,
|
||||
data_provider=self.data_provider,
|
||||
dashboard=self
|
||||
)
|
||||
ctx = dash.callback_context
|
||||
if not ctx.triggered:
|
||||
raise PreventUpdate
|
||||
trigger_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
||||
if trigger_id == 'start-training-btn':
|
||||
ok = manager.start()
|
||||
return 'Running' if ok else 'Error'
|
||||
elif trigger_id == 'stop-training-btn':
|
||||
ok = manager.stop()
|
||||
return 'Stopped' if ok else 'Error'
|
||||
return 'Idle'
|
||||
except Exception as e:
|
||||
logger.error(f"Training control error: {e}")
|
||||
return 'Error'
|
||||
|
||||
@self.app.callback(
|
||||
[Output('eth-cob-content', 'children'),
|
||||
Output('btc-cob-content', 'children')],
|
||||
@@ -5215,7 +5244,12 @@ class CleanTradingDashboard:
|
||||
"""Start the Dash server"""
|
||||
try:
|
||||
logger.info(f"TRADING: Starting Clean Dashboard at http://{host}:{port}")
|
||||
self.app.run(host=host, port=port, debug=debug)
|
||||
# Run the Dash app normally; launch/activation is handled by the runner
|
||||
if hasattr(self, 'app') and self.app is not None:
|
||||
# Dash 3.x: use app.run
|
||||
self.app.run(host=host, port=port, debug=debug)
|
||||
else:
|
||||
logger.error("Dash app is not initialized")
|
||||
except Exception as e:
|
||||
logger.error(f"Error starting dashboard server: {e}")
|
||||
raise
|
||||
|
Reference in New Issue
Block a user