text exporter

This commit is contained in:
Dobromir Popov
2025-08-26 18:16:12 +03:00
parent c39b70f6fa
commit 9a76624904
9 changed files with 658 additions and 106 deletions

View File

@@ -1756,32 +1756,25 @@ class CleanTradingDashboard:
# Original training metrics callback - temporarily disabled for testing
# @self.app.callback(
# Output('training-metrics', 'children'),
# Lightweight, cached training metrics panel
self._training_panel_cache = {"content": None, "ts": 0.0}
self._training_panel_ttl = 3.0 # seconds
@self.app.callback(
Output('training-metrics', 'children'),
[Input('slow-interval-component', 'n_intervals'),
Input('fast-interval-component', 'n_intervals'), # Add fast interval for testing
Input('refresh-training-metrics-btn', 'n_clicks')] # Add manual refresh button
Input('fast-interval-component', 'n_intervals'),
Input('refresh-training-metrics-btn', 'n_clicks')]
)
def update_training_metrics(slow_intervals, fast_intervals, n_clicks):
"""Update training metrics using new clean panel implementation"""
logger.info(f"update_training_metrics callback triggered with slow_intervals={slow_intervals}, fast_intervals={fast_intervals}, n_clicks={n_clicks}")
try:
# Import compact training panel
now_ts = time.time()
# Serve cached panel if fresh
if self._training_panel_cache["content"] is not None and (now_ts - self._training_panel_cache["ts"]) < self._training_panel_ttl:
raise PreventUpdate
from web.models_training_panel import ModelsTrainingPanel
# Create panel instance with orchestrator
panel = ModelsTrainingPanel(orchestrator=self.orchestrator)
# Ensure enhanced training system is initialized and running
try:
if self.orchestrator and hasattr(self.orchestrator, 'initialize_enhanced_training_system'):
self.orchestrator.initialize_enhanced_training_system()
if self.orchestrator and hasattr(self.orchestrator, 'start_enhanced_training'):
self.orchestrator.start_enhanced_training()
except Exception as _ets_ex:
logger.warning(f"TRAINING: Failed to start orchestrator enhanced training system: {_ets_ex}")
# Prefer create_panel if available; fallback to render
if hasattr(panel, 'create_panel'):
panel_content = panel.create_panel()
elif hasattr(panel, 'render'):
@@ -1789,20 +1782,14 @@ class CleanTradingDashboard:
else:
panel_content = [html.Div("Training panel not available", className="text-muted small")]
logger.info("Successfully created training metrics panel")
self._training_panel_cache["content"] = panel_content
self._training_panel_cache["ts"] = now_ts
return panel_content
except PreventUpdate:
logger.info("PreventUpdate raised in training metrics callback")
raise
except Exception as e:
logger.error(f"Error updating training metrics with new panel: {e}")
import traceback
logger.error(f"Traceback: {traceback.format_exc()}")
return [
html.P("Error loading training panel", className="text-danger small"),
html.P(f"Details: {str(e)}", className="text-muted small")
]
logger.debug(f"Error updating training metrics: {e}")
return self._training_panel_cache.get("content") or [html.Div("Training panel unavailable", className="text-muted small")]
# Universal model toggle callback using pattern matching
@self.app.callback(