From a173546c8d2a10508f57d007ae615a1853a5fa5c Mon Sep 17 00:00:00 2001 From: -LAN- Date: Thu, 18 Sep 2025 21:03:20 +0800 Subject: [PATCH] Fix: replace stdout prints with debug logging (#25931) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- api/celery_entrypoint.py | 2 +- api/commands.py | 2 +- api/core/schemas/registry.py | 5 ++++- api/services/rag_pipeline/rag_pipeline_transform_service.py | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/api/celery_entrypoint.py b/api/celery_entrypoint.py index 0773029775..4d1f17430d 100644 --- a/api/celery_entrypoint.py +++ b/api/celery_entrypoint.py @@ -7,7 +7,7 @@ _logger = logging.getLogger(__name__) def _log(message: str): - print(message, flush=True) + _logger.debug(message) # grpc gevent diff --git a/api/commands.py b/api/commands.py index 035c456a8c..259d823dea 100644 --- a/api/commands.py +++ b/api/commands.py @@ -1544,7 +1544,7 @@ def transform_datasource_credentials(): if jina_plugin_id not in installed_plugins_ids: if jina_plugin_unique_identifier: # install jina plugin - print(jina_plugin_unique_identifier) + logger.debug("Installing Jina plugin %s", jina_plugin_unique_identifier) PluginService.install_from_marketplace_pkg(tenant_id, [jina_plugin_unique_identifier]) auth_count = 0 diff --git a/api/core/schemas/registry.py b/api/core/schemas/registry.py index 867e4803bc..51bfae1cd3 100644 --- a/api/core/schemas/registry.py +++ b/api/core/schemas/registry.py @@ -1,4 +1,5 @@ import json +import logging import threading from collections.abc import Mapping, MutableMapping from pathlib import Path @@ -8,6 +9,8 @@ from typing import Any, ClassVar, Optional class SchemaRegistry: """Schema registry manages JSON schemas with version support""" + logger: ClassVar[logging.Logger] = logging.getLogger(__name__) + _default_instance: ClassVar[Optional["SchemaRegistry"]] = None _lock: ClassVar[threading.Lock] = threading.Lock() @@ -83,7 +86,7 @@ class SchemaRegistry: self.metadata[uri] = metadata except (OSError, json.JSONDecodeError) as e: - print(f"Warning: failed to load schema {version}/{schema_name}: {e}") + self.logger.warning("Failed to load schema %s/%s: %s", version, schema_name, e) def get_schema(self, uri: str) -> Any | None: """Retrieves a schema by URI with version support""" diff --git a/api/services/rag_pipeline/rag_pipeline_transform_service.py b/api/services/rag_pipeline/rag_pipeline_transform_service.py index c2dbb484cf..8435030183 100644 --- a/api/services/rag_pipeline/rag_pipeline_transform_service.py +++ b/api/services/rag_pipeline/rag_pipeline_transform_service.py @@ -1,4 +1,5 @@ import json +import logging from datetime import UTC, datetime from pathlib import Path from uuid import uuid4 @@ -17,6 +18,8 @@ from services.entities.knowledge_entities.rag_pipeline_entities import Knowledge from services.plugin.plugin_migration import PluginMigration from services.plugin.plugin_service import PluginService +logger = logging.getLogger(__name__) + class RagPipelineTransformService: def transform_dataset(self, dataset_id: str): @@ -257,7 +260,7 @@ class RagPipelineTransformService: if plugin_unique_identifier: need_install_plugin_unique_identifiers.append(plugin_unique_identifier) if need_install_plugin_unique_identifiers: - print(need_install_plugin_unique_identifiers) + logger.debug("Installing missing pipeline plugins %s", need_install_plugin_unique_identifiers) PluginService.install_from_marketplace_pkg(tenant_id, need_install_plugin_unique_identifiers) def _transfrom_to_empty_pipeline(self, dataset: Dataset):