colony / app.py
Chimera
Redirect to dedicated colony on port 8766, fix Colab worker payload format
9ce22ef
Raw
History Blame Contribute Delete
2.88 kB
import gradio as gr
import requests
import time
from datetime import datetime
VPS_GATEWAY = "http://187.124.226.128:8766"
NOTEBOOK_URL = "https://huggingface.co/spaces/ScottzillaSystems/colony/resolve/main/colony_worker.ipynb"
COLAB_URL = "https://colab.research.google.com/notebook#fileUrl=https%3A%2F%2Fhuggingface.co%2Fspaces%2FScottzillaSystems%2Fcolony%2Fresolve%2Fmain%2Fcolony_worker.ipynb"
def fetch_colony_status():
"""Fetch live colony status from VPS gateway."""
try:
r = requests.get(f"{VPS_GATEWAY}/colony/machines", timeout=5)
data = r.json()
machines = data.get("machines", [])
total = data.get("total", len(machines))
online = sum(1 for m in machines if m.get("status") == "online")
table_data = []
for m in machines:
table_data.append([
m.get("id", "?")[:20],
m.get("gpu", "?"),
f"{m.get('vram', '?')}GB",
"🟒" if m.get("status") == "online" else "πŸ”΄",
str(m.get("last_seen", "never"))[:19],
m.get("ip", "?")
])
return table_data, f"🐝 {online}/{total} Online", f"πŸ–₯️ {total} Total"
except Exception as e:
return [], "πŸ”΄ OFFLINE", f"Error: {str(e)[:60]}"
def refresh():
table, online_text, total_text = fetch_colony_status()
return table, online_text, total_text
with gr.Blocks(title="🐝 Chimera Colony", theme=gr.themes.Soft()) as demo:
gr.Markdown("# 🐝 Chimera Colony Dashboard")
gr.Markdown("Distributed GPU swarm for NSFW inference β€” connect free Colab GPUs to the hive.")
with gr.Row():
online_label = gr.Label(value="πŸ”„ Loading...", label="Status")
total_label = gr.Label(value="πŸ”„ Loading...", label="Fleet")
with gr.Row():
refresh_btn = gr.Button("πŸ”„ Refresh", variant="primary", scale=1)
machines_table = gr.Dataframe(
headers=["Machine ID", "GPU", "VRAM", "Status", "Last Seen", "IP"],
label="Connected Workers",
interactive=False,
row_count=(10, "dynamic")
)
gr.Markdown(f"""
---
### πŸš€ Deploy a New Worker
**Step 1:** [⬇️ Download the notebook]({NOTEBOOK_URL})
**Step 2:** Upload to [Google Colab](https://colab.research.google.com) or click below:
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]({COLAB_URL})
**Step 3:** Run all cells β€” worker auto-registers and appears above within 30 seconds
**Requirements:** Free Google Colab GPU (T4 works great, A100 available on Pro)
""")
refresh_btn.click(fn=refresh, outputs=[machines_table, online_label, total_label])
demo.load(fn=refresh, outputs=[machines_table, online_label, total_label])
if __name__ == "__main__":
demo.launch()