Spaces:
Paused
Paused
| 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: | |
| []({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() | |