mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-15 00:11:59 +00:00
分析卡运行时对合并后的阈值再核一遍(复核 R28):画图时阈值覆盖只能对着缺省值校验(schema 不改),发起时的设置快照合进来以后可能冲突——管理员把「超出常规波动」调到 3、卡上把「明显超出」覆盖成 2.5,就永远判不出超出。卡上写了覆盖时,运行时对缺省 ← 快照 ← 覆盖合并后的阈值跑一次 contract.settings_problem,有问题让卡失败并说清「阈值覆盖和这次运行的分析设置冲突:…。请改分析卡上的阈值覆盖」(配置错误,不是数据问题,一项都不算)
This commit is contained in:
@@ -56,7 +56,12 @@ async def run_analysis(state: GraphState, ctx: NodeContext) -> dict[str, Any]:
|
||||
if errors := [i for i in analysis_issues(ctx.run.spec, ctx.node) if i.level == "error"]:
|
||||
raise NodeError(ctx.node.id, errors[0].message)
|
||||
items: list[dict[str, Any]] = ctx.config["items"]
|
||||
settings = await settings_of(run_snapshot(ctx.run), ctx.config.get("overrides") or None)
|
||||
overrides = ctx.config.get("overrides") or None
|
||||
settings = await settings_of(run_snapshot(ctx.run), overrides)
|
||||
# 画图时阈值覆盖只能对着缺省值校验;合并了这次运行的设置快照以后再核一遍(管理员把「超出常规波动」调到 3、卡上把「明显
|
||||
# 超出」覆盖成 2.5,就永远判不出超出)。这是配置错误,不是数据问题:让卡失败、说清冲突在哪
|
||||
if overrides and (problem := contract.settings_problem(settings)):
|
||||
raise NodeError(ctx.node.id, f"阈值覆盖和这次运行的分析设置冲突:{problem}。请改分析卡上的阈值覆盖")
|
||||
|
||||
queries = [e for e in state.get("evidence") or [] if isinstance(e, dict) and e.get("kind") == "query"]
|
||||
inputs: dict[str, InputSnapshot] = {}
|
||||
|
||||
@@ -68,3 +68,16 @@ async def test_a_structural_call_error_still_fails_the_card_and_names_the_item()
|
||||
assert row.status == "failed"
|
||||
assert "分析项「where」(变化拆解)" in row.error and "没有「channel」这一列" in row.error
|
||||
assert "请在分析卡中改正这一项" in row.error
|
||||
|
||||
|
||||
async def test_overrides_that_conflict_with_the_run_settings_fail_the_card():
|
||||
# 画图时对着缺省值校验能过(缺省「超出常规波动」是 2);这次运行的设置把它调到 3,卡上覆盖的「明显超出」2.5 就永远判不出
|
||||
card = node("card", "analysis", items=[WHERE], overrides={"k_alert": 2.5})
|
||||
graph = chain(node("start", "input"), node("by_region", "tool", tool=TOOL, args={"sql": BY_REGION}), card)
|
||||
run = await run_manager.start(graph=graph, input_payload={}, options={"analysis": {"k_warn": 3.0}})
|
||||
row = await wait(run.id)
|
||||
assert row.status == "failed"
|
||||
assert "阈值覆盖和这次运行的分析设置冲突:「明显超出」的倍数要大于「超出常规波动」的倍数" in row.error
|
||||
assert await events(row.id, "analysis.end", "card") == []
|
||||
ok = await run_manager.start(graph=graph, input_payload={}, options={"analysis": {"k_warn": 2.0}})
|
||||
assert (await wait(ok.id)).status == "succeeded"
|
||||
|
||||
Reference in New Issue
Block a user