bugfix
This commit is contained in:
parent
d49ca32878
commit
5f852140a9
@ -24,33 +24,33 @@ aeval = Interpreter()
|
||||
|
||||
# 2. 在你的 node_transfer 或条件判断逻辑中
|
||||
def safe_eval_condition(cond_str, ctx_dict):
|
||||
"""
|
||||
安全地评估条件表达式
|
||||
Args:
|
||||
cond_str: 表达式字符串,例如 "ctx['age'] > 18 and ctx['score'] >= 60"
|
||||
ctx_dict: 上下文数据字典
|
||||
Returns: None 错误或的确是None
|
||||
其他: 表达式结果
|
||||
"""
|
||||
try:
|
||||
# 将 ctx 注入到 asteval 的符号表中
|
||||
aeval.symtable['ctx'] = ctx_dict
|
||||
"""
|
||||
安全地评估条件表达式
|
||||
Args:
|
||||
cond_str: 表达式字符串,例如 "ctx['age'] > 18 and ctx['score'] >= 60"
|
||||
ctx_dict: 上下文数据字典
|
||||
Returns: None 错误或的确是None
|
||||
其他: 表达式结果
|
||||
"""
|
||||
try:
|
||||
# 将 ctx 注入到 asteval 的符号表中
|
||||
aeval.symtable['ctx'] = ctx_dict
|
||||
|
||||
# 执行表达式
|
||||
# mode='eval' 表示只允许单个表达式,不允许语句(如赋值、import)
|
||||
result = aeval(cond_str, mode='eval')
|
||||
# 执行表达式
|
||||
# mode='eval' 表示只允许单个表达式,不允许语句(如赋值、import)
|
||||
result = aeval(cond_str, mode='eval')
|
||||
|
||||
# 检查是否有语法错误或运行时错误
|
||||
if aeval.error:
|
||||
print(f"asteval Error: {aeval.error}")
|
||||
return False
|
||||
# 检查是否有语法错误或运行时错误
|
||||
if aeval.error:
|
||||
print(f"asteval Error: {aeval.error}")
|
||||
return False
|
||||
|
||||
return bool(result)
|
||||
return bool(result)
|
||||
|
||||
except Exception as e:
|
||||
# asteval 通常很安全,但以防万一
|
||||
print(f"Eval Exception: {e}")
|
||||
return False
|
||||
except Exception as e:
|
||||
# asteval 通常很安全,但以防万一
|
||||
print(f"Eval Exception: {e}")
|
||||
return False
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Table definitions
|
||||
@ -527,11 +527,11 @@ where instance_id=${instance_id}$
|
||||
async def task_error_callback(self, ne_id, errmsg):
|
||||
env = Server()
|
||||
async with get_sor_context(env, 'dagflow') as sor:
|
||||
recs = await sor.R('node_execution', {'id': ne_id})
|
||||
if not recs:
|
||||
debug(f'{ne_id=} 没找到node_execution记录')
|
||||
return
|
||||
ne = recs[0]
|
||||
recs = await sor.R('node_execution', {'id': ne_id})
|
||||
if not recs:
|
||||
debug(f'{ne_id=} 没找到node_execution记录')
|
||||
return
|
||||
ne = recs[0]
|
||||
ne.status = 'failed',
|
||||
ne.output = errmsg
|
||||
await sor.U('node_execution', ne)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user