You've already forked DataMate
feat(annotation): 添加标注项目文件快照功能
- 新增 LabelingProjectFile 模型用于存储标注项目的文件快照 - 在创建标注项目时记录关联的文件快照数据 - 更新查询逻辑以基于项目快照过滤文件列表 - 优化导出统计功能使用快照数据进行计算 - 添加数据库表结构支持项目文件快照关系
This commit is contained in:
@@ -3,14 +3,16 @@ import math
|
||||
import uuid
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Path
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db.session import get_db
|
||||
from app.db.models import LabelingProject
|
||||
from app.db.models import LabelingProject, DatasetFiles
|
||||
from app.module.shared.schema import StandardResponse, PaginatedData
|
||||
from app.module.dataset import DatasetManagementService
|
||||
from app.core.logging import get_logger
|
||||
|
||||
from app.module.annotation.service.editor import AnnotationEditorService
|
||||
from ..service.mapping import DatasetMappingService
|
||||
from ..service.template import AnnotationTemplateService
|
||||
from ..schema import (
|
||||
@@ -116,8 +118,20 @@ async def create_mapping(
|
||||
configuration=project_configuration or None,
|
||||
)
|
||||
|
||||
# 创建映射关系,包含项目名称(先持久化映射以获得 mapping.id)
|
||||
mapping = await mapping_service.create_mapping(labeling_project)
|
||||
file_query = select(DatasetFiles.id).where(
|
||||
DatasetFiles.dataset_id == request.dataset_id
|
||||
)
|
||||
if dataset_type == TEXT_DATASET_TYPE:
|
||||
file_query = file_query.where(
|
||||
~AnnotationEditorService._build_source_document_filter()
|
||||
)
|
||||
file_result = await db.execute(file_query)
|
||||
snapshot_file_ids = [str(fid) for fid in file_result.scalars().all()]
|
||||
|
||||
# 创建映射关系并写入快照
|
||||
mapping = await mapping_service.create_mapping_with_snapshot(
|
||||
labeling_project, snapshot_file_ids
|
||||
)
|
||||
|
||||
response_data = DatasetMappingCreateResponse(
|
||||
id=mapping.id,
|
||||
|
||||
Reference in New Issue
Block a user