Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Vega expression parsing in Python library #168

Open
boydgreenfield opened this issue Apr 16, 2024 · 3 comments
Open

Expose Vega expression parsing in Python library #168

boydgreenfield opened this issue Apr 16, 2024 · 3 comments

Comments

@boydgreenfield
Copy link

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!

@jonmmease
Copy link
Collaborator

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 vega/altair#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!

@boydgreenfield
Copy link
Author

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).

@jonmmease jonmmease transferred this issue from vega/vegafusion Apr 24, 2024
@jonmmease
Copy link
Collaborator

Great, issue transferred!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants