refactor: share env-bool parsing and logging setup
env_utils.env_bool replaces duplicated truthy parsing in config and rembg_cli. logging_config.configure_logging unifies entry-point setup. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+8
-7
@@ -14,8 +14,9 @@ from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from . import config, pipeline, remix
|
||||
from .logging_config import configure_logging
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s [%(name)s] %(message)s")
|
||||
configure_logging()
|
||||
logger = logging.getLogger("livef12.web")
|
||||
|
||||
app = FastAPI(title=config.SITE_TITLE)
|
||||
@@ -63,15 +64,15 @@ def _safe_job_file(job_id: str, filename: str) -> Path:
|
||||
def list_jobs() -> list[dict[str, Any]]:
|
||||
jobs = []
|
||||
for job_id in pipeline.list_job_ids():
|
||||
status = pipeline.read_status(job_id) or {}
|
||||
manifest = pipeline.read_manifest(job_id) or {}
|
||||
data = pipeline.read_meta(job_id) or {}
|
||||
variants = data.get("variants") or []
|
||||
jobs.append(
|
||||
{
|
||||
"job_id": job_id,
|
||||
"status": status.get("status", "unknown"),
|
||||
"created_at": status.get("created_at") or manifest.get("created_at") or "",
|
||||
"variant_count": len(manifest.get("variants", [])),
|
||||
"thumbnail": (manifest.get("variants") or [{}])[-1].get("file") if manifest.get("variants") else None,
|
||||
"status": data.get("status", "unknown"),
|
||||
"created_at": data.get("created_at") or "",
|
||||
"variant_count": len(variants),
|
||||
"thumbnail": variants[-1].get("file") if variants else None,
|
||||
}
|
||||
)
|
||||
jobs.sort(key=lambda j: j["created_at"] or j["job_id"], reverse=True)
|
||||
|
||||
Reference in New Issue
Block a user