rename fix and build fixes

This commit is contained in:
Dobromir Popov
2025-10-18 16:46:23 +03:00
parent a520ed7e39
commit 3d91cb0e8f
7 changed files with 100 additions and 69 deletions

View File

@@ -31,9 +31,9 @@ except ImportError as e:
TradingOrchestrator = None
get_config = lambda: {}
# Import TESTCASES modules
testcases_dir = Path(__file__).parent.parent
sys.path.insert(0, str(testcases_dir))
# Import ANNOTATE modules
annotate_dir = Path(__file__).parent.parent
sys.path.insert(0, str(annotate_dir))
try:
from core.annotation_manager import AnnotationManager
@@ -45,7 +45,7 @@ except ImportError:
# Load annotation_manager
ann_spec = importlib.util.spec_from_file_location(
"annotation_manager",
testcases_dir / "core" / "annotation_manager.py"
annotate_dir / "core" / "annotation_manager.py"
)
ann_module = importlib.util.module_from_spec(ann_spec)
ann_spec.loader.exec_module(ann_module)
@@ -54,7 +54,7 @@ except ImportError:
# Load training_simulator
train_spec = importlib.util.spec_from_file_location(
"training_simulator",
testcases_dir / "core" / "training_simulator.py"
annotate_dir / "core" / "training_simulator.py"
)
train_module = importlib.util.module_from_spec(train_spec)
train_spec.loader.exec_module(train_module)
@@ -82,7 +82,7 @@ class AnnotationDashboard:
static_folder='static'
)
# Initialize Dash app
# Initialize Dash app (optional component)
self.app = Dash(
__name__,
server=self.server,
@@ -93,13 +93,23 @@ class AnnotationDashboard:
]
)
# Set a simple Dash layout to avoid NoLayoutException
self.app.layout = html.Div([
html.H1("ANNOTATE Dashboard", className="text-center mb-4"),
html.Div([
html.P("This is the Dash component of the ANNOTATE system."),
html.P("The main interface is available at the Flask routes."),
html.A("Go to Main Interface", href="/", className="btn btn-primary")
], className="container")
])
# Initialize core components
self.data_provider = DataProvider() if DataProvider else None
self.orchestrator = TradingOrchestrator(
data_provider=self.data_provider
) if TradingOrchestrator and self.data_provider else None
# Initialize TESTCASES components
# Initialize ANNOTATE components
self.annotation_manager = AnnotationManager()
self.training_simulator = TrainingSimulator(self.orchestrator) if self.orchestrator else None
@@ -114,18 +124,65 @@ class AnnotationDashboard:
@self.server.route('/')
def index():
"""Main dashboard page"""
# Get current annotations
annotations = self.annotation_manager.get_annotations()
# Prepare template data
template_data = {
'current_symbol': 'ETH/USDT',
'timeframes': ['1s', '1m', '1h', '1d'],
'annotations': [ann.__dict__ if hasattr(ann, '__dict__') else ann
for ann in annotations]
}
return render_template('annotation_dashboard.html', **template_data)
try:
# Get current annotations
annotations = self.annotation_manager.get_annotations()
# Prepare template data
template_data = {
'current_symbol': 'ETH/USDT',
'timeframes': ['1s', '1m', '1h', '1d'],
'annotations': [ann.__dict__ if hasattr(ann, '__dict__') else ann
for ann in annotations]
}
return render_template('annotation_dashboard.html', **template_data)
except Exception as e:
logger.error(f"Error rendering main page: {e}")
# Fallback simple HTML page
return f"""
<html>
<head>
<title>ANNOTATE - Manual Trade Annotation UI</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h1 class="text-center">📝 ANNOTATE - Manual Trade Annotation UI</h1>
<div class="alert alert-info">
<h4>System Status</h4>
<p>✅ Annotation Manager: Active</p>
<p>⚠️ Data Provider: {'Available' if self.data_provider else 'Not Available (Standalone Mode)'}</p>
<p>⚠️ Trading Orchestrator: {'Available' if self.orchestrator else 'Not Available (Standalone Mode)'}</p>
</div>
<div class="row">
<div class="col-md-6">
<h3>Available Features</h3>
<ul>
<li>Manual trade annotation</li>
<li>Test case generation</li>
<li>Annotation export</li>
<li>Training simulation</li>
</ul>
</div>
<div class="col-md-6">
<h3>API Endpoints</h3>
<ul>
<li><code>POST /api/chart-data</code> - Get chart data</li>
<li><code>POST /api/save-annotation</code> - Save annotation</li>
<li><code>POST /api/delete-annotation</code> - Delete annotation</li>
<li><code>POST /api/generate-test-case</code> - Generate test case</li>
<li><code>POST /api/export-annotations</code> - Export annotations</li>
</ul>
</div>
</div>
<div class="text-center mt-4">
<a href="/dash/" class="btn btn-primary">Go to Dash Interface</a>
</div>
</div>
</body>
</html>
"""
@self.server.route('/api/chart-data', methods=['POST'])
def get_chart_data():