From 649ab2f6bb2b72cf17e18226d92ee8f0e73954c2 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 19 Jan 2026 21:58:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(annotation):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97=E5=92=8C=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A0=86=E6=A0=88=E8=B7=9F=E8=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了项目映射获取接口中的traceback打印 - 简化了内部服务器错误响应消息 - 删除了映射服务中的多个调试日志输出 - 清理了响应数据构建过程中的调试信息 --- .../app/module/annotation/interface/project.py | 5 ++--- .../app/module/annotation/service/mapping.py | 11 ----------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/runtime/datamate-python/app/module/annotation/interface/project.py b/runtime/datamate-python/app/module/annotation/interface/project.py index efe6121..1cd0ce5 100644 --- a/runtime/datamate-python/app/module/annotation/interface/project.py +++ b/runtime/datamate-python/app/module/annotation/interface/project.py @@ -225,9 +225,8 @@ async def get_mapping( except HTTPException: raise except Exception as e: - import traceback - logger.error(f"Error getting mapping: {e}\n{traceback.format_exc()}") - raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}") + logger.error(f"Error getting mapping: {e}") + raise HTTPException(status_code=500, detail="Internal server error") @router.get("/by-source/{dataset_id}", response_model=StandardResponse[PaginatedData[DatasetMappingResponse]]) async def get_mappings_by_source( diff --git a/runtime/datamate-python/app/module/annotation/service/mapping.py b/runtime/datamate-python/app/module/annotation/service/mapping.py index 7be5bee..a1aae34 100644 --- a/runtime/datamate-python/app/module/annotation/service/mapping.py +++ b/runtime/datamate-python/app/module/annotation/service/mapping.py @@ -49,21 +49,16 @@ class DatasetMappingService: mapping = row[0] # LabelingProject object dataset_name = row[1] # dataset_name from join - logger.debug(f"_to_response_from_row: mapping.id={mapping.id}") - # Get template_id from mapping template_id = getattr(mapping, 'template_id', None) # 从 configuration JSON 字段中提取 label_config 和 description configuration = getattr(mapping, 'configuration', None) or {} - logger.debug(f"_to_response_from_row: configuration type={type(configuration)}, value={configuration}") - label_config = None description = None if isinstance(configuration, dict): label_config = configuration.get('label_config') description = configuration.get('description') - logger.debug(f"_to_response_from_row: label_config={label_config[:100] if label_config else None}...") # Optionally fetch full template details template_response = None @@ -102,8 +97,6 @@ class DatasetMappingService: mapping: LabelingProject ORM object include_template: If True, fetch and include full template details """ - logger.debug(f"_to_response: mapping.id={mapping.id}") - # Fetch dataset name dataset_name = None dataset_id = getattr(mapping, 'dataset_id', None) @@ -118,14 +111,11 @@ class DatasetMappingService: # 从 configuration JSON 字段中提取 label_config 和 description configuration = getattr(mapping, 'configuration', None) or {} - logger.debug(f"_to_response: configuration type={type(configuration)}, value={configuration}") - label_config = None description = None if isinstance(configuration, dict): label_config = configuration.get('label_config') description = configuration.get('description') - logger.debug(f"_to_response: label_config={label_config[:100] if label_config else None}...") # Optionally fetch full template details template_response = None @@ -151,7 +141,6 @@ class DatasetMappingService: "deleted_at": mapping.deleted_at, } - logger.debug(f"_to_response: response_data keys={response_data.keys()}") return DatasetMappingResponse(**response_data) async def create_mapping(