✅ Give human review its own handler

This commit is contained in:
eust-w 2026-06-23 21:23:22 +08:00
parent 7a60d0d277
commit f52866bd45
9 changed files with 48 additions and 4 deletions

View File

@ -4960,6 +4960,7 @@ BUILTIN_HANDLERS: dict[str, BuiltinHandler] = {
"audit_sampling": operator_handler(audit_sample_operator),
"condition_router": operator_handler(conditional_route_operator),
"human_review": operator_handler(human_review_operator),
"builtin_human_review": operator_handler(human_review_operator),
"lerobot": operator_handler(lerobot_summary_operator),
"rosbag": operator_handler(rosbag_summary_operator),
"upload": operator_handler(upload_operator),

View File

@ -304,6 +304,31 @@ class RuntimeFileContractTests(unittest.TestCase):
self.assertEqual(payload["count"], 1)
self.assertEqual(payload["items"], [{"status": "ready"}])
def test_dispatch_runs_named_human_review_operator(self):
with tempfile.TemporaryDirectory() as temp_dir:
output_dir = pathlib.Path(temp_dir)
node_data = {
"label": "人工审核",
"hyperparams": [
{"key": "REVIEW_TYPE", "value": "task"},
{"key": "REVIEWER_ROLE", "value": "qa_reviewer"},
],
}
artifacts = MODULE.BUILTIN_HANDLERS["builtin_human_review"](
"run-1",
"review",
output_dir,
node_data,
[{"data": {"items": [{"id": "clip-1", "score": 0.9}]}}],
)
payload = json.loads(pathlib.Path(artifacts[0]["path"]).read_text(encoding="utf-8"))
self.assertEqual(payload["datasetType"], "human-review-tasks")
self.assertEqual(payload["reviewerRole"], "qa_reviewer")
self.assertEqual(payload["taskCount"], 1)
self.assertEqual(payload["items"][0]["id"], "run-1-clip-1")
def test_load_input_artifacts_prefers_manifest_file(self):
with tempfile.TemporaryDirectory() as temp_dir:
manifest_path = pathlib.Path(temp_dir) / "input-artifacts.json"

View File

@ -3,7 +3,7 @@
"name": "人工审核",
"category": "HUMAN",
"type": "builtin",
"runtimeHandler": "builtin_condition_router",
"runtimeHandler": "builtin_human_review",
"runtimeSource": "backend/operators/builtin/human_review/operator.py",
"migrationStatus": "migrated",
"acceptance": {

View File

@ -21,7 +21,7 @@
"runtimeDependencies": [
"json-artifacts"
],
"runtimeHandler": "builtin_condition_router",
"runtimeHandler": "builtin_human_review",
"runtimeSource": "backend/operators/builtin/human_review/operator.py",
"schemaVersion": "droboticflow.operator.repository/v1",
"sourceRoot": "backend/operators/builtin/human_review",

View File

@ -22,7 +22,7 @@
- Worker 会先把上游 artifact 汇总到 `INPUT_ARTIFACTS_PATH`,再把节点配置通过 `NODE_DATA_JSON` 注入运行容器。
- 节点执行结果会写入 `OUTPUT_DIR`、`RESULT_OUTPUT_PATH` 和 `STAGE_MANIFEST_PATH` 对应的文件,再由 worker 汇总进运行记录。
- 大文件和大 JSON 不应依赖 API 内联传输,应该通过 `artifact.path`、`dataRef.payloadPath`、共享 PVC 或对象存储引用传递。
- 当前实现入口通常可追到 `backend/operator-runner/main.py` 中的 `builtin_condition_router(...)`。
- 当前实现入口可追到 `backend/operators/builtin/human_review/operator.py` 中的 `run(...)`,平台 runtimeHandler 为 `builtin_human_review`。
## 设计边界

View File

@ -260,7 +260,7 @@
],
"skillDefinition": "基于真实输入生成审核任务并等待人工处理。",
"runtimeSource": "backend/operators/builtin/human_review/operator.py",
"runtimeHandler": "builtin_condition_router"
"runtimeHandler": "builtin_human_review"
},
{
"id": "operator-builtin-directory-scan",

View File

@ -730,6 +730,8 @@ def validate_static_operator_layout(base_dir: pathlib.Path) -> dict[str, Any]:
duplicate_operator_names.append(operator_name)
else:
seen_operator_names[operator_name] = slug
if slug == "human_review" and metadata.get("runtimeHandler") != "builtin_human_review":
repository_manifest_errors.append("human_review: runtimeHandler must be builtin_human_review")
if slug.startswith("dcloud_") and (
"https://gitea.d-robotics.cc" in source or "https://cloud-fat.d-robotics.cc" in source
):

View File

@ -168,6 +168,8 @@ def static_operator_layout() -> dict[str, Any]:
duplicate_operator_names.append(operator_name)
else:
seen_operator_names[operator_name] = slug
if slug == "human_review" and metadata.get("runtimeHandler") != "builtin_human_review":
repository_manifest_errors.append("human_review: runtimeHandler must be builtin_human_review")
if slug.startswith("dcloud_") and (
"https://gitea.d-robotics.cc" in source or "https://cloud-fat.d-robotics.cc" in source
):

View File

@ -109,6 +109,20 @@ class OperatorRepositoryLayoutTest(unittest.TestCase):
self.assertNotIn('helpers["builtin_', source)
self.assertNotIn("helpers['builtin_", source)
def test_human_review_uses_independent_runtime_handler(self):
metadata = json.loads((OPERATOR_ROOT / "human_review" / "operator.json").read_text(encoding="utf-8"))
catalog = {
item["id"]: item
for item in json.loads(CATALOG_PATH.read_text(encoding="utf-8"))
if item.get("type") == "builtin"
}
manifest = json.loads((OPERATOR_ROOT / "human_review" / "repository.json").read_text(encoding="utf-8"))
self.assertEqual(metadata["runtimeHandler"], "builtin_human_review")
self.assertEqual(catalog["operator-builtin-human-review"]["runtimeHandler"], "builtin_human_review")
self.assertEqual(manifest["runtimeHandler"], "builtin_human_review")
self.assertNotEqual(metadata["runtimeHandler"], "builtin_condition_router")
def test_every_builtin_operator_has_independent_repository_manifest(self):
for metadata_path in sorted(OPERATOR_ROOT.glob("*/operator.json")):
metadata = json.loads(metadata_path.read_text(encoding="utf-8"))