HealSpace — Guardian AI for Hugging Face Spaces
Project description
🛡️ HealSpace
Automated AI runtime guardian for Hugging Face Spaces.
HealSpace monitors your Space for runtime errors, attempts automatic fixes, and alerts you — so your Space stays alive even when you're not watching.
Install
pip install healspace
Quickstart
import healspace as HS
HS.protect(demo)
demo.launch()
Or the one-liner shorthand:
import healspace as HS
HS(demo)
demo.launch()
Configuration
Call HS.configure() before HS.protect() to customise behaviour.
All commands support inline # comments and are case-insensitive.
import healspace as HS
HS.configure(
"disable HS_promo\n"
"inspect every 30 sec\n"
"set fix quota to 100\n"
"inform dev when retry count 10\n"
'set inform email to "you@gmail.com"\n'
"retry limit 50\n"
)
HS.protect(demo)
demo.launch()
Command Reference
disable HS_promo
Removes the Protected by HealSpace footer from your Gradio UI. Enabled by default — use this if it conflicts with your layout.
disable HS_promo
inspect every N sec / min / hrs
Starts a background polling loop that actively checks for errors on a schedule.
Without this, HealSpace only reacts when an error surfaces on stderr. With this, it proactively scans at every interval.
inspect every 30 sec
inspect every 5 min
inspect every 1 hrs
set fix quota to N
Caps the number of automatic fixes HealSpace will apply this session. After the quota is reached HealSpace continues to detect and report errors, but stops applying fixes.
set fix quota to 100
Without this, HealSpace fixes indefinitely.
inform dev when retry count N
Sends a Hugging Face inbox notification to your account once the total number of errors in this session reaches N.
inform dev when retry count 10
Requires HF_TOKEN to be set as a Space secret (Settings → Variables and secrets).
set inform email to "address"
Sends an email alert to any address when errors accumulate.
set inform email to "you@gmail.com"
set inform email to "team@company.io"
Works with any email provider — Gmail, Outlook, Yahoo, iCloud, custom domains.
Emails arrive from healspace@proton.me.
Requires one Space secret — no password, no SMTP config:
| Secret | Where to get it |
|---|---|
HS_RESEND_KEY |
resend.com — free, 3 000 emails/month |
HS_SENDGRID_KEY |
sendgrid.com — free, 100 emails/day (fallback) |
retry limit N
Hard stop. After N total errors HealSpace prints a final warning,
sends one last email + HF inbox message (if configured), then raises
a RuntimeError that stops the Space process entirely.
retry limit 50
Use this when you want a broken Space to fail loudly and visibly rather than silently loop forever.
What HealSpace Fixes Automatically
| Error type | What it does |
|---|---|
| Missing dependency | pip install the missing package at runtime |
| Port conflict | Frees port 7860 so Gradio can restart |
| GPU out-of-memory | Clears the CUDA cache |
| And more… | Covers 9 known HF Space error patterns |
Space Secrets Reference
| Secret | Required for |
|---|---|
HF_TOKEN |
inform dev when retry count N |
HS_RESEND_KEY |
set inform email to (preferred) |
HS_SENDGRID_KEY |
set inform email to (fallback) |
Add secrets under Space Settings → Variables and secrets.
Mini AI — Code Healer
HealSpace also ships a context-aware code repair engine that reads your codebase style (indentation, quotes, naming, type hints) and writes fixes that match it.
from healspace import CodeHealer
healer = CodeHealer()
patch = healer.heal_traceback(traceback_text, source_file="app.py")
print(patch) # shows a diff
patch.apply() # writes the fix back to the file
Full API
import healspace as HS
HS.fix_quota = 10 # set quota via attribute
HS.protect(demo) # inject UI + start monitoring
HS.watch() # start background stderr monitor only
HS.heal(demo) # one-call: monitor + protect
HS.configure("...") # apply DSL config string
HS.fix(report) # manually attempt a fix for an ErrorReport
License
Apache 2.0 — pypi.org/project/healspace
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file healspace-0.6.2.tar.gz.
File metadata
- Download URL: healspace-0.6.2.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
128f737c48c6a3fef95950cba5c54d2016811ec402a5bd365a2b339748e05806
|
|
| MD5 |
c50f4d8abce66b7db16265ba78bbbbc4
|
|
| BLAKE2b-256 |
41ec3de76bcf71b809efca6e439a68ba6a3e623da28dd699109c1265f25afc4f
|
File details
Details for the file healspace-0.6.2-py3-none-any.whl.
File metadata
- Download URL: healspace-0.6.2-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98987b3867a2a8a340ae72ab2bb9130e45ef30f3bee61b14cc0ba8a038e1efe6
|
|
| MD5 |
8070683316819604c3ecb759101fea83
|
|
| BLAKE2b-256 |
41502a39f0ffc40341179a9d5b67442c44f18455a2a41a34997ead67ed9332ce
|