You've already forked DataMate
```
chore(annotation): 添加调试日志到映射服务 - 在 _to_response_from_row 方法中添加配置和标签配置的调试日志 - 在 _to_response 方法中添加映射ID和配置信息的调试日志 - 添加响应数据键名的调试日志 - 优化配置解析逻辑以确保字典类型的正确检查 ```
This commit is contained in:
@@ -225,8 +225,9 @@ async def get_mapping(
|
|||||||
except HTTPException:
|
except HTTPException:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error getting mapping: {e}")
|
import traceback
|
||||||
raise HTTPException(status_code=500, detail="Internal server error")
|
logger.error(f"Error getting mapping: {e}\n{traceback.format_exc()}")
|
||||||
|
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
||||||
|
|
||||||
@router.get("/by-source/{dataset_id}", response_model=StandardResponse[PaginatedData[DatasetMappingResponse]])
|
@router.get("/by-source/{dataset_id}", response_model=StandardResponse[PaginatedData[DatasetMappingResponse]])
|
||||||
async def get_mappings_by_source(
|
async def get_mappings_by_source(
|
||||||
|
|||||||
@@ -49,13 +49,21 @@ class DatasetMappingService:
|
|||||||
mapping = row[0] # LabelingProject object
|
mapping = row[0] # LabelingProject object
|
||||||
dataset_name = row[1] # dataset_name from join
|
dataset_name = row[1] # dataset_name from join
|
||||||
|
|
||||||
|
logger.debug(f"_to_response_from_row: mapping.id={mapping.id}")
|
||||||
|
|
||||||
# Get template_id from mapping
|
# Get template_id from mapping
|
||||||
template_id = getattr(mapping, 'template_id', None)
|
template_id = getattr(mapping, 'template_id', None)
|
||||||
|
|
||||||
# 从 configuration JSON 字段中提取 label_config 和 description
|
# 从 configuration JSON 字段中提取 label_config 和 description
|
||||||
configuration = getattr(mapping, 'configuration', None) or {}
|
configuration = getattr(mapping, 'configuration', None) or {}
|
||||||
label_config = configuration.get('label_config') if isinstance(configuration, dict) else None
|
logger.debug(f"_to_response_from_row: configuration type={type(configuration)}, value={configuration}")
|
||||||
description = configuration.get('description') if isinstance(configuration, dict) else None
|
|
||||||
|
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
|
# Optionally fetch full template details
|
||||||
template_response = None
|
template_response = None
|
||||||
@@ -94,6 +102,8 @@ class DatasetMappingService:
|
|||||||
mapping: LabelingProject ORM object
|
mapping: LabelingProject ORM object
|
||||||
include_template: If True, fetch and include full template details
|
include_template: If True, fetch and include full template details
|
||||||
"""
|
"""
|
||||||
|
logger.debug(f"_to_response: mapping.id={mapping.id}")
|
||||||
|
|
||||||
# Fetch dataset name
|
# Fetch dataset name
|
||||||
dataset_name = None
|
dataset_name = None
|
||||||
dataset_id = getattr(mapping, 'dataset_id', None)
|
dataset_id = getattr(mapping, 'dataset_id', None)
|
||||||
@@ -108,8 +118,14 @@ class DatasetMappingService:
|
|||||||
|
|
||||||
# 从 configuration JSON 字段中提取 label_config 和 description
|
# 从 configuration JSON 字段中提取 label_config 和 description
|
||||||
configuration = getattr(mapping, 'configuration', None) or {}
|
configuration = getattr(mapping, 'configuration', None) or {}
|
||||||
label_config = configuration.get('label_config') if isinstance(configuration, dict) else None
|
logger.debug(f"_to_response: configuration type={type(configuration)}, value={configuration}")
|
||||||
description = configuration.get('description') if isinstance(configuration, dict) else None
|
|
||||||
|
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
|
# Optionally fetch full template details
|
||||||
template_response = None
|
template_response = None
|
||||||
@@ -135,6 +151,7 @@ class DatasetMappingService:
|
|||||||
"deleted_at": mapping.deleted_at,
|
"deleted_at": mapping.deleted_at,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug(f"_to_response: response_data keys={response_data.keys()}")
|
||||||
return DatasetMappingResponse(**response_data)
|
return DatasetMappingResponse(**response_data)
|
||||||
|
|
||||||
async def create_mapping(
|
async def create_mapping(
|
||||||
|
|||||||
Reference in New Issue
Block a user