You've already forked DataMate
feat(annotation): 文件版本更新时支持保留标注记录(位置偏移+文字匹配迁移)
新增 AnnotationMigrator 迁移算法,在 TEXT 类型数据集的文件版本更新时, 可选通过 difflib 位置偏移映射和文字二次匹配将旧版本标注迁移到新版本上。 前端版本切换对话框增加"保留标注"复选框(仅 TEXT 类型显示),后端 API 增加 preserveAnnotations 参数,完全向后兼容。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,7 @@ from app.module.annotation.schema.editor import (
|
||||
EditorTaskSegmentResponse,
|
||||
EditorTaskResponse,
|
||||
FileVersionCheckResponse,
|
||||
UseNewVersionRequest,
|
||||
UseNewVersionResponse,
|
||||
UpsertAnnotationRequest,
|
||||
UpsertAnnotationResponse,
|
||||
@@ -158,12 +159,14 @@ async def check_file_version(
|
||||
async def use_new_version(
|
||||
project_id: str = Path(..., description="标注项目ID(t_dm_labeling_projects.id)"),
|
||||
file_id: str = Path(..., description="文件ID(t_dm_dataset_files.id)"),
|
||||
request: Optional[UseNewVersionRequest] = None,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
user_context: RequestUserContext = Depends(get_request_user_context),
|
||||
):
|
||||
"""
|
||||
使用文件新版本并清空标注
|
||||
使用文件新版本(可选保留标注)
|
||||
"""
|
||||
preserve = request.preserve_annotations if request else False
|
||||
service = AnnotationEditorService(db, user_context)
|
||||
result = await service.use_new_version(project_id, file_id)
|
||||
result = await service.use_new_version(project_id, file_id, preserve_annotations=preserve)
|
||||
return StandardResponse(code=200, message="success", data=result)
|
||||
|
||||
Reference in New Issue
Block a user