Skip to content

Expose the environment's message types as .proto text #144

Open

Description

@galshi

env.config().to_yaml() names each variable's message type, but not its fields, so the environment can't be shown in full:

uv run --no-project --with cel-expr-python==0.1.4 --with protobuf python - <<'EOF'
from cel_expr_python import cel
from google.protobuf import descriptor_pb2, descriptor_pool

file = descriptor_pb2.FileDescriptorProto(name="probe.proto", package="probe", syntax="proto3")
file.message_type.add(name="Row").field.add(name="text", number=1, type=9, label=1)  # string text = 1;
pool = descriptor_pool.DescriptorPool()
pool.Add(file)

env = cel.NewEnv(descriptor_pool=pool, variables={"self": cel.Type("probe.Row")})
print(env.config().to_yaml())  # names the type probe.Row, but not its field text
# variables:
#  - name: "self"
#   type: "probe.Row"
EOF

Python's protobuf (upb) has no .proto printer, but the C++ protobuf this module links has one (FileDescriptor::DebugString()). Could the binding expose it, for example as the .proto text of each file the environment's types come from?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions