-
Notifications
You must be signed in to change notification settings - Fork 83
Description
It can currently be a bit laborious to keep the Python bindings up to date when we change either Command or CommandOutput in egglog.
For example, the recent changes to add reporting required adding hundreds of lines of code (egraphs-good/egglog-python#375). I did use AI to help with the process, but I wanted to open this issue to explore another option.
If the rust library supported exported the types of the AST and the outputs in a machine readable format, then I could possibly generate the Python bindings directly. This would still give us type safety in Python, but require less manual updates.
There are many ways this could be done, but one that seems possible would be to use Schemars to generate a JSON schema defeinition from the rust code for Command and CommandOutput.
Then for Python I could use datamodel-code-generator to construct Python types to build the structures in a type safe manner.
There are a few other options, including serde-reflection/generate to emit Python code directly or switching to something like Protocol Buffers to specify the schema and generating both Rust and Python bindings. But schemars seems like the simplest to try at first.
This would also make it easier to construct Egglog from other languages or generate bindings for them.
I don't know if this would be possible without trying it out. I don't know how much, if any, it would require changing the existing rust structures.