#!/usr/bin/env python3 """ Launch script for the NL→SQL Leaderboard """ import os import sys import subprocess from pathlib import Path def check_requirements(): """Check if all requirements are installed.""" try: import gradio import pandas import duckdb import sqlglot import yaml print("✓ All required packages are installed") return True except ImportError as e: print(f"✗ Missing required package: {e}") print("Please install requirements: pip install -r requirements.txt") return False def check_config(): """Check if configuration files exist.""" required_files = [ "config/models.yaml", "prompts/template_presto.txt", "prompts/template_bigquery.txt", "prompts/template_snowflake.txt", "tasks/nyc_taxi_small/schema.sql", "tasks/nyc_taxi_small/loader.py", "tasks/nyc_taxi_small/cases.yaml" ] missing_files = [] for file_path in required_files: if not os.path.exists(file_path): missing_files.append(file_path) if missing_files: print("✗ Missing required files:") for file_path in missing_files: print(f" - {file_path}") return False else: print("✓ All configuration files are present") return True def main(): """Main launch function.""" print("NL→SQL Leaderboard Launcher") print("=" * 40) # Check requirements if not check_requirements(): sys.exit(1) # Check configuration if not check_config(): sys.exit(1) # Check for API keys and model configuration has_hf_token = bool(os.getenv("HF_TOKEN")) if has_hf_token: print("🔑 HF_TOKEN detected - using Hugging Face model APIs") else: print("🏠 No HF_TOKEN detected - using local models") print(" Models will be downloaded and run locally") print("\n🚀 Starting the NL→SQL Leaderboard...") print("The app will be available at: http://localhost:7860") print("Press Ctrl+C to stop the server") print("-" * 40) # Launch the app try: from app import create_interface app = create_interface() app.launch( server_name="0.0.0.0", server_port=7860, share=False, # Set to True for public sharing show_error=True ) except KeyboardInterrupt: print("\n👋 Shutting down the NL→SQL Leaderboard...") except Exception as e: print(f"\n❌ Error launching the app: {e}") sys.exit(1) if __name__ == "__main__": main()