Spaces:
Running on Zero
Running on Zero
Add the "Test your TFM" synthetic-data tool
#1
by arthurnahmias - opened
What
- The Space moves from the static template to a Docker FastAPI server:
app.pymounts each tool undertool/at its own path, and/redirects to/synth_data/. tool/synth_dataholds the Test your TFM page. It draws a classification dataset from a random MLP (X ~ N(0, I), tanh layers, y = argmax of the logits), then fits XGBoost, LightGBM or Seldon (seldon-small) on it and ranks them per dataset. The code istfm_lab/server.py's, served over HTTP instead of MCP.
The Neuralk key
- Each viewer enters their own key in the page's Neuralk key tab. It stays in the browser tab (sessionStorage), or in the browser (localStorage) if they tick Remember on this device.
- The page sends it only with a TFM fit, in the
X-Neuralk-Keyheader. The server hands it toSeldonClassifier(api_key=...)for that fit. It never stores or logs the key and never readsNEURALK_API_KEY, so no org key is used by default. - A Content-Security-Policy limits the page to its own server: no third-party script, no request anywhere else.
Tested locally
- Seed 0 reproduces the page's example run exactly (XGBoost 0.776, LightGBM 0.786).
- End to end in Chrome: the tabs, storing and forgetting the key, the header sent only for the TFM, the CSP, and no console errors.
- With a fake key, the Neuralk API answers 401, the page says the key was refused, and the key appears in neither the response nor the server log.
Not tested yet
- A real Seldon fit with a real key.
- The Docker build, since Docker isn't installed locally. The first build on the Space after the merge will test it.
Run it locally
uv run --with-requirements requirements.txt uvicorn app:app --port 7860
๐ค Generated with Claude Code
arthurnahmias changed pull request status to open
paulnovello-nk changed pull request status to merged