Spaces:
Sleeping
Sleeping
Commit ·
b0c681a
1
Parent(s): 0fafc9b
Launch FastAPI server via uvicorn in app.py to keep process alive
Browse files12345673 unmodified lines111213141516171819202122232425262728293030 unmodified lines6162636465666768697071#!/usr/bin/env python3"""FALL (SwarmNet) - Hugging Face Space Production EntrypointCompatible with ZeroGPU and CPU runtimes."""import sysimport os3 unmodified linesROOT_DIR = os.path.abspath(os.path.dirname(__file__))sys.path.insert(0, ROOT_DIR)# Handle ZeroGPU @spaces.GPU decorator if running under spaces runtimetry:import spaces@spaces.GPUdef zerogpu_warmup():"""Satisfies ZeroGPU startup check"""import torchreturn torch.cuda.is_available()zerogpu_warmup()except Exception:passimport gradio as gr# 1. Start Miner 1 (Layers 0 to 14) in backgroundprint("⚡ Starting Swarm Miner 01 (Layers 0-14)...")env = os.environ.copy()30 unmodified linestime.sleep(2)# 3. Mount our custom FastAPI app inside Gradiofrom scripts.run_client_ui import app as fastapi_app# gr.mount_gradio_app modifies and returns the FastAPI appapp = gr.mount_gradio_app(fastapi_app, gr.Blocks(), path="/gradio")# Export for Hugging Face Spaces Gradio runnerdemo = app12345673 unmodified lines11121314151630 unmodified lines4748495051525354555657#!/usr/bin/env python3"""FALL (SwarmNet) - Hugging Face Space Production EntrypointRuns via Uvicorn server on port 7860."""import sysimport os3 unmodified linesROOT_DIR = os.path.abspath(os.path.dirname(__file__))sys.path.insert(0, ROOT_DIR)# 1. Start Miner 1 (Layers 0 to 14) in backgroundprint("⚡ Starting Swarm Miner 01 (Layers 0-14)...")env = os.environ.copy()30 unmodified linestime.sleep(2)# 3. Import and launch the FastAPI app directly with Uvicornfrom scripts.run_client_ui import appif __name__ == "__main__":import uvicornport = int(os.environ.get("PORT", 7860))print(f"\n🌐 FALL UI & Swarm Genesis listening on 0.0.0.0:{port}\n")uvicorn.run(app, host="0.0.0.0", port=port, log_level="info")
app.py+8-22