From f52fdc78197ef568d5e6577582aa98667df56e0c Mon Sep 17 00:00:00 2001 From: eust-w Date: Mon, 27 Jul 2026 12:06:28 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Group=20artifacts=20and=20preview?= =?UTF-8?q?=20HTML=20reports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ubt-mcap-pipeline/ubt_pipeline/report.py | 46 ++ src/components/ArtifactPreviewPanel.tsx | 164 +++++- src/components/QualityReportSummaryCard.tsx | 77 +++ src/lib/artifact-download.js | 79 ++- src/lib/artifact-groups.js | 109 ++++ src/lib/report-summary.js | 120 ++++ src/pages/Monitoring.tsx | 535 +++++++++--------- src/types.ts | 24 +- tests/backend/ubt_mcap_pipeline_test.py | 103 ++++ tests/frontend/artifact-download.test.mjs | 9 + tests/frontend/artifact-groups.test.mjs | 97 ++++ .../frontend/artifact-preview-panel.test.mjs | 29 + tests/frontend/report-summary.test.mjs | 58 ++ 13 files changed, 1170 insertions(+), 280 deletions(-) create mode 100644 src/components/QualityReportSummaryCard.tsx create mode 100644 src/lib/artifact-groups.js create mode 100644 src/lib/report-summary.js create mode 100644 tests/frontend/artifact-groups.test.mjs create mode 100644 tests/frontend/artifact-preview-panel.test.mjs create mode 100644 tests/frontend/report-summary.test.mjs diff --git a/lightweight-operators/ubt-mcap-pipeline/ubt_pipeline/report.py b/lightweight-operators/ubt-mcap-pipeline/ubt_pipeline/report.py index 5ead87ab..63a4a199 100644 --- a/lightweight-operators/ubt-mcap-pipeline/ubt_pipeline/report.py +++ b/lightweight-operators/ubt-mcap-pipeline/ubt_pipeline/report.py @@ -19,6 +19,20 @@ from .common import ( OPERATOR_ID = "ubt-quality-report" +RULE_LABELS = { + "start_ts_mismatch": "起始时间戳不一致", + "end_ts_mismatch": "结束时间戳不一致", + "alignment_time_diff_out_of_range": "时间对齐偏差超限", + "joint_jump_violation": "关节跳变", + "joint_limit_violation": "关节限位异常", + "gripper_position_out_of_range": "夹爪位置超范围", + "master_slave_joint_mismatch": "主从关节偏差", + "camera_fps_out_of_range": "相机帧率异常", + "robot_state_fps_out_of_range": "机器人状态帧率异常", + "ee_pose_mismatch": "末端位姿偏差", + "gripper_state_mismatch": "夹爪状态不一致", +} + def _episode_results(artifacts: list[dict[str, Any]]) -> list[dict[str, Any]]: for item in artifacts: @@ -57,6 +71,33 @@ def _date_statistics(results: list[dict[str, Any]]) -> dict[str, dict[str, int]] } +def _quality_report_summary( + status_counts: dict[str, int], + rule_counts: Counter[str], + total_count: int, +) -> dict[str, Any]: + success_count = status_counts.get("PASS", 0) + return { + "schemaVersion": 1, + "kind": "quality", + "title": "数据质量报告", + "unit": "trajectory", + "totalCount": total_count, + "successCount": success_count, + "failureCount": status_counts.get("ERROR", 0), + "runtimeErrorCount": status_counts.get("RUNTIME_ERROR", 0), + "successRate": success_count / total_count if total_count else 0.0, + "issueHits": [ + { + "code": code, + "label": RULE_LABELS.get(code, code), + "count": count, + } + for code, count in sorted(rule_counts.items()) + ], + } + + def _manifest_entry(item: dict[str, Any]) -> dict[str, Any]: return { "episode": item.get("episode"), @@ -207,6 +248,11 @@ def run_report() -> None: "passRate": status_counts["PASS"] / len(results), "dateStatistics": _date_statistics(results), "ruleStatistics": dict(sorted(rule_counts.items())), + "reportSummary": _quality_report_summary( + status_counts, + rule_counts, + len(results), + ), "checkerSummary": checker_summary, } pass_manifest = { diff --git a/src/components/ArtifactPreviewPanel.tsx b/src/components/ArtifactPreviewPanel.tsx index f08563bc..082f566c 100644 --- a/src/components/ArtifactPreviewPanel.tsx +++ b/src/components/ArtifactPreviewPanel.tsx @@ -6,15 +6,18 @@ import { artifactContentPath, artifactDownloadLabel, artifactExtension, + isHTMLArtifact, artifactPreviewCategory, artifactPreviewTitle, } from "../lib/artifact-download.js"; import { summarizePocAcceptanceArtifact } from "../lib/poc-acceptance-summary.js"; +import { summarizeQualityReportArtifact } from "../lib/report-summary.js"; import { LazyVideoPreview } from "./LazyVideoPreview"; import { HoloBrainTrainingReportCard } from "./HoloBrainTrainingReportCard"; import { PocAcceptanceSummaryCard } from "./PocAcceptanceSummaryCard"; +import { QualityReportSummaryCard } from "./QualityReportSummaryCard"; import { buildAPIURL } from "../services/api/base-url.js"; -import { Download, ExternalLink } from "lucide-react"; +import { Code2, Download, ExternalLink, Eye, Loader2 } from "lucide-react"; import { cn } from "../lib/utils"; const ObjModelPreview = lazy(() => import("./ObjModelPreview").then((module) => ({ default: module.ObjModelPreview }))); @@ -44,13 +47,13 @@ const derivedPreview = (item: ExecutionData) => { }; const artifactPreviewURL = (item: ExecutionData, preview: Record) => { - if (typeof preview.url === "string" && preview.url) { - return preview.url; - } const contentPath = artifactContentPath(item); if (contentPath) { return buildAPIURL(contentPath); } + if (typeof preview.url === "string" && preview.url) { + return preview.url; + } const source = item.data?.source; if (source && typeof source === "object") { if (typeof source.previewURL === "string" && source.previewURL) { @@ -116,11 +119,13 @@ function TextContentPreview({ previewURL, inlineText, fullscreen = false, + showActions = true, }: { item: ExecutionData; previewURL: string; inlineText?: string; fullscreen?: boolean; + showActions?: boolean; }) { const [state, setState] = useState<{ status: "idle" | "loading" | "ready" | "error"; @@ -175,7 +180,7 @@ function TextContentPreview({
{artifactPreviewTitle(item)}
{language}
- + {showActions ? : null} {state.status === "loading" ? (
正在加载预览...
@@ -202,6 +207,128 @@ function TextContentPreview({ ); } +function HTMLArtifactPreview({ + item, + previewURL, + inlineText, + fullscreen, +}: { + item: ExecutionData; + previewURL: string; + inlineText?: string; + fullscreen: boolean; +}) { + const [mode, setMode] = useState<"report" | "source">("report"); + const [frameStatus, setFrameStatus] = useState<"loading" | "ready" | "error">(previewURL ? "loading" : "error"); + const [verifiedFrameURL, setVerifiedFrameURL] = useState(""); + + useEffect(() => { + setMode("report"); + setVerifiedFrameURL(""); + if (!previewURL) { + setFrameStatus("error"); + return; + } + const controller = new AbortController(); + setFrameStatus("loading"); + fetch(previewURL, { + method: "HEAD", + credentials: "include", + signal: controller.signal, + }) + .then((response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + setVerifiedFrameURL(previewURL); + }) + .catch((error: Error) => { + if (error.name !== "AbortError") { + setFrameStatus("error"); + } + }); + return () => controller.abort(); + }, [item.id, previewURL]); + + return ( +
+
+
+ + +
+ +
+ + {mode === "source" ? ( +
+ +
+ ) : ( +
+ {verifiedFrameURL === previewURL ? ( +