Mizan / app.py
nmmursit's picture
Refactor codebase structure
bc37111
#!/usr/bin/env python3
"""
Mizan Turkish Leaderboard - HuggingFace Space Version
Clean entry point that wires together all components.
"""
import logging
import sys
import gradio as gr
from src.core.config import settings
from src.data import DataTransformer
from src.components import LeaderboardTab, DatasetTab, SubmitTab
# Configure logging
logging.basicConfig(
level=logging.DEBUG if settings.ui.debug else logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout),
]
)
logger = logging.getLogger(__name__)
class MizanApp:
"""
Main application class.
Orchestrates all components and creates the Gradio interface.
"""
def __init__(self):
# Load data
self.transformer = DataTransformer()
self.data = self.transformer.load_from_csv()
# UI components (will be initialized during build)
self._leaderboard_tab: LeaderboardTab = None
self._dataset_tab: DatasetTab = None
self._submit_tab: SubmitTab = None
logger.info(f"Application initialized with {len(self.data)} models")
def build_interface(self) -> gr.Blocks:
"""
Build the complete Gradio interface.
Returns:
Gradio Blocks application.
"""
with gr.Blocks(
title="๐Ÿ‡น๐Ÿ‡ท Mizan Turkish Leaderboard",
theme=gr.themes.Soft()
) as demo:
# Header
gr.Markdown("""
# ๐Ÿ‡น๐Ÿ‡ท Mizan Turkish Evaluation Leaderboard
Performance comparison for Turkish embedding models
""")
with gr.Tabs():
# Tab 1: Leaderboard
with gr.Tab("Leaderboard"):
self._leaderboard_tab = LeaderboardTab(data=self.data)
self._leaderboard_tab.build()
# Tab 2: Submit
with gr.Tab("Submit"):
self._submit_tab = SubmitTab()
self._submit_tab.build()
# Tab 3: Dataset Information
with gr.Tab("Dataset Information"):
self._dataset_tab = DatasetTab()
self._dataset_tab.build()
return demo
def run(self):
"""Run the application."""
logger.info("Starting Mizan Turkish Leaderboard...")
# Build and launch
demo = self.build_interface()
demo.launch(
server_name="0.0.0.0",
server_port=settings.ui.port,
share=False
)
def main():
"""Main entry point."""
app = MizanApp()
app.run()
if __name__ == "__main__":
main()