feat(v2): 实现SQLite对公租赁经验加工与卡片预审轨迹闭环
This commit is contained in:
@@ -112,13 +112,19 @@ def _view(snapshot_id: str, key: str, as_of: str | None = None) -> ProbabilityVi
|
||||
"scenario_key": key, "label": DEMO_LABEL})
|
||||
|
||||
|
||||
def _target(key, dimension_ids):
|
||||
aliases = {'assume_bank_flow': ('DC-CASH', 'corporate.cashflow'),
|
||||
'assume_title': ('DC-TITLE', 'corporate.title')}
|
||||
return next((name for name in aliases[key] if name in set(dimension_ids)), None)
|
||||
|
||||
|
||||
def _assumptions_for(keys, dimension_ids) -> list[SimulationAssumption]:
|
||||
known = set(dimension_ids)
|
||||
chosen: list[SimulationAssumption] = []
|
||||
for key in ASSUMPTIONS:
|
||||
if key not in set(keys or ()):
|
||||
continue
|
||||
item = ASSUMPTIONS[key]
|
||||
item = dict(ASSUMPTIONS[key], dimension_id=_target(key, known) or ASSUMPTIONS[key]["dimension_id"])
|
||||
if item["dimension_id"] not in known:
|
||||
raise AssumptionConflict(
|
||||
f"假设动作 {key} 指向本次方案不存在的维度 {item['dimension_id']}")
|
||||
@@ -165,9 +171,9 @@ def available_assumptions(run_view: dict) -> list[dict]:
|
||||
服务端也不靠"忽略无效动作"来掩饰不匹配(E-22)。
|
||||
"""
|
||||
known = {item["id"] for item in run_view.get("dimension_results") or ()}
|
||||
return [{"key": key, "label": item["label"], "dimension_id": item["dimension_id"],
|
||||
return [{"key": key, "label": item["label"], "dimension_id": _target(key, known),
|
||||
"assumed_stage": item["assumed_stage"], "premise": item["premise"]}
|
||||
for key, item in ASSUMPTIONS.items() if item["dimension_id"] in known]
|
||||
for key, item in ASSUMPTIONS.items() if _target(key, known)]
|
||||
|
||||
|
||||
def _baseline_view(run_view: dict) -> ProbabilityView:
|
||||
|
||||
Reference in New Issue
Block a user