Skip to main content

🛡️ 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

Release files for healspace 0.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for healspace 0.6.2
File Size Uploaded
healspace-0.6.2.tar.gz 26.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for healspace 0.6.2
File Interpreter ABI Platform
healspace-0.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 54.7 kB

Release files / healspace-0.6.2.tar.gz

Download URL healspace-0.6.2.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
128f737c48c6a3fef95950cba5c54d2016811ec402a5bd365a2b339748e05806
BLAKE2b-256 checksum
How to use checksums
41ec3de76bcf71b809efca6e439a68ba6a3e623da28dd699109c1265f25afc4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / healspace-0.6.2-py3-none-any.whl

Download URL healspace-0.6.2-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98987b3867a2a8a340ae72ab2bb9130e45ef30f3bee61b14cc0ba8a038e1efe6
BLAKE2b-256 checksum
How to use checksums
41502a39f0ffc40341179a9d5b67442c44f18455a2a41a34997ead67ed9332ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

0.6.2 This release

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page