feat: Unified Ingest SDK for DMS/ADAS promote, cuboid export and 3D fit
Replace subprocess build with promote_batch SDK, add ADAS cuboid export/fit/validate pipeline, stage normalization, and offline unit tests wired into smoke_labeling_api. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -37,6 +37,8 @@ from as_platform.labeling.service import (
|
||||
open_campaign,
|
||||
submit_campaign,
|
||||
trigger_labeling_export,
|
||||
get_batch_export_stats,
|
||||
trigger_cuboid_fit,
|
||||
)
|
||||
from as_platform.labeling.vendor_import import import_vendor_zip, list_registry_profiles
|
||||
|
||||
@@ -315,6 +317,30 @@ def api_labeling_export(
|
||||
raise HTTPException(404, "campaign not found") from None
|
||||
|
||||
|
||||
@router.get("/api/v1/labeling/campaigns/{campaign_id}/export-stats")
|
||||
def api_batch_export_stats(
|
||||
campaign_id: str,
|
||||
_user: Annotated[User, Depends(require_permission("read:pending"))],
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
return get_batch_export_stats(campaign_id)
|
||||
except FileNotFoundError:
|
||||
raise HTTPException(404, "campaign not found") from None
|
||||
|
||||
|
||||
@router.post("/api/v1/labeling/campaigns/{campaign_id}/cuboid-fit")
|
||||
def api_cuboid_fit(
|
||||
campaign_id: str,
|
||||
_user: Annotated[User, Depends(require_permission("read:pending"))],
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
return trigger_cuboid_fit(campaign_id)
|
||||
except FileNotFoundError:
|
||||
raise HTTPException(404, "campaign not found") from None
|
||||
except ValueError as e:
|
||||
raise HTTPException(400, str(e)) from e
|
||||
|
||||
|
||||
@router.get("/api/v1/labeling/campaigns/{campaign_id}/export-jobs")
|
||||
def api_campaign_export_jobs(
|
||||
campaign_id: str,
|
||||
|
||||
@@ -498,15 +498,23 @@ def api_submit(body: SubmitApprovalBody, user: Annotated[User, Depends(get_curre
|
||||
|
||||
@app.post("/api/v1/approvals/submit-build-batch")
|
||||
def api_submit_build_batch(body: BuildFromBatchBody, user: Annotated[User, Depends(get_current_user)]) -> dict[str, Any]:
|
||||
if not can_submit_action(user, "build_dms"):
|
||||
action = "build_adas" if body.project == "adas" else "build_dms"
|
||||
if not can_submit_action(user, action) and not can_submit_action(user, "build_dms"):
|
||||
raise HTTPException(403, "无权提交 build")
|
||||
params: dict[str, Any] = {"task": body.task, "pack": body.pack}
|
||||
pack = body.pack
|
||||
if body.project == "adas" and (not pack or pack == "dms_v2"):
|
||||
pack = "adas_moon3d_v1"
|
||||
params: dict[str, Any] = {
|
||||
"project": body.project,
|
||||
"task": body.task,
|
||||
"pack": pack,
|
||||
}
|
||||
if body.location == "inbox":
|
||||
params["batch"] = body.batch
|
||||
else:
|
||||
params["all_sources"] = True
|
||||
return submit_approval(
|
||||
"build_dms", params,
|
||||
action, params,
|
||||
submitted_by=user.name,
|
||||
submitted_by_user_id=user.id,
|
||||
note=body.note or f"入库 {body.batch}",
|
||||
|
||||
@@ -92,6 +92,47 @@ def api_system_submit_approval(
|
||||
raise HTTPException(400, str(e)) from e
|
||||
|
||||
|
||||
class BuildFromBatchBody(BaseModel):
|
||||
project: str = "dms"
|
||||
task: str
|
||||
batch: str
|
||||
pack: str = "dms_v2"
|
||||
location: str = "inbox"
|
||||
note: str | None = None
|
||||
|
||||
|
||||
@router.post("/audit/submit-build-batch")
|
||||
def api_system_submit_build_batch(
|
||||
body: BuildFromBatchBody,
|
||||
user: Annotated[User, Depends(get_current_user)],
|
||||
) -> dict[str, Any]:
|
||||
action = "build_adas" if body.project == "adas" else "build_dms"
|
||||
if not can_submit_action(user, action) and not can_submit_action(user, "build_dms"):
|
||||
raise HTTPException(403, "无权提交 build")
|
||||
pack = body.pack
|
||||
if body.project == "adas" and (not pack or pack == "dms_v2"):
|
||||
pack = "adas_moon3d_v1"
|
||||
params: dict[str, Any] = {
|
||||
"project": body.project,
|
||||
"task": body.task,
|
||||
"pack": pack,
|
||||
}
|
||||
if body.location == "inbox":
|
||||
params["batch"] = body.batch
|
||||
else:
|
||||
params["all_sources"] = True
|
||||
try:
|
||||
return submit_approval(
|
||||
action,
|
||||
params,
|
||||
submitted_by=user.name,
|
||||
submitted_by_user_id=user.id,
|
||||
note=body.note or f"入库 {body.batch}",
|
||||
)
|
||||
except ValueError as e:
|
||||
raise HTTPException(400, str(e)) from e
|
||||
|
||||
|
||||
@router.get("/audit/{record_id}")
|
||||
def api_system_get_approval(
|
||||
record_id: str,
|
||||
|
||||
Reference in New Issue
Block a user