Skip to content

Commit 543649b

Browse files
dmitriplotnikovcopybara-github
authored andcommitted
Rename py_cel to cel_expr_python
PiperOrigin-RevId: 868938372
1 parent ac15061 commit 543649b

54 files changed

Lines changed: 206 additions & 206 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CEL Python Wrapper (PyCEL)
1+
# CEL Python Wrapper (cel.expr.python)
22

33
This is a Python wrapper for the CEL C++ implementation.
44

@@ -7,7 +7,7 @@ This is a Python wrapper for the CEL C++ implementation.
77
### Importing CEL module
88

99
```python
10-
from py_cel import py_cel
10+
from cel_expr_python import cel
1111
```
1212

1313
### Creating and configuring Cel
@@ -16,12 +16,12 @@ To create a CEL environment, you need to define
1616
variable types that can be used in expressions.
1717

1818
```python
19-
cel_env = py_cel.NewEnv(variables={"x": py_cel.Type.INT, "y": py_cel.Type.INT})
19+
cel_env = cel.NewEnv(variables={"x": cel.Type.INT, "y": cel.Type.INT})
2020
```
2121

2222
#### Optional configuration parameters
2323

24-
The `py_cel.NewEnv` constructor also accepts the following optional parameters:
24+
The `cel.NewEnv` constructor also accepts the following optional parameters:
2525

2626
* `pool` (`descriptor_pool.DescriptorPool`): The descriptor pool used for
2727
resolving protobuf message types within CEL expressions. If not provided,
@@ -115,7 +115,7 @@ of the associated objects are released until the last object using the arena is
115115
garbage-collected in Python.
116116

117117
```python
118-
arena = py_cel.Arena()
118+
arena = cel.Arena()
119119

120120
activation1 = cel_env.Activation({"x": 7, "y": 4}, arena)
121121
# evaluate some expressions
@@ -135,19 +135,19 @@ You can pass protobuf messages as variables to an activation; CEL
135135
expressions can return protobuf messages.
136136

137137
First, ensure your proto messages are available in the descriptor pool used by
138-
`py_cel.NewEnv`, by importing your proto library in Python:
138+
`cel.NewEnv`, by importing your proto library in Python:
139139

140140
from cel.expr.conformance.proto2 import test_all_types_pb2 as test_pb
141141

142-
Then declare any variables of message type using `py_cel.Type` with their fully
142+
Then declare any variables of message type using `cel.Type` with their fully
143143
qualified name.
144144

145145
```python
146146
# Declare 'msg_var' as a message type.
147-
cel = py_cel.NewEnv(
147+
cel = cel.NewEnv(
148148
pool,
149149
variables={
150-
"msg_var": py_cel.Type("cel.expr.conformance.proto2.TestAllTypes"),
150+
"msg_var": cel.Type("cel.expr.conformance.proto2.TestAllTypes"),
151151
},
152152
)
153153
```
@@ -192,13 +192,13 @@ Resulting message value: 123
192192

193193
#### Standard extensions
194194

195-
Standard extensions are available under `py_cel.ext`.
195+
Standard extensions are available under `cel_expr_python.ext`.
196196

197197
```python
198-
from py_cel.ext import ext_math
198+
from cel_expr_python.ext import ext_math
199199

200-
cel = py_cel.NewEnv(pool, extensions=[ext_math.ExtMath()])
201-
expr = cel_env.compile("math.sqrt(4)")
200+
env = cel.NewEnv(pool, extensions=[ext_math.ExtMath()])
201+
expr = env.compile("math.sqrt(4)")
202202
```
203203

204204
#### Defining a custom extension in Python
@@ -209,24 +209,24 @@ You can define custom functions and pass them as an extension.
209209
def my_func_impl(x):
210210
return x + 1
211211

212-
my_ext = py_cel.CelExtension(
212+
my_ext = cel.CelExtension(
213213
"my_extension",
214214
[
215-
py_cel.FunctionDecl(
215+
cel.FunctionDecl(
216216
"my_func",
217217
[
218-
py_cel.Overload(
218+
cel.Overload(
219219
"my_func_int",
220-
py_cel.Type.INT,
221-
[py_cel.Type.INT],
220+
cel.Type.INT,
221+
[cel.Type.INT],
222222
impl=my_func_impl,
223223
)
224224
],
225225
)
226226
],
227227
)
228228

229-
cel_env = py_cel.NewEnv(pool, extensions=[my_ext])
229+
cel_env = cel.NewEnv(pool, extensions=[my_ext])
230230
expr = cel_env.compile("my_func(1)")
231231
```
232232

@@ -311,23 +311,23 @@ pybind_extension(
311311
name = "translation_cel_ext",
312312
srcs = ["translation_cel_ext.cc"],
313313
data = [
314-
"@py_cel:py_cel",
314+
"@cel_expr_python:cel",
315315
]
316316
deps = [
317-
"@py_cel:py_cel",
318-
"@py_cel:py_cel_extension",
319-
"@py_cel:status_macros",
317+
"@cel_expr_python:cel",
318+
"@cel_expr_python:cel_extension",
319+
"@cel_expr_python:status_macros",
320320
...
321321
],
322322
)
323323
```
324324

325-
Now you can use the extension in PyCel:
325+
Now you can use the extension in cel_expr_python:
326326

327327
```python
328328
import translation_cel_ext
329329

330-
cel_env = py_cel.NewEnv(variables={},
330+
cel_env = cel.NewEnv(variables={},
331331
extensions=[translation_cel_ext.TranslationCelExtension()])
332332

333333
expr = cel_env.compile("'Hello, world!'.translate('en', 'es')")
@@ -341,16 +341,16 @@ simply leave the implementation parameter unspecified:
341341

342342
```python
343343

344-
my_ext = py_cel.CelExtension(
344+
my_ext = cel.CelExtension(
345345
"my_extension",
346346
[
347-
py_cel.FunctionDecl(
347+
cel.FunctionDecl(
348348
"my_func",
349349
[
350-
py_cel.Overload(
350+
cel.Overload(
351351
"my_func_int",
352-
py_cel.Type.INT,
353-
[py_cel.Type.INT],
352+
cel.Type.INT,
353+
[cel.Type.INT],
354354
# Note: no impl provided here.
355355
)
356356
],
@@ -380,7 +380,7 @@ If the extension is written in C++, use the `RegisterLazyFunction` function:
380380
Now you can bind the function at runtime:
381381
382382
```python
383-
cel_env = py_cel.NewEnv(variables={}, extensions=[my_ext])
383+
cel_env = cel.NewEnv(variables={}, extensions=[my_ext])
384384
expr = cel_env.compile("my_func(42)")
385385
386386
multiplier = 2

py_cel/BUILD renamed to cel_expr_python/BUILD

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports_files(["LICENSE"])
1010

1111
# For Python programs using CEL.
1212
pybind_extension(
13-
name = "py_cel",
13+
name = "cel",
1414
srcs = [
1515
"py_cel_activation.cc",
1616
"py_cel_activation.h",
@@ -117,10 +117,10 @@ cc_library(
117117
)
118118

119119
py_test(
120-
name = "py_cel_test",
121-
srcs = ["py_cel_test.py"],
120+
name = "cel_test",
121+
srcs = ["cel_test.py"],
122122
deps = [
123-
":py_cel",
123+
":cel",
124124
"//testing:proto2_test_all_types_py_pb2",
125125
"@com_google_absl_py//absl/testing:absltest",
126126
"@com_google_protobuf//:protobuf",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class CelExtension {
5959
std::string name_;
6060
};
6161

62-
#define CEL_MODULE_NAME "py_cel"
62+
#define CEL_MODULE_NAME "cel_expr_python.cel"
6363

6464
// Macro for defining a pybind11 module for a CEL extension. The macro takes two
6565
// arguments: the name of the module and the name of the extension class. It
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
from google.protobuf import duration_pb2 as duration_pb
2424
from google.protobuf import timestamp_pb2 as timestamp_pb
2525
from absl.testing import absltest
26-
from py_cel import py_cel as cel
26+
from cel_expr_python import cel
2727
from cel.expr.conformance.proto2 import test_all_types_pb2 as test_all_types_pb
2828

2929

30-
class PyCelTest(absltest.TestCase):
30+
class CelTest(absltest.TestCase):
3131

3232
def setUp(self):
3333
super().setUp()
@@ -604,7 +604,7 @@ def testDynType_nonCelType(self):
604604
res = self._eval("var_dyn", {"var_dyn": self})
605605
self.assertEqual(res.type(), cel.Type.ERROR)
606606
self.assertIn(
607-
"Non-CEL value type for 'var_dyn': PyCelTest",
607+
"Non-CEL value type for 'var_dyn': CelTest",
608608
res.value(),
609609
)
610610

@@ -804,7 +804,7 @@ def FindFileContainingSymbol(self, symbol_name: str): # pylint: disable=invalid
804804
raise LookupError("Could not find file containing symbol: %s" % symbol_name)
805805

806806

807-
class PyCelWithoutProtoSupportTest(absltest.TestCase):
807+
class CelWithoutProtoSupportTest(absltest.TestCase):
808808
"""Test that the environment can be created without proto support."""
809809

810810
def setUp(self):
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ pybind_extension(
88
"ext_bindings.cc",
99
],
1010
data = [
11-
"//py_cel",
11+
"//cel_expr_python:cel",
1212
],
1313
visibility = ["//visibility:public"],
1414
deps = [
15-
"//py_cel:cel_extension",
15+
"//cel_expr_python:cel_extension",
1616
"@com_google_absl//absl/status",
1717
"@com_google_cel_cpp//compiler",
1818
"@com_google_cel_cpp//extensions:bindings_ext",
@@ -26,11 +26,11 @@ pybind_extension(
2626
"ext_encoders.cc",
2727
],
2828
data = [
29-
"//py_cel",
29+
"//cel_expr_python:cel",
3030
],
3131
visibility = ["//visibility:public"],
3232
deps = [
33-
"//py_cel:cel_extension",
33+
"//cel_expr_python:cel_extension",
3434
"@com_google_absl//absl/status",
3535
"@com_google_cel_cpp//checker:type_checker_builder",
3636
"@com_google_cel_cpp//compiler",
@@ -47,12 +47,12 @@ pybind_extension(
4747
"ext_math.cc",
4848
],
4949
data = [
50-
"//py_cel",
50+
"//cel_expr_python:cel",
5151
],
5252
visibility = ["//visibility:public"],
5353
deps = [
54-
"//py_cel:cel_extension",
55-
"//py_cel:status_macros",
54+
"//cel_expr_python:cel_extension",
55+
"//cel_expr_python:status_macros",
5656
"@com_google_absl//absl/base:nullability",
5757
"@com_google_absl//absl/status",
5858
"@com_google_absl//absl/status:statusor",
@@ -80,11 +80,11 @@ pybind_extension(
8080
"ext_optional.cc",
8181
],
8282
data = [
83-
"//py_cel",
83+
"//cel_expr_python:cel",
8484
],
8585
visibility = ["//visibility:public"],
8686
deps = [
87-
"//py_cel:cel_extension",
87+
"//cel_expr_python:cel_extension",
8888
"@com_google_absl//absl/status",
8989
"@com_google_cel_cpp//compiler",
9090
"@com_google_cel_cpp//compiler:optional",
@@ -101,11 +101,11 @@ pybind_extension(
101101
"ext_proto.cc",
102102
],
103103
data = [
104-
"//py_cel",
104+
"//cel_expr_python:cel",
105105
],
106106
visibility = ["//visibility:public"],
107107
deps = [
108-
"//py_cel:cel_extension",
108+
"//cel_expr_python:cel_extension",
109109
"@com_google_absl//absl/status",
110110
"@com_google_cel_cpp//compiler",
111111
"@com_google_cel_cpp//extensions:proto_ext",
@@ -119,11 +119,11 @@ pybind_extension(
119119
"ext_string.cc",
120120
],
121121
data = [
122-
"//py_cel",
122+
"//cel_expr_python:cel",
123123
],
124124
visibility = ["//visibility:public"],
125125
deps = [
126-
"//py_cel:cel_extension",
126+
"//cel_expr_python:cel_extension",
127127
"@com_google_absl//absl/status",
128128
"@com_google_cel_cpp//compiler",
129129
"@com_google_cel_cpp//extensions:strings",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "absl/status/status.h"
1616
#include "compiler/compiler.h"
1717
#include "extensions/bindings_ext.h"
18-
#include "py_cel/cel_extension.h"
18+
#include "cel_expr_python/cel_extension.h"
1919
#include "google/protobuf/descriptor.h"
2020

2121
namespace cel_python {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "extensions/encoders.h"
1919
#include "runtime/runtime_builder.h"
2020
#include "runtime/runtime_options.h"
21-
#include "py_cel/cel_extension.h"
21+
#include "cel_expr_python/cel_extension.h"
2222
#include "google/protobuf/descriptor.h"
2323

2424
namespace cel_python {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "extensions/math_ext_decls.h"
1919
#include "runtime/runtime_builder.h"
2020
#include "runtime/runtime_options.h"
21-
#include "py_cel/cel_extension.h"
22-
#include "py_cel/status_macros.h"
21+
#include "cel_expr_python/cel_extension.h"
22+
#include "cel_expr_python/status_macros.h"
2323
#include "google/protobuf/descriptor.h"
2424

2525
namespace cel_python {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "runtime/optional_types.h"
1919
#include "runtime/runtime_builder.h"
2020
#include "runtime/runtime_options.h"
21-
#include "py_cel/cel_extension.h"
21+
#include "cel_expr_python/cel_extension.h"
2222
#include "google/protobuf/descriptor.h"
2323

2424
namespace cel_python {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "absl/status/status.h"
1616
#include "compiler/compiler.h"
1717
#include "extensions/proto_ext.h"
18-
#include "py_cel/cel_extension.h"
18+
#include "cel_expr_python/cel_extension.h"
1919
#include "google/protobuf/descriptor.h"
2020

2121
namespace cel_python {

0 commit comments

Comments
 (0)