python-yama 0.9.0__tar.gz → 0.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_yama-0.9.0 → python_yama-0.10.0}/PKG-INFO +1 -1
- {python_yama-0.9.0 → python_yama-0.10.0}/docs/agent-skill-test-framework-design.md +18 -8
- {python_yama-0.9.0 → python_yama-0.10.0}/skills/eval-plugin-with-yama/SKILL.md +6 -3
- {python_yama-0.9.0 → python_yama-0.10.0}/skills/eval-plugin-with-yama/references/case-schema.md +3 -1
- {python_yama-0.9.0 → python_yama-0.10.0}/skills/eval-plugin-with-yama/references/debugging.md +3 -1
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_report.py +71 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_report_bundle.py +91 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_report_upload.py +75 -9
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/report.py +212 -101
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/report_bundle.py +38 -3
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/report_upload.py +94 -43
- {python_yama-0.9.0 → python_yama-0.10.0}/.github/workflows/publish.yml +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/.gitignore +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/CLAUDE.md +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/LICENSE +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/README.md +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/README.zh-CN.md +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/docs/case-schema-reference.md +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/docs/yama-intro.html +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/pyproject.toml +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/skills/eval-plugin-with-yama/references/install-upgrade.md +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_assertions.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_cli.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_cli_shim.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_dashboard.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_framework.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_llm.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_main_entrypoint.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_mocks.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_pr.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_preview.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_public_api.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_run_plan.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_runner.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_skill_tool.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_thread_case.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_tool_loader.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_usage.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/tests/test_workspace.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/uv.lock +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/__init__.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/__main__.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/assertions.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/cli.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/dashboard.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/llm.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/loaders/__init__.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/loaders/case.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/loaders/common.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/loaders/tool_loader.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/mocks.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/models.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/pr.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/preview.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/runner.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/thread_case.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/tools/__init__.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/tools/base.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/tools/bash/__init__.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/tools/bash/_cli_shim.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/tools/bash/bash.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/tools/bash/fs.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/tools/skill/__init__.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/tools/skill/skill.py +0 -0
- {python_yama-0.9.0 → python_yama-0.10.0}/yama/workspace.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-yama
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: A reproducible evaluation runner for tool-using Agent skills
|
|
5
5
|
Project-URL: Repository, https://github.com/world-sim-dev/yama
|
|
6
6
|
Project-URL: Issues, https://github.com/world-sim-dev/yama/issues
|
|
@@ -2781,14 +2781,24 @@ PASS)。`error_kind="llm"` 对应 LLM 请求异常和 Step 超时;`error_kin
|
|
|
2781
2781
|
只保留上面三张人工浏览用汇总卡片。
|
|
2782
2782
|
|
|
2783
2783
|
远端报告上传由 `yama pr-run --report --upload-report --commit-id <sha>` 触发。命令从
|
|
2784
|
-
环境变量读取 `ADMIN_HOST` 和 `YAMA_EVAL_REPORT_API_TOKEN
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2784
|
+
环境变量读取 `ADMIN_HOST` 和 `YAMA_EVAL_REPORT_API_TOKEN`。本地 `--report` 仍保持
|
|
2785
|
+
单文件自包含 HTML;只有远端上传会拆分为三类对象:每个运行到的 Case 先上传一份完整
|
|
2786
|
+
详情 HTML(`report_scope=case`,`plugin_name=<plugin>`,`report_key=<case_report_key>`),
|
|
2787
|
+
再上传当前 commit 的 push 汇总 HTML,最后对本次涉及的每个 Plugin 查询远端 latest
|
|
2788
|
+
报告、读取其中的 `<script type="application/json" id="yama-report-bundle">`,按
|
|
2789
|
+
`case_key` 把本次运行到的 Case 摘要新增或覆盖进去并上传新的 Plugin latest HTML。
|
|
2790
|
+
|
|
2791
|
+
push / Plugin latest 远端 HTML 只渲染摘要列表:状态、description、原始 `case_key`、
|
|
2792
|
+
上传安全的 `case_report_key`、pass rate、run 计数、tokens、LLM request time、
|
|
2793
|
+
`updated_at_beijing` 和指向 Case 详情 HTML 的 `case_report_url`。它们不再内嵌完整
|
|
2794
|
+
`CaseResult.to_dict()`,也不展开 Run/Step/transcript/Tool Call,因此页面体积随 Case 数
|
|
2795
|
+
线性增长但不随单个 Case 的执行明细膨胀。`case_key` 继续是 Yama 的 Case 身份(相对
|
|
2796
|
+
Plugin Root 的路径),用于展示和合并;`case_report_key` 仅用于后端 case scope 上传,
|
|
2797
|
+
只含字母、数字、`.`、`_`、`-`。`yama-report-meta` 继续服务本地 dashboard;
|
|
2798
|
+
`yama-report-bundle` 是远端 Plugin latest 合并用的机器可读摘要索引。每个被本次 CI
|
|
2799
|
+
新增或更新的 Case 都写入 `updated_at_beijing`,格式为 `YYYY-MM-DD HH:MM:SS`,HTML
|
|
2800
|
+
页面标明这是 Beijing time;本次未运行的旧 Case 在 Plugin latest 中保留原摘要 entry
|
|
2801
|
+
和旧的 Case 详情链接。
|
|
2792
2802
|
|
|
2793
2803
|
**用例预览页(`preview.py`,`--preview` 与 dashboard `/preview` 共用)。**
|
|
2794
2804
|
`render_preview_html` 复用报告的页面外壳与版式(`report.py:render_page` +
|
|
@@ -274,9 +274,12 @@ message(含 tool_calls);Case/Run/Step 层级仍展示 tool-loop LLM Reques
|
|
|
274
274
|
耗时总和。
|
|
275
275
|
|
|
276
276
|
当仓库 CI 使用 `yama pr-run --report --upload-report --commit-id <sha>` 时,yama 会上传当前
|
|
277
|
-
commit
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
commit 报告、每个运行到的 Case 详情报告,并更新受影响 Plugin 的远端 latest 报告。
|
|
278
|
+
commit / Plugin latest 远端页只展示 Case 摘要和 `Open case` 链接,完整
|
|
279
|
+
Run/Step/transcript/Tool Call/Judge 明细在单独的 Case 详情 HTML 里。Plugin latest 会保留
|
|
280
|
+
旧 Case,并按原始 `case_key` 替换本次运行到的 Case 摘要;上传用的 `case_report_key`
|
|
281
|
+
是由 yama 生成的安全 key,不替代原始 `case_key`。每个被更新的条目显示
|
|
282
|
+
`updated_at_beijing`,该时间是北京时间。
|
|
280
283
|
|
|
281
284
|
## 排查不通过的用例
|
|
282
285
|
|
{python_yama-0.9.0 → python_yama-0.10.0}/skills/eval-plugin-with-yama/references/case-schema.md
RENAMED
|
@@ -306,7 +306,9 @@ mocks:
|
|
|
306
306
|
`yama` 运行仍按这里声明的 `backend` / `auto` 规则执行。
|
|
307
307
|
- 远端 Plugin latest 报告里的 Case 身份就是 `case_key`(相对 Plugin Root 的 Case 路径)。
|
|
308
308
|
`yama pr-run --report --upload-report --commit-id <sha>` 合并远端报告时,会用相同
|
|
309
|
-
`case_key`
|
|
309
|
+
`case_key` 的本次运行摘要替换旧条目,未运行到的旧 Case 保留。远端 case 详情上传会
|
|
310
|
+
额外生成只含字母、数字、`.`、`_`、`-` 的 `case_report_key`,它只用于后端存储和
|
|
311
|
+
汇总页链接,不替代原始 `case_key`。
|
|
310
312
|
|
|
311
313
|
## execution
|
|
312
314
|
|
{python_yama-0.9.0 → python_yama-0.10.0}/skills/eval-plugin-with-yama/references/debugging.md
RENAMED
|
@@ -58,7 +58,9 @@ Step 超时)的具体 `LLM error` / `Framework error` 文本显示在对应 Ca
|
|
|
58
58
|
CI 若开启 `yama pr-run --report --upload-report --commit-id <sha>`,上传失败也是 CI 失败。
|
|
59
59
|
先看 `yama-pr-summary.json`:`upload_errors` 表示 push 报告上传失败,
|
|
60
60
|
`plugins[].upload_error` 表示 Plugin latest 查询、合并或上传失败;上传成功时对应 URL 在
|
|
61
|
-
`remote_push_report_url` 和 `plugins[].remote_report_url
|
|
61
|
+
`remote_push_report_url` 和 `plugins[].remote_report_url`。远端 push / Plugin latest 页面
|
|
62
|
+
是轻量摘要列表,不直接展开执行明细;从失败 Case 行的 `Open case` 打开单独上传的 Case
|
|
63
|
+
详情 HTML,再查看 Run/Step/transcript/Tool Call/Judge 明细。
|
|
62
64
|
|
|
63
65
|
## 第 1 层:Collection error(退出码 2)
|
|
64
66
|
|
|
@@ -19,6 +19,7 @@ from yama.report import (
|
|
|
19
19
|
_title_for_role,
|
|
20
20
|
render_html_report,
|
|
21
21
|
render_html_report_from_bundle,
|
|
22
|
+
render_html_summary_report_from_bundle,
|
|
22
23
|
write_timestamped_report,
|
|
23
24
|
)
|
|
24
25
|
from yama.runner import CaseResult, RunResult
|
|
@@ -140,6 +141,23 @@ class CaseDescriptionTests(unittest.TestCase):
|
|
|
140
141
|
self.assertIn("<h2>__evals__/cases/demo.yaml</h2>", html)
|
|
141
142
|
|
|
142
143
|
|
|
144
|
+
class ReportVisualStyleTests(unittest.TestCase):
|
|
145
|
+
def test_report_shell_uses_modern_panel_tokens(self) -> None:
|
|
146
|
+
case = _make_case("visual style")
|
|
147
|
+
result = CaseResult(
|
|
148
|
+
case_key=case.case_key, passed=True, runs=[], pass_rate=1.0
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
html = render_html_report([case], [result])
|
|
152
|
+
|
|
153
|
+
self.assertIn('<main class="report-shell">', html)
|
|
154
|
+
self.assertIn("--bg: #f5f6f8;", html)
|
|
155
|
+
self.assertIn("--surface: #ffffff;", html)
|
|
156
|
+
self.assertIn("--accent: #0b6bcb;", html)
|
|
157
|
+
self.assertIn("border-radius: 8px;", html)
|
|
158
|
+
self.assertIn("box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);", html)
|
|
159
|
+
|
|
160
|
+
|
|
143
161
|
class JudgeStatusReportTests(unittest.TestCase):
|
|
144
162
|
def test_judge_section_shows_overall_requirement_failure(self) -> None:
|
|
145
163
|
case = _make_case("")
|
|
@@ -877,6 +895,59 @@ class TimestampedReportTests(unittest.TestCase):
|
|
|
877
895
|
|
|
878
896
|
|
|
879
897
|
class ReportBundleRenderingTests(unittest.TestCase):
|
|
898
|
+
def test_summary_bundle_renderer_links_to_case_detail_without_expanding_result(
|
|
899
|
+
self,
|
|
900
|
+
) -> None:
|
|
901
|
+
bundle = {
|
|
902
|
+
"schema_version": 1,
|
|
903
|
+
"kind": "plugin",
|
|
904
|
+
"generated_at": "2026-08-01T20:34:56+08:00",
|
|
905
|
+
"plugins": [
|
|
906
|
+
{
|
|
907
|
+
"name": "plugin-a",
|
|
908
|
+
"root": "plugin-a",
|
|
909
|
+
"cases": [
|
|
910
|
+
{
|
|
911
|
+
"case_key": "__evals__/cases/smoke.yaml",
|
|
912
|
+
"case_report_key": "__evals__.cases.smoke.yaml-a1b2c3d4",
|
|
913
|
+
"case_report_url": "https://oss/cases/smoke.html",
|
|
914
|
+
"path": "plugin-a/__evals__/cases/smoke.yaml",
|
|
915
|
+
"description": "Smoke case",
|
|
916
|
+
"status": "fail",
|
|
917
|
+
"pass_rate": 0.0,
|
|
918
|
+
"counts": {
|
|
919
|
+
"runs_passed": 0,
|
|
920
|
+
"runs_total": 1,
|
|
921
|
+
"runs_error": 0,
|
|
922
|
+
},
|
|
923
|
+
"usage": {"total_tokens": 42},
|
|
924
|
+
"llm_request_duration_ms": 12.5,
|
|
925
|
+
"updated_at_beijing": "2026-08-01 20:34:56",
|
|
926
|
+
"case": {
|
|
927
|
+
"case_key": "__evals__/cases/smoke.yaml",
|
|
928
|
+
"path": "plugin-a/__evals__/cases/smoke.yaml",
|
|
929
|
+
"description": "Smoke case",
|
|
930
|
+
"model": {"name": "test-model"},
|
|
931
|
+
"execution": {},
|
|
932
|
+
"tools": [],
|
|
933
|
+
"skills": [],
|
|
934
|
+
},
|
|
935
|
+
}
|
|
936
|
+
],
|
|
937
|
+
}
|
|
938
|
+
],
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
html = render_html_summary_report_from_bundle(bundle)
|
|
942
|
+
|
|
943
|
+
self.assertIn("plugin-a", html)
|
|
944
|
+
self.assertIn("Smoke case", html)
|
|
945
|
+
self.assertIn("Open case", html)
|
|
946
|
+
self.assertIn('href="https://oss/cases/smoke.html"', html)
|
|
947
|
+
self.assertIn("__evals__.cases.smoke.yaml-a1b2c3d4", html)
|
|
948
|
+
self.assertNotIn("Planned runs", html)
|
|
949
|
+
self.assertNotIn("Resolved transcript", html)
|
|
950
|
+
|
|
880
951
|
def test_report_embeds_bundle_and_labels_beijing_case_update_time(self) -> None:
|
|
881
952
|
case = _make_case("bundle")
|
|
882
953
|
result = CaseResult(
|
|
@@ -11,10 +11,12 @@ from yama.report_bundle import (
|
|
|
11
11
|
beijing_timestamp,
|
|
12
12
|
build_case_entry,
|
|
13
13
|
build_report_bundle,
|
|
14
|
+
case_report_key_for_case_key,
|
|
14
15
|
embed_json_for_html_script,
|
|
15
16
|
extract_report_bundle,
|
|
16
17
|
merge_plugin_report_bundle,
|
|
17
18
|
validate_commit_id,
|
|
19
|
+
validate_case_report_key,
|
|
18
20
|
validate_plugin_report_key,
|
|
19
21
|
)
|
|
20
22
|
from yama.runner import CaseResult, RunResult
|
|
@@ -80,6 +82,17 @@ class ReportBundleTests(unittest.TestCase):
|
|
|
80
82
|
with self.subTest(value=value), self.assertRaises(ReportBundleError):
|
|
81
83
|
validate_plugin_report_key(value)
|
|
82
84
|
|
|
85
|
+
def test_case_report_key_is_stable_and_upload_safe(self) -> None:
|
|
86
|
+
self.assertEqual(validate_case_report_key("case_001"), "case_001")
|
|
87
|
+
self.assertEqual(case_report_key_for_case_key("case_001"), "case_001")
|
|
88
|
+
|
|
89
|
+
key = case_report_key_for_case_key("__evals__/cases/foo bar.yaml")
|
|
90
|
+
|
|
91
|
+
self.assertRegex(key, r"^__evals__.cases.foo.bar.yaml-[0-9a-f]{8}$")
|
|
92
|
+
self.assertEqual(validate_case_report_key(key), key)
|
|
93
|
+
with self.assertRaises(ReportBundleError):
|
|
94
|
+
validate_case_report_key("__evals__/cases/foo.yaml")
|
|
95
|
+
|
|
83
96
|
def test_build_case_entry_contains_updated_at_beijing_and_render_payloads(
|
|
84
97
|
self,
|
|
85
98
|
) -> None:
|
|
@@ -106,6 +119,24 @@ class ReportBundleTests(unittest.TestCase):
|
|
|
106
119
|
self.assertEqual(entry["case"]["execution"], {"repeat": 1})
|
|
107
120
|
self.assertEqual(entry["result"]["case_key"], "__evals__/cases/greet.yaml")
|
|
108
121
|
|
|
122
|
+
def test_build_case_entry_can_emit_summary_only_case_link(self) -> None:
|
|
123
|
+
case = make_case()
|
|
124
|
+
result = make_result()
|
|
125
|
+
|
|
126
|
+
entry = build_case_entry(
|
|
127
|
+
case,
|
|
128
|
+
result,
|
|
129
|
+
workspace_root=Path("/workspace"),
|
|
130
|
+
updated_at_beijing="2026-08-01 20:34:56",
|
|
131
|
+
case_report_key="case_001",
|
|
132
|
+
case_report_url="https://oss/case_001.html",
|
|
133
|
+
include_result=False,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
self.assertEqual(entry["case_report_key"], "case_001")
|
|
137
|
+
self.assertEqual(entry["case_report_url"], "https://oss/case_001.html")
|
|
138
|
+
self.assertNotIn("result", entry)
|
|
139
|
+
|
|
109
140
|
def test_build_report_bundle_groups_plugins(self) -> None:
|
|
110
141
|
case = make_case()
|
|
111
142
|
entry = build_case_entry(
|
|
@@ -135,6 +166,66 @@ class ReportBundleTests(unittest.TestCase):
|
|
|
135
166
|
"2026-08-01 20:34:56",
|
|
136
167
|
)
|
|
137
168
|
|
|
169
|
+
def test_merge_plugin_bundle_strips_legacy_result_payloads(self) -> None:
|
|
170
|
+
legacy = {
|
|
171
|
+
"schema_version": 1,
|
|
172
|
+
"kind": "plugin",
|
|
173
|
+
"generated_at": "2026-08-01T20:34:56+08:00",
|
|
174
|
+
"plugins": [
|
|
175
|
+
{
|
|
176
|
+
"name": "plugin-a",
|
|
177
|
+
"root": "plugin-a",
|
|
178
|
+
"cases": [
|
|
179
|
+
{
|
|
180
|
+
"case_key": "__evals__/cases/old.yaml",
|
|
181
|
+
"description": "Old",
|
|
182
|
+
"status": "pass",
|
|
183
|
+
"pass_rate": 1.0,
|
|
184
|
+
"counts": {"runs_passed": 1, "runs_total": 1},
|
|
185
|
+
"result": {"runs": [{"large": "payload"}]},
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
}
|
|
191
|
+
current = {
|
|
192
|
+
"schema_version": 1,
|
|
193
|
+
"kind": "plugin",
|
|
194
|
+
"generated_at": "2026-08-02T20:34:56+08:00",
|
|
195
|
+
"plugins": [
|
|
196
|
+
{
|
|
197
|
+
"name": "plugin-a",
|
|
198
|
+
"root": "plugin-a",
|
|
199
|
+
"cases": [
|
|
200
|
+
{
|
|
201
|
+
"case_key": "__evals__/cases/new.yaml",
|
|
202
|
+
"case_report_key": "new",
|
|
203
|
+
"description": "New",
|
|
204
|
+
"status": "pass",
|
|
205
|
+
"pass_rate": 1.0,
|
|
206
|
+
"counts": {"runs_passed": 1, "runs_total": 1},
|
|
207
|
+
"result": {"runs": [{"large": "payload"}]},
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
merged = merge_plugin_report_bundle(
|
|
215
|
+
legacy,
|
|
216
|
+
current,
|
|
217
|
+
plugin_name="plugin-a",
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
cases = {
|
|
221
|
+
entry["case_key"]: entry
|
|
222
|
+
for entry in merged["plugins"][0]["cases"]
|
|
223
|
+
}
|
|
224
|
+
self.assertNotIn("result", cases["__evals__/cases/old.yaml"])
|
|
225
|
+
self.assertNotIn("result", cases["__evals__/cases/new.yaml"])
|
|
226
|
+
self.assertIn("case_report_key", cases["__evals__/cases/old.yaml"])
|
|
227
|
+
self.assertEqual(cases["__evals__/cases/new.yaml"]["case_report_key"], "new")
|
|
228
|
+
|
|
138
229
|
def test_embed_json_escapes_script_end_tags(self) -> None:
|
|
139
230
|
payload = {"text": "</script><script>alert(1)</script>"}
|
|
140
231
|
|
|
@@ -7,7 +7,11 @@ from pathlib import Path
|
|
|
7
7
|
from urllib.error import HTTPError
|
|
8
8
|
|
|
9
9
|
from yama.models import ResolvedCase
|
|
10
|
-
from yama.report_bundle import
|
|
10
|
+
from yama.report_bundle import (
|
|
11
|
+
case_report_key_for_case_key,
|
|
12
|
+
embed_json_for_html_script,
|
|
13
|
+
extract_report_bundle,
|
|
14
|
+
)
|
|
11
15
|
from yama.report_upload import (
|
|
12
16
|
ReportUploadClient,
|
|
13
17
|
ReportUploadError,
|
|
@@ -102,6 +106,39 @@ class ReportUploadClientTests(unittest.TestCase):
|
|
|
102
106
|
self.assertIn("146bdae", body)
|
|
103
107
|
self.assertIn('name="file"; filename="report.html"', body)
|
|
104
108
|
|
|
109
|
+
def test_case_upload_sends_plugin_name(self) -> None:
|
|
110
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
111
|
+
path = Path(tmp) / "case.html"
|
|
112
|
+
path.write_text("<html>case</html>", encoding="utf-8")
|
|
113
|
+
seen = {}
|
|
114
|
+
|
|
115
|
+
def fake_urlopen(request, timeout=30):
|
|
116
|
+
seen["data"] = request.data
|
|
117
|
+
return FakeResponse(
|
|
118
|
+
json.dumps({"report_url": "https://oss/case.html"}).encode()
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
client = ReportUploadClient(
|
|
122
|
+
admin_host="https://admin.example",
|
|
123
|
+
token="secret",
|
|
124
|
+
urlopen=fake_urlopen,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
client.upload_report(
|
|
128
|
+
report_scope="case",
|
|
129
|
+
plugin_name="adflow.en",
|
|
130
|
+
report_key="case_001",
|
|
131
|
+
file_path=path,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
body = seen["data"].decode("utf-8", errors="ignore")
|
|
135
|
+
self.assertIn('name="report_scope"', body)
|
|
136
|
+
self.assertIn("case", body)
|
|
137
|
+
self.assertIn('name="plugin_name"', body)
|
|
138
|
+
self.assertIn("adflow.en", body)
|
|
139
|
+
self.assertIn('name="report_key"', body)
|
|
140
|
+
self.assertIn("case_001", body)
|
|
141
|
+
|
|
105
142
|
def test_get_plugin_report_returns_none_for_404(self) -> None:
|
|
106
143
|
def fake_urlopen(request, timeout=30):
|
|
107
144
|
raise HTTPError(request.full_url, 404, "missing", {}, None)
|
|
@@ -158,7 +195,7 @@ class ReportUploadClientTests(unittest.TestCase):
|
|
|
158
195
|
with self.assertRaises(ReportUploadError):
|
|
159
196
|
load_remote_plugin_bundle({}, download_text=lambda url: "")
|
|
160
197
|
|
|
161
|
-
def
|
|
198
|
+
def test_upload_pr_reports_uploads_case_details_and_summary_reports(self) -> None:
|
|
162
199
|
with tempfile.TemporaryDirectory() as tmp:
|
|
163
200
|
root = Path(tmp)
|
|
164
201
|
first = make_case(root, "first")
|
|
@@ -173,13 +210,16 @@ class ReportUploadClientTests(unittest.TestCase):
|
|
|
173
210
|
|
|
174
211
|
class FakeClient:
|
|
175
212
|
def __init__(self) -> None:
|
|
176
|
-
self.uploads: list[tuple[str, str, str]] = []
|
|
213
|
+
self.uploads: list[tuple[str, str, str | None, str]] = []
|
|
177
214
|
|
|
178
|
-
def upload_report(
|
|
215
|
+
def upload_report(
|
|
216
|
+
self, *, report_scope, report_key, file_path, plugin_name=None
|
|
217
|
+
):
|
|
179
218
|
self.uploads.append(
|
|
180
219
|
(
|
|
181
220
|
report_scope,
|
|
182
221
|
report_key,
|
|
222
|
+
plugin_name,
|
|
183
223
|
file_path.read_text(encoding="utf-8"),
|
|
184
224
|
)
|
|
185
225
|
)
|
|
@@ -211,8 +251,19 @@ class ReportUploadClientTests(unittest.TestCase):
|
|
|
211
251
|
"https://oss/plugin/plugin-a.html",
|
|
212
252
|
)
|
|
213
253
|
self.assertIsNone(plugin_results["plugin-a"]["upload_error"])
|
|
214
|
-
|
|
215
|
-
|
|
254
|
+
expected_case_report_key = case_report_key_for_case_key(second.case_key)
|
|
255
|
+
self.assertEqual(
|
|
256
|
+
[upload[:3] for upload in client.uploads],
|
|
257
|
+
[
|
|
258
|
+
("case", expected_case_report_key, "plugin-a"),
|
|
259
|
+
("push", "146bdae", None),
|
|
260
|
+
("plugin", "plugin-a", None),
|
|
261
|
+
],
|
|
262
|
+
)
|
|
263
|
+
case_html = client.uploads[0][3]
|
|
264
|
+
push_html = client.uploads[1][3]
|
|
265
|
+
plugin_html = client.uploads[2][3]
|
|
266
|
+
self.assertIn("<h2>second</h2>", case_html)
|
|
216
267
|
push_bundle = extract_report_bundle(push_html)
|
|
217
268
|
plugin_bundle = extract_report_bundle(plugin_html)
|
|
218
269
|
self.assertEqual(
|
|
@@ -229,6 +280,17 @@ class ReportUploadClientTests(unittest.TestCase):
|
|
|
229
280
|
],
|
|
230
281
|
["__evals__/cases/second.yaml"],
|
|
231
282
|
)
|
|
283
|
+
push_entry = push_bundle["plugins"][0]["cases"][0]
|
|
284
|
+
plugin_entry = plugin_bundle["plugins"][0]["cases"][0]
|
|
285
|
+
self.assertNotIn("result", push_entry)
|
|
286
|
+
self.assertNotIn("result", plugin_entry)
|
|
287
|
+
self.assertEqual(push_entry["case_report_key"], expected_case_report_key)
|
|
288
|
+
self.assertEqual(
|
|
289
|
+
push_entry["case_report_url"],
|
|
290
|
+
f"https://oss/case/{expected_case_report_key}.html",
|
|
291
|
+
)
|
|
292
|
+
self.assertIn("Open case", push_html)
|
|
293
|
+
self.assertIn("Open case", plugin_html)
|
|
232
294
|
|
|
233
295
|
def test_upload_pr_reports_keeps_invalid_plugin_key_in_push_report(self) -> None:
|
|
234
296
|
with tempfile.TemporaryDirectory() as tmp:
|
|
@@ -245,13 +307,16 @@ class ReportUploadClientTests(unittest.TestCase):
|
|
|
245
307
|
|
|
246
308
|
class FakeClient:
|
|
247
309
|
def __init__(self) -> None:
|
|
248
|
-
self.uploads: list[tuple[str, str, str]] = []
|
|
310
|
+
self.uploads: list[tuple[str, str, str | None, str]] = []
|
|
249
311
|
|
|
250
|
-
def upload_report(
|
|
312
|
+
def upload_report(
|
|
313
|
+
self, *, report_scope, report_key, file_path, plugin_name=None
|
|
314
|
+
):
|
|
251
315
|
self.uploads.append(
|
|
252
316
|
(
|
|
253
317
|
report_scope,
|
|
254
318
|
report_key,
|
|
319
|
+
plugin_name,
|
|
255
320
|
file_path.read_text(encoding="utf-8"),
|
|
256
321
|
)
|
|
257
322
|
)
|
|
@@ -285,12 +350,13 @@ class ReportUploadClientTests(unittest.TestCase):
|
|
|
285
350
|
"plugin report key may only contain",
|
|
286
351
|
plugin_results[plugin_key]["upload_error"],
|
|
287
352
|
)
|
|
288
|
-
push_bundle = extract_report_bundle(client.uploads[0][
|
|
353
|
+
push_bundle = extract_report_bundle(client.uploads[0][3])
|
|
289
354
|
self.assertEqual(push_bundle["plugins"][0]["name"], plugin_key)
|
|
290
355
|
self.assertEqual(
|
|
291
356
|
push_bundle["plugins"][0]["cases"][0]["case_key"],
|
|
292
357
|
"__evals__/cases/smoke.yaml",
|
|
293
358
|
)
|
|
359
|
+
self.assertNotIn("result", push_bundle["plugins"][0]["cases"][0])
|
|
294
360
|
|
|
295
361
|
|
|
296
362
|
if __name__ == "__main__":
|