Spaces:
Running
Running
Download sinetti_api/addons/batch_check.py from Couscouskabyle/iscc-app: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/Couscouskabyle/iscc-app/resolve/main/sinetti_api/addons/batch_check.py
- Command line
-
hf download hf://spaces/Couscouskabyle/iscc-app/sinetti_api/addons/batch_check.py
-
curl -L -o batch_check.py https://huggingface.co/spaces/Couscouskabyle/iscc-app/resolve/main/sinetti_api/addons/batch_check.py
1.09 kB
| """Batch-check add-on. On unless SINETTI_BATCH_CHECK_ENABLED is explicitly off.""" | |
| from __future__ import annotations | |
| import os | |
| from collections.abc import Mapping | |
| from dataclasses import dataclass | |
| from fastapi import FastAPI | |
| _OFF = frozenset({"0", "false", "no", "off"}) | |
| class BatchCheckStatus: | |
| active: bool | |
| reason: str | |
| def deployment_requested(environ: Mapping[str, str] | None = None) -> bool: | |
| source = os.environ if environ is None else environ | |
| raw = source.get("SINETTI_BATCH_CHECK_ENABLED", "").strip().casefold() | |
| return raw not in _OFF | |
| def status() -> BatchCheckStatus: | |
| if deployment_requested(): | |
| return BatchCheckStatus(True, "active") | |
| return BatchCheckStatus(False, "deployment_disabled") | |
| def register(app: FastAPI, dependencies: list) -> BatchCheckStatus: | |
| current = status() | |
| if not current.active: | |
| return current | |
| from sinetti_api.routers import batch_check | |
| app.include_router(batch_check.router, dependencies=dependencies) | |
| return current | |