vl-convert
vl-convert copied to clipboard
Expose Vega expression parsing in Python library
Thank you for the great library @jonmmease. Have you considered / what do you think about exposing the Vega expression parsing in the Python library so a user can validate, manipulate, or otherwise inspect a Vega expression without having to go through transformed_data
(and getting a fairly generic Python ValueError
).
I'm a little, ahem, rusty, but could be persuaded to help if this is something you'd like to support and you have guidance on a preferred implementation approach. Thanks again!
Thanks for the kind words @boydgreenfield. I'm definitely open to exposing more of VegaFusion's functionality through the Python API.
That said, for the use case of inspecting / evaluating Vega expressions, I would lean toward building this into vl-convert rather than VegaFusion. vl-convert bundles the Deno JavaScript runtime into a Python package for the primary purpose of static image export. With this setup, we already have the ability to call Vega functions from Python (through Rust), and we could add additional entry points for passing in individual expressions rather than full Vega specifications. The advantage of this approach over using VegaFusion is that it would support the entire Vega expression language, whereas VegaFusion only supports a subset at this point. This assumes that compatibility is more important than performance of course.
Also see https://github.com/vega/altair/issues/3365 for some more discussion.
If you're interested in this approach, I'll transfer this issue to the vl-convert repo. Then the next step would be to design the vl-convert API for working with expressions. So if you have specific examples of what you'd like to be able to do (or even better API ideas) that would be helpful!
Apologies for the slow reply @jonmmease. Yes happy to discuss this in the context of vl-convert
and I'll give some thought to API design and comment once the issue is moved there.
For context, I'm working on a proof-of-concept around "natural language for data viz" (https://minard.ai) and it'd be nice to be able to parse arbitrary Vega-Expressions in addition to evaluating transforms as is supported in vegafusion
. In this case, we're experimenting with LLM-generated expressions (e.g., calculations and filters) and want to be able to parse -> validate -> retry with feedback as needed. But, I think the same functionality would be useful for arbitrary user-written Vega as well Expressions (which we may do at some point too).
Great, issue transferred!