CompiledRunner Functions Bug
@Quantum0uasar がすでに取り組んでいます。
2026年6月1日 から。
評価
この issue はまだ評価されていません。
説明
Hello,
First of all thanks for producing this library very useful for some applications I'm looking at right now.
I'm trying to use the CompiledRunner with some additional functions defined, short example below:
{
'lower': celpy.celtypes.FunctionType,
'upper': celpy.celtypes.FunctionType
}
def lower(lhs: celpy.celtypes.StringType) -> celpy.celtypes.StringType:
return celpy.celtypes.StringType(lhs.lower())
def upper(lhs: celpy.celtypes.StringType) -> celpy.celtypes.StringType:
return celpy.celtypes.StringType(lhs.upper())
env = celpy.Environment(annotations=declarations, runner_class=CompiledRunner)
rule = "size(items) == 1 && meta.device.lower() == 'tablet'"
ast = env.compile(rule)
prgm = env.program(ast, functions={
'lower': lower,
'upper': upper
})
prgm.evaluate({'items': [1,2,3], 'meta': {'device': 'tablet'}})
This works normally when using the InterpretedRunner, however with the compiled runner I get the following:
TypeError: <class 'celpy.evaluation.CELEvalError'> CELEvalError(*('no such overload', <class 'TypeError'>, ('<class \'celpy.evaluation.CELEvalError\'> CELEvalError(*(\'undeclared reference to "name \\\'__main__\\\' is not defined" (in container ())\', <class \'NameError\'>, ("name \'__main__\' is not defined",))) and <class \'celpy.evaluation.CELEvalError\'> CELEvalError(*(\'undeclared reference to "name \\\'__main__\\\' is not defined" (in container ())\', <class \'NameError\'>, ("name \'__main__\' is not defined",)))',))) or <class 'celpy.evaluation.CELEvalError'> CELEvalError(*('undeclared reference to "name \'__main__\' is not defined" (in container ())', <class 'NameError'>, ("name '__main__' is not defined",)))
I dumped out the source from the compiled runner:
# conditionaland:
ex_2_l = lambda activation: celpy.evaluation.bool_eq(celpy.evaluation.function_size(activation.items), celpy.celtypes.IntType(1))
ex_2_r = lambda activation: celpy.evaluation.bool_eq(__main__.lower(activation.meta.get('device')), celpy.celtypes.StringType('tablet'))
ex_2 = lambda activation: celpy.celtypes.logical_and(celpy.evaluation.result(activation, ex_2_l), celpy.evaluation.result(activation, ex_2_r))
CEL = celpy.evaluation.result(base_activation, ex_2)
Internal error: CELEvalError(*('undeclared reference to "name \'__main__\' is not defined" (in container ())', <class 'NameError'>, ("name '__main__' is not defined",)))
This also happens when you use a lambda rather than referencing a function.
Looks like this may not be referencing the function correctly? Happy to assist if you want to point me in the right direction for resolution, or if this is an error on my part please let me know.
Thanks
- 主要言語
- Python
- スター
- 174
- フォーク
- 40
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cloud-custodian/cel-python のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cloud-custodian/cel-python#180 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
cloud-custodian/cel-python#194 ·
-
documentation enhancement tracking
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
cloud-custodian/cel-python#182 ·
-
Refresh Features オープンdependencies
cloud-custodian/cel-python#172 · コメント 2 件 · 担当者 1 名 ·
-
enhancement
cloud-custodian/cel-python#169 · コメント 3 件 · 担当者 1 名 ·
cloud-custodian/cel-python の issue をすべて見る
似ている issue
-
bug confirmed issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
open-webui/open-webui#30750 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 90/100