You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanclass="sd"> Contains the current evaluation context.</span>
308
-
<spanclass="sd"> The :py:meth:`Environment.compile` method</span>
318
+
319
+
<spanclass="sd"> CEL integration starts by creating an :py:class:`Environment` object.</span>
320
+
<spanclass="sd"> This can be initialized with three optional values:</span>
321
+
322
+
<spanclass="sd"> - A package name used to resolve variable names.</span>
323
+
<spanclass="sd"> This is not generally required, but is sometimes helpful to provide an explicit namespace for variables.</span>
324
+
325
+
<spanclass="sd"> - Type annotations for variables.</span>
326
+
<spanclass="sd"> This helps perform type conversions on external data.</span>
327
+
328
+
<spanclass="sd"> - The class of runner to use. By default an :py:class:`InterpretedRunner` is used.</span>
329
+
<spanclass="sd"> The alternative is the :py:class:`CompiledRunner`.</span>
330
+
<spanclass="sd"> Detailed performance benchmarks are still pending.</span>
331
+
<spanclass="sd"> Detailed logging is available from the interpreted runner, to help debug external function bindings.</span>
332
+
333
+
<spanclass="sd"> Once the environment has been created, the :py:meth:`Environment.compile` method</span>
309
334
<spanclass="sd"> compiles CEL text to create an AST.</span>
335
+
<spanclass="sd"> This can be helpful for an application that needs to prepare error messages based on the AST.</span>
336
+
<spanclass="sd"> An application can also optimize or transform the AST.</span>
310
337
311
338
<spanclass="sd"> The :py:meth:`Environment.program` method</span>
312
-
<spanclass="sd"> packages the AST into a program ready for evaluation.</span>
339
+
<spanclass="sd"> packages the AST into a :py:class:`Runnable` ready for evaluation.</span>
340
+
<spanclass="sd"> At this time, external functions are bound to the CEL expression.</span>
341
+
<spanclass="sd"> The :py:class:`Runnable` can be evaluated repeatedly with multiple inputs, avoiding the overheads of compiling for each input value.</span>
313
342
314
343
<spanclass="sd"> .. todo:: For a better fit with Go language expectations</span>
315
344
@@ -364,7 +393,20 @@ <h1>Source code for celpy.__init__</h1><div class="highlight"><pre>
<spanclass="sd"> Transforms the AST into an executable :py:class:`Runner` object.</span>
421
+
<spanclass="sd"> This will bind the given functions into the runnable object.</span>
422
+
423
+
<spanclass="sd"> The resulting object has a :py:meth:`Runner.evaluate` method that applies the CEL structure to input data to compute the final result.</span>
379
424
380
425
<spanclass="sd"> :param expr: The parse tree from :py:meth:`compile`.</span>
381
426
<spanclass="sd"> :param functions: Any additional functions to be used by this CEL expression.</span>
@@ -422,7 +467,7 @@ <h1 class="logo"><a href="../../index.html">CEL in Python</a></h1>
0 commit comments