training wip
This commit is contained in:
@@ -926,33 +926,44 @@ class CleanTradingDashboard:
|
||||
return html.P(f"Error: {str(e)}", className="text-danger")
|
||||
|
||||
@self.app.callback(
|
||||
Output('training-status', 'children'),
|
||||
[Output('training-status', 'children'),
|
||||
Output('training-status', 'className')],
|
||||
[Input('start-training-btn', 'n_clicks'),
|
||||
Input('stop-training-btn', 'n_clicks')],
|
||||
prevent_initial_call=True
|
||||
Input('stop-training-btn', 'n_clicks'),
|
||||
Input('interval-component', 'n_intervals')], # Auto-update on interval
|
||||
prevent_initial_call=False # Allow initial call to set status
|
||||
)
|
||||
def control_training(start_clicks, stop_clicks):
|
||||
def control_training(start_clicks, stop_clicks, n_intervals):
|
||||
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
|
||||
)
|
||||
# Use orchestrator's enhanced training system directly
|
||||
if not hasattr(self.orchestrator, 'enhanced_training_system') or not self.orchestrator.enhanced_training_system:
|
||||
return "Not Available", "badge bg-danger small"
|
||||
|
||||
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'
|
||||
|
||||
# Check if this is triggered by button clicks
|
||||
if ctx.triggered:
|
||||
trigger_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
||||
if trigger_id == 'start-training-btn':
|
||||
self.orchestrator.start_enhanced_training()
|
||||
return 'Running', 'badge bg-success small'
|
||||
elif trigger_id == 'stop-training-btn':
|
||||
self.orchestrator.stop_enhanced_training()
|
||||
return 'Stopped', 'badge bg-warning small'
|
||||
|
||||
# Auto-update: Check actual training status
|
||||
if hasattr(self.orchestrator.enhanced_training_system, 'is_training'):
|
||||
if self.orchestrator.enhanced_training_system.is_training:
|
||||
return 'Running', 'badge bg-success small'
|
||||
else:
|
||||
return 'Idle', 'badge bg-secondary small'
|
||||
else:
|
||||
# Default to Running since training auto-starts
|
||||
return 'Running', 'badge bg-success small'
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Training control error: {e}")
|
||||
return 'Error'
|
||||
logger.error(f"Training status error: {e}")
|
||||
return 'Error', 'badge bg-danger small'
|
||||
|
||||
@self.app.callback(
|
||||
[Output('eth-cob-content', 'children'),
|
||||
|
||||
@@ -173,7 +173,7 @@ class DashboardLayoutManager:
|
||||
], className="d-flex align-items-center mb-1"),
|
||||
html.Div([
|
||||
html.Span("Training:", className="small me-1"),
|
||||
html.Span(id="training-status", children="Idle", className="badge bg-secondary small")
|
||||
html.Span(id="training-status", children="Starting...", className="badge bg-primary small")
|
||||
])
|
||||
], className="mb-2"),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user