diff --git a/backend/operator-runner/main.py b/backend/operator-runner/main.py index 2878e49a..5e3a0990 100644 --- a/backend/operator-runner/main.py +++ b/backend/operator-runner/main.py @@ -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), diff --git a/backend/operator-runner/test_main.py b/backend/operator-runner/test_main.py index 49e7e5e2..b383c7b3 100644 --- a/backend/operator-runner/test_main.py +++ b/backend/operator-runner/test_main.py @@ -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" diff --git a/backend/operators/builtin/human_review/operator.json b/backend/operators/builtin/human_review/operator.json index d7d76141..be7cfe76 100644 --- a/backend/operators/builtin/human_review/operator.json +++ b/backend/operators/builtin/human_review/operator.json @@ -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": { diff --git a/backend/operators/builtin/human_review/repository.json b/backend/operators/builtin/human_review/repository.json index 0bfed8f3..94204e02 100644 --- a/backend/operators/builtin/human_review/repository.json +++ b/backend/operators/builtin/human_review/repository.json @@ -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", diff --git a/docs/operators/人工审核.md b/docs/operators/人工审核.md index 526282b6..ddd43a5e 100644 --- a/docs/operators/人工审核.md +++ b/docs/operators/人工审核.md @@ -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`。 ## 设计边界 diff --git a/internal/api/builtin_operators_catalog.json b/internal/api/builtin_operators_catalog.json index 71b45512..9238e80b 100644 --- a/internal/api/builtin_operators_catalog.json +++ b/internal/api/builtin_operators_catalog.json @@ -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", diff --git a/scripts/poc_operator_full_acceptance_job.py b/scripts/poc_operator_full_acceptance_job.py index 8ce01c05..8a5ee34f 100755 --- a/scripts/poc_operator_full_acceptance_job.py +++ b/scripts/poc_operator_full_acceptance_job.py @@ -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 ): diff --git a/scripts/poc_strict_preflight_result.py b/scripts/poc_strict_preflight_result.py index f5fdc1f6..84f3e728 100644 --- a/scripts/poc_strict_preflight_result.py +++ b/scripts/poc_strict_preflight_result.py @@ -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 ): diff --git a/tests/backend/operator_repository_layout_test.py b/tests/backend/operator_repository_layout_test.py index 5772691c..6bc09f51 100644 --- a/tests/backend/operator_repository_layout_test.py +++ b/tests/backend/operator_repository_layout_test.py @@ -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"))