-
Hi Team, first of all, thanks a lot for the great work you are putting into Vegafusion, i really like it! As the source has been evolving a lot in the last couple of months, I am wondering whether it is feasible now to use Vegafusion and the brushing and selection capabilities of Vega outside jupyter, for example in a javascript web application where the Vegafusion client is communicating to Vegafusion server via grpc? Is vegafusion-embed the intended solution? Can you please share an example of the above? Thanks a lot in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 16 replies
-
Hi @prenigma, thanks for the kind works! The architecture of VegaFusion is certainly designed to support the scenario you're describing. But I'll be honest that this hasn't been proven in practice yet, and we don't have a solid example on this scenario at the moment. The closest example is in javascript/vegafusion-chart-editor. This example includes a super-simple Vega editor that communicates with a VegaFusion server instance over gRPC-Web. And yes, vegafusion-embed is the intended client entry point for non-Jupyter usage. Unfortunately, I'm currently having issues getting around a CORS policy error when running the example (FWIW, I created this example more than a year ago on a linux desktop, and I'm now hitting the CORS issue on a mac). Definitely give that a try and see if you run into the same error. Using gRPC-Web isn't a requirement for client-server communication, but (apart from this CORS error) it's the easiest way to have the client communicate directly with the VegaFusion server without any middleware. The Jupyter Widget's usage of vegafusion-embed shows the alternative to using gRPC-Web. Here, the vegafusion-embed constructor is passed a callback function which accepts a protobuf message in binary form, and is responsible for routing those bytes to an instance of the vegafusion-runtime. In the Jupyter widget case, these messages are routed over Jupyter comms to the vegafusion-runtime instance running in the Python kernel (in the vegafusion-python-embed package). But these bytes could also be routed over websockets to some middleware application and then dispatched to a vegafusion-server instance over (non-web) gRPC. If you have more thoughts on the architecture you'd like to end up with, I'd be happy to work with you on building an example that fits your use case. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot, Jon for the quick and detailed answer. I will try what you suggested and turn back to you as soon I try the proposed directions! |
Beta Was this translation helpful? Give feedback.
-
Hi @prenigma, I think I got all of the issues worked out in the chart editor example over in #276. Let me know if you're interested in trying to get this working. The changes to vegafusion-server will be included in version 1.1.0 early next week. |
Beta Was this translation helpful? Give feedback.
-
Hi Jon @jonmmease, thanks a lot for the update! I am really interested in trying it out! Can you also share the steps you executed to replicate what you presented on the PR? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Sure. At the moment you'll need to clone the VegaFusion repo and compile There are development setup instructions in BUILD.md. I know there's a lot there, so let me know if you run into issues. Once you have the development environment here are the steps: Compile vegafusion-wasmIn the
Compile vegafusion-embedIn the
Compile and run vegafusion-serverIn the
Launch the chart editorIn the
Once 1.1.0 is released, I think I'll move this chart editor example out into a separate repository and add instructions that only depend on the published versions of vegafusion-server, vegafusion-wasm, and vegafusion-embed. So feel free to wait until next week to try out that approach. |
Beta Was this translation helpful? Give feedback.
-
I got 1.1.0 published this evening and moved the editor demo to https://github.com/hex-inc/vegafusion-demos/tree/main/apps/vegafusion-editor-grpc-web. See the README instructions there. With this approach you just download vegafusion-server 1.1.0 from GitHub releases, and launch the app with Let me know how it works out for you! |
Beta Was this translation helpful? Give feedback.
-
Hi Jon, thanks a lot for the work you put into the demo, it works very well! I spent the last couple of days understanding further your code. My goal is to create the following architecture demo: The python server will allow loading data/table e.g., pandas dataframe, and register this dataframe in the vegafusion-server. The JS client/Webapp, like the vegafusion-editor example, will render the chart for a specific dataframe registered in the vegafusion-server. I have found under the vegafusion python module, in the method pre_transform_datasets for example a mention of inline datasets under the syntax 'vegafusion+dataset://{dataset_name}' or 'table://{dataset_name}' I also found the following 2 methods set_connection and grpc_connect under the class runtime in the module vegafusion which are expected to connect to vegafusion-server and return the list of tables of a connection. Can you please guide me further on how to build such an example architecture? I believe most of the functionalities/methods are available in your implementation, but i need your guidance on how to bring the different blocs together to make this architecture work. An example of how vegafusion python module, vegafusion-server and vegafusion-embed work together to render a chart for a specfic table ('vegafusion+dataset://{dataset_name}' or 'table://{dataset_name}') will be very helpful Thanks a lot |
Beta Was this translation helpful? Give feedback.
-
Hi @prenigma, this looks great. I'm happy to make another example, let me just clarify a few things. vegafusion-server vs vegafusion in PythonIf you're happy with the server portion of the app being written in Python, then it might be easiest to use VegaFusion embedded in Python (as the
Do either of those apply to your usecase? Also to note, the Pre-transform vs Live connection workflowsVegaFusion has two primary workflows: pre-transform workflowThe pre-transform workflow starts with a Vega spec, pre-evaluates all of the transforms and creates a new Vega spec that has the transformed data inlined. This is how the Mime Renderer works, and the advantage is that it doesn't require a live connection between the client and server, and it doesn't require the vegafusion-embed package on the client since the resulting Vega spec can be rendered using the regular vega-embed library. The The downside of this approach is that, because there's no live connection between the client and server, any data that is filtered based on selection interactions must be shipped to the client in the transformed spec. So it's not a good choice for examples like Interactive Average, Crossfilter, or Cross Highlight. Live connection workflowThis needs a better name, but this refers to the workflow that VegaFusion Widget and the gRPC-Web demo use. In this case the vegafusion-embed library is used in the client to render the chart and maintain a live connection between the client and the VegaFusion runtime (either running inside vegafusion-python-embed or in VegaFusion Server). This has the advantage that interactive filtering can happen on the server, so the full dataset isn't sent to the client in the examples noted above. A downside of this approach is that there's not a good way to register inline datasets and use For the live connection workflow, a choice needs to be made for how the messages are transported between the Python server and the client. gRPC-Web is the most integrated approach, but this can be customized. For example, VegaFusion Widget routes these messages over Jupyter Comms. If gRPC-Web isn't an option, then it would be also possible to route the messages to a rest endpoint by base64 encoding the protobuf messages to strings (at the loss of some efficiency of course). SummaryAs a summary, given a Python server, here are the choices to make:
Let me know what you think! |
Beta Was this translation helpful? Give feedback.
-
Hi Jon, can you please support me by pointing me where to start to point the VegaFusion server to S3 instead of pointing to local files? Many thanks |
Beta Was this translation helpful? Give feedback.
-
Hi @prenigma, I wanted to check in to see if you're still making use of this workflow. I'm working on simplifying VegaFusion for version 2, and I'm debating whether to keep |
Beta Was this translation helpful? Give feedback.
-
Hi Jon, apologies missed your message! Yes, i am still using the workflow of having a vegafusion-server and vegafusion-wasm on the frontend. I am also thinking whether we could further scale the vegafusion-server by integrating with datafusion-ballista. I would be happy to further brainstorm with you. Thanks |
Beta Was this translation helpful? Give feedback.
Hi @prenigma, thanks for the kind works!
The architecture of VegaFusion is certainly designed to support the scenario you're describing. But I'll be honest that this hasn't been proven in practice yet, and we don't have a solid example on this scenario at the moment. The closest example is in javascript/vegafusion-chart-editor.
This example includes a super-simple Vega editor that communicates with a VegaFusion server instance over gRPC-Web. And yes, vegafusion-embed is the intended client entry point for non-Jupyter usage. Unfortunately, I'm currently having issues getting around a CORS policy error when running the example (FWIW, I created this example more than a year ago on a linux de…