From 185052471baffda1b6980560f3ac0285e95ea9d7 Mon Sep 17 00:00:00 2001 From: Jerome Picault Date: Mon, 20 Jul 2026 14:08:35 +0000 Subject: [PATCH] fix(hf-space): run on CPU basic, disable Gradio SSR (Node sidecar) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Space showed a runtime error — "No @spaces.GPU function detected during startup" — which HF only raises on ZeroGPU hardware; this app is CPU-only, so it must run on CPU basic. Document that (README + suggested_hardware: cpu-basic) and disable Gradio's SSR (GRADIO_SSR_MODE=false + ssr_mode=False) so the Space is plain server-rendered Python with no Node sidecar — leaner on free CPU. --- .github/huggingface/space_readme_header.md | 1 + README.md | 4 +++- space_app.py | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/huggingface/space_readme_header.md b/.github/huggingface/space_readme_header.md index 266a044..5b5a11c 100644 --- a/.github/huggingface/space_readme_header.md +++ b/.github/huggingface/space_readme_header.md @@ -6,6 +6,7 @@ colorTo: indigo sdk: gradio app_file: space_app.py python_version: "3.12" +suggested_hardware: cpu-basic pinned: false license: mpl-2.0 short_description: Browse, theme-classify and topic-model conference papers diff --git a/README.md b/README.md index c5cbcdb..68dc9e9 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,9 @@ Action mirrors `main` to the Space on every push, so it stays in sync. **One-time setup:** 1. **Create the Space** — on , pick **Gradio → - Blank**, and note its owner + name (e.g. `your-user/conflens`). + Blank**, **CPU basic** hardware (this app is CPU-only; ZeroGPU errors with + *"No @spaces.GPU function detected"*), and note its owner + name (e.g. + `your-user/conflens`). 2. **Give GitHub a token** — create a Hugging Face access token with **write** scope (Settings → Access Tokens) and add it to this GitHub repo as a secret named **`HF_TOKEN`** (Settings → Secrets and variables → Actions). diff --git a/space_app.py b/space_app.py index caef124..1cbf8d5 100644 --- a/space_app.py +++ b/space_app.py @@ -3,13 +3,26 @@ The Space's README metadata sets ``app_file: space_app.py``. HF imports this module, finds the module-level ``demo`` and serves it. Running it directly (``python space_app.py``) launches locally too. + +The Space runs on free **CPU** hardware, so Gradio's SSR (which spawns a Node +sidecar) is disabled — the app is plain server-rendered Python. Set the Space +hardware to *CPU basic*; ZeroGPU hardware would error with "No @spaces.GPU +function detected" because this app has no GPU code. """ import os from conflens.gradio_app import build_demo +# Disable Gradio SSR (Node proxy) — set before any launch, whether HF launches +# `demo` itself or this file is run directly. +os.environ.setdefault("GRADIO_SSR_MODE", "false") + demo = build_demo() if __name__ == "__main__": - demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", "7860"))) + demo.launch( + server_name="0.0.0.0", + server_port=int(os.environ.get("PORT", "7860")), + ssr_mode=False, + )