From 290201f62ec938b9b6c66ea7c81482a42a7e8631 Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Thu, 28 May 2026 13:39:13 +0400 Subject: [PATCH] Studio: trim captioner logs to invoked+complete, render subprocess logs as JSON Two changes to the RAG captioning log output: - Drop the noisy per-image and path-selection info lines (using-chat-VLM, loading-helper, per-image done). Only the 'caption_images: invoked' and 'caption_images: complete' lines remain; warnings for genuine failures (helper load, per-image request, helper unload) are kept. - Configure structlog at the top of the ingestion subprocess worker with the same env the parent uses. The worker runs in a spawned process where structlog was never set up, so its logs fell back to structlog's dev ConsoleRenderer ([info] ...) instead of the JSON renderer the rest of the app uses. Now captioner/parser logs from the subprocess match the parent's JSON format. --- studio/backend/core/rag/captioner.py | 16 +--------------- studio/backend/core/rag/ingestion.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/studio/backend/core/rag/captioner.py b/studio/backend/core/rag/captioner.py index 857d8e54c6..b488bd7dcd 100644 --- a/studio/backend/core/rag/captioner.py +++ b/studio/backend/core/rag/captioner.py @@ -170,13 +170,7 @@ def caption_images( if vlm_url and vlm_model: endpoint = f"{vlm_url.rstrip('/')}/v1/chat/completions" model_name = vlm_model - logger.info( - "caption_images: using loaded chat VLM", - endpoint = endpoint, - model = model_name, - ) else: - logger.info("caption_images: chat VLM unavailable, loading helper") loaded = _load_helper_vlm() if loaded is None: logger.warning( @@ -186,20 +180,12 @@ def caption_images( helper_backend, helper_base_url, helper_model_name = loaded endpoint = f"{helper_base_url.rstrip('/')}/v1/chat/completions" model_name = helper_model_name - logger.info("caption_images: using helper VLM", endpoint = endpoint) out: list[str] = [] with httpx.Client(timeout = _REQUEST_TIMEOUT_SECONDS) as client: for idx, blob in enumerate(image_bytes_list): try: - caption = _post_one(client, endpoint, model_name, blob) - out.append(caption) - logger.info( - "caption_images: per-image done", - idx = idx, - caption_len = len(caption), - preview = caption[:80], - ) + out.append(_post_one(client, endpoint, model_name, blob)) except Exception as exc: # noqa: BLE001 logger.warning( "caption_images: per-image request failed", diff --git a/studio/backend/core/rag/ingestion.py b/studio/backend/core/rag/ingestion.py index f8c286d165..32614a8e5f 100644 --- a/studio/backend/core/rag/ingestion.py +++ b/studio/backend/core/rag/ingestion.py @@ -64,6 +64,20 @@ def _subprocess_worker( vlm_url: str | None = None, vlm_model: str | None = None, ) -> None: + # Spawned subprocess: structlog isn't configured here (the parent's + # setup runs in the FastAPI process only), so configure it the same + # way so captioner / parser logs render as JSON like the rest, not + # structlog's default dev ConsoleRenderer. + try: + import os as _os + + from loggers.config import LogConfig + + LogConfig.setup_logging( + env = _os.getenv("ENVIRONMENT_TYPE", "production"), + ) + except Exception: # noqa: BLE001 + pass try: from core.rag.captioner import caption_images from core.rag.chunking import chunk_pages