INNER CODE UNIT · Python
calculation_id
simonlin1212/Vibe-Research · calc/cli.py:258
def calculation_id(function: str, ident_args: dict, refs: list[dict]) -> str:
key = json.dumps({"f": function, "v": CALC_VERSION, "a": _canon(ident_args), "r": refs},
sort_keys=True, ensure_ascii=False, separators=(",", ":"))
return "calc-" + hashlib.sha256(key.encode("utf-8")).hexdigest()[:16]
def run(function: str, args: dict, evidence_ids: list | None = None, calc_ids: list | None = None,
run_dir: str | None = None) -> dict:
if function not in FUNCTIONS:
return {"calculation_id": None, "function": function, "calc_version": CALC_VERSION, "inputs": args,
"inputs_resolved": {}, "inputs_refs": [], "output": _error_out(f"未知函数 {function}")}
fn = FUNCTIONS[function]
try:
refs = normalize_refs(evidence_ids or [], calc_ids or [])
except ValueError as e:
return {"calculation_id": None, "function": function, "calc_version": CALC_VERSION, "inputs": args,
"inputs_resolved": {}, "inputs_refs": [], "output": _error_out(str(e), "bad_refs")}
try: