Spaces:
Running
Running
Merge pull request #6 from maribakulj/claude/repo-audit-deployment-71Dac
Browse files- .env.example +2 -0
- src/app/api/routes_health.py +3 -1
- src/app/settings.py +5 -0
.env.example
CHANGED
|
@@ -25,6 +25,8 @@ DB_NAME=app.db
|
|
| 25 |
# Set by HF automatically in Spaces — do not set manually in local mode
|
| 26 |
# SPACE_ID=
|
| 27 |
# HF_HOME=/data/.huggingface
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# -----------------------------------------------------------------------------
|
| 30 |
# Server
|
|
|
|
| 25 |
# Set by HF automatically in Spaces — do not set manually in local mode
|
| 26 |
# SPACE_ID=
|
| 27 |
# HF_HOME=/data/.huggingface
|
| 28 |
+
# HF_TOKEN — set as a Space secret for private model access
|
| 29 |
+
# HF_TOKEN=hf_...
|
| 30 |
|
| 31 |
# -----------------------------------------------------------------------------
|
| 32 |
# Server
|
src/app/api/routes_health.py
CHANGED
|
@@ -10,10 +10,12 @@ router = APIRouter(tags=["health"])
|
|
| 10 |
|
| 11 |
|
| 12 |
@router.get("/health")
|
| 13 |
-
async def health() -> dict[str, str]:
|
| 14 |
settings = get_settings()
|
| 15 |
return {
|
| 16 |
"status": "ok",
|
| 17 |
"version": "0.1.0",
|
| 18 |
"mode": settings.app_mode.value,
|
|
|
|
|
|
|
| 19 |
}
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
@router.get("/health")
|
| 13 |
+
async def health() -> dict[str, str | bool]:
|
| 14 |
settings = get_settings()
|
| 15 |
return {
|
| 16 |
"status": "ok",
|
| 17 |
"version": "0.1.0",
|
| 18 |
"mode": settings.app_mode.value,
|
| 19 |
+
"hf_token_set": bool(settings.hf_token),
|
| 20 |
+
"storage_root": str(settings.storage_root),
|
| 21 |
}
|
src/app/settings.py
CHANGED
|
@@ -62,6 +62,7 @@ class Settings(BaseSettings):
|
|
| 62 |
|
| 63 |
# -- HuggingFace ----------------------------------------------------------
|
| 64 |
hf_home: Path | None = None
|
|
|
|
| 65 |
|
| 66 |
# -- Derived properties ---------------------------------------------------
|
| 67 |
|
|
@@ -106,6 +107,10 @@ class Settings(BaseSettings):
|
|
| 106 |
|
| 107 |
def model_post_init(self, __context: object) -> None:
|
| 108 |
"""Apply Space-specific defaults after init."""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
if self.is_space:
|
| 110 |
if self.storage_root == Path("./data"):
|
| 111 |
object.__setattr__(self, "storage_root", Path("/data"))
|
|
|
|
| 62 |
|
| 63 |
# -- HuggingFace ----------------------------------------------------------
|
| 64 |
hf_home: Path | None = None
|
| 65 |
+
hf_token: str | None = Field(default=None, alias="HF_TOKEN")
|
| 66 |
|
| 67 |
# -- Derived properties ---------------------------------------------------
|
| 68 |
|
|
|
|
| 107 |
|
| 108 |
def model_post_init(self, __context: object) -> None:
|
| 109 |
"""Apply Space-specific defaults after init."""
|
| 110 |
+
# Propagate HF token to environment so huggingface_hub picks it up
|
| 111 |
+
if self.hf_token:
|
| 112 |
+
os.environ.setdefault("HF_TOKEN", self.hf_token)
|
| 113 |
+
|
| 114 |
if self.is_space:
|
| 115 |
if self.storage_root == Path("./data"):
|
| 116 |
object.__setattr__(self, "storage_root", Path("/data"))
|