Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,69 @@
|
|
| 1 |
# app.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
import json
|
|
|
|
| 1 |
# app.py
|
| 2 |
+
|
| 3 |
+
# app.py (add this at the very top)
|
| 4 |
+
|
| 5 |
+
import subprocess
|
| 6 |
+
import sys
|
| 7 |
+
import os
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
def setup_salt():
|
| 11 |
+
"""Clone and setup SALT library like in Colab."""
|
| 12 |
+
try:
|
| 13 |
+
# Check if salt is already available
|
| 14 |
+
import salt.dataset
|
| 15 |
+
print("β
SALT library already available")
|
| 16 |
+
return True
|
| 17 |
+
except ImportError:
|
| 18 |
+
pass
|
| 19 |
+
|
| 20 |
+
print("π₯ Setting up SALT library...")
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
# Clone SALT repo if not exists
|
| 24 |
+
salt_dir = Path("salt")
|
| 25 |
+
if not salt_dir.exists():
|
| 26 |
+
print("π Cloning SALT repository...")
|
| 27 |
+
subprocess.check_call([
|
| 28 |
+
"git", "clone", "https://github.com/sunbirdai/salt.git"
|
| 29 |
+
])
|
| 30 |
+
else:
|
| 31 |
+
print("π SALT repository already exists")
|
| 32 |
+
|
| 33 |
+
# Install SALT requirements
|
| 34 |
+
salt_requirements = salt_dir / "requirements.txt"
|
| 35 |
+
if salt_requirements.exists():
|
| 36 |
+
print("π¦ Installing SALT requirements...")
|
| 37 |
+
subprocess.check_call([
|
| 38 |
+
sys.executable, "-m", "pip", "install", "-q", "-r", str(salt_requirements)
|
| 39 |
+
])
|
| 40 |
+
|
| 41 |
+
# Add SALT directory to Python path
|
| 42 |
+
salt_path = str(salt_dir.absolute())
|
| 43 |
+
if salt_path not in sys.path:
|
| 44 |
+
sys.path.insert(0, salt_path)
|
| 45 |
+
print(f"π Added {salt_path} to Python path")
|
| 46 |
+
|
| 47 |
+
# Test import
|
| 48 |
+
import salt.dataset
|
| 49 |
+
print("β
SALT library setup completed successfully")
|
| 50 |
+
return True
|
| 51 |
+
|
| 52 |
+
except Exception as e:
|
| 53 |
+
print(f"β Failed to setup SALT: {e}")
|
| 54 |
+
return False
|
| 55 |
+
|
| 56 |
+
# Setup SALT on startup
|
| 57 |
+
print("π Starting SALT Translation Leaderboard...")
|
| 58 |
+
if not setup_salt():
|
| 59 |
+
print("β Cannot continue without SALT library")
|
| 60 |
+
print("π‘ Please check that git is available and GitHub is accessible")
|
| 61 |
+
sys.exit(1)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
import gradio as gr
|
| 68 |
import pandas as pd
|
| 69 |
import json
|