3232#include " cel_expr_python/py_cel_env_internal.h"
3333#include " cel_expr_python/py_cel_expression.h"
3434#include " cel_expr_python/py_cel_function_decl.h"
35+ #include " cel_expr_python/py_cel_options.h"
3536#include " cel_expr_python/py_cel_type.h"
3637#include " cel_expr_python/py_error_status.h"
3738#include < pybind11/pybind11.h>
@@ -81,7 +82,8 @@ void PyCelEnv::DefinePythonBindings(pybind11::module& m) {
8182 std::optional<std::vector<std::shared_ptr<PyCelFunctionDecl>>>&
8283 functions,
8384 std::optional<std::unordered_map<std::string, py::object>>&
84- function_impls) {
85+ function_impls,
86+ std::optional<PyCelOptions>& options) {
8587 PyObject* pool_ptr;
8688 if (descriptor_pool.is_none ()) {
8789 // Replicates python's `descriptor_pool.Default()`
@@ -119,7 +121,10 @@ void PyCelEnv::DefinePythonBindings(pybind11::module& m) {
119121 }
120122 }
121123
122- return PyCelEnv (config.value_or (PyCelEnvConfig ()), pool_ptr,
124+ PyCelOptions env_options = options.value_or (PyCelOptions ());
125+
126+ return PyCelEnv (config.value_or (PyCelEnvConfig ()), env_options,
127+ pool_ptr,
123128 std::move (variables).value_or (
124129 std::unordered_map<std::string, PyCelType>{}),
125130 ext_ptrs, std::move (expr_container),
@@ -131,10 +136,12 @@ void PyCelEnv::DefinePythonBindings(pybind11::module& m) {
131136 py::arg (" descriptor_pool" ) = py::none (), py::arg (" config" ) = py::none (),
132137 py::arg (" variables" ) = py::none (), py::arg (" extensions" ) = py::none (),
133138 py::arg (" container" ) = py::none (), py::arg (" functions" ) = py::none (),
134- py::arg (" function_impls" ) = py::none ());
139+ py::arg (" function_impls" ) = py::none (), py::arg ( " options " ) = py::none () );
135140 cel_class
136141 .def (" config" ,
137142 [](PyCelEnv& self) { return self.GetEnv ()->GetEnvConfig (); })
143+ .def (" options" ,
144+ [](PyCelEnv& self) { return self.GetEnv ()->GetOptions (); })
138145 .def (" compile" , &PyCelEnv::Compile, py::arg (" expression" ),
139146 py::arg (" disable_check" ) = false )
140147 .def (" deserialize" , &PyCelEnv::Deserialize, py::arg (" serialized" ))
@@ -165,14 +172,15 @@ void PyCelEnv::DefinePythonBindings(pybind11::module& m) {
165172}
166173
167174PyCelEnv::PyCelEnv (
168- const PyCelEnvConfig& config, PyObject* descriptor_pool,
175+ const PyCelEnvConfig& config, const PyCelOptions& options,
176+ PyObject* descriptor_pool,
169177 const std::unordered_map<std::string, PyCelType>& variable_types,
170178 const std::vector<PyObject*>& extensions,
171179 cel::ExpressionContainer container,
172180 const std::vector<std::shared_ptr<PyCelFunctionDecl>>& functions,
173181 const std::unordered_map<std::string, py::object>& function_impls) {
174182 env_ = ThrowIfError (PyCelEnvInternal::NewCelEnvInternal (
175- config, descriptor_pool, std::move (variable_types), extensions,
183+ config, options, descriptor_pool, std::move (variable_types), extensions,
176184 std::move (container), std::move (functions), std::move (function_impls)));
177185 ABSL_CHECK (PyGILState_Check ());
178186}
0 commit comments