-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Clientside Callbacks #266
Comments
This is super exciting, as it will greatly increase the range of contexts where Dash can be used. The plan to have serverless components be available within a server-connected app is a great idea. I've often found myself swapping bits of pre-computed layout in and out using callbacks. Having to do an entire round-trip just to change the page layout is not ideal. This will allow for much more responsive single-page apps. |
In theory, this would open up Dash apps to be used with different React renderers, such as these https://github.com/chentsulin/awesome-react-renderer right? Very exciting! |
hey , guys. I think you make problems complicated. |
Thanks for chiming in @Tasselmi !
This will be possible if you want to just export the However, if you want to convert your Python callbacks to a standalone file, we need some way to run those callbacks without a Python server running. So, that's what this "new language" is proposing: a way to write your Dash callbacks in a way that can be run without a Python server. |
I was looking for this feature before trying out Dash. This would be great |
This would also be a really useful feature by itself as often I would just like to take a snapshot of the html with the existing widget states that have generated that html. |
This is a feature missing from Dash compared to Bokeh autload_static mode. Very excited to see it will come to Dash too! Do you have an ETA for the feature? |
Shooting for late fall, but I'll keep this post updated with progress. Glad you're excited, it's going to be sweet :) |
Hey guys. How is all of this going? I think offline mode is historic. As a data analyst, i will never use Microsoft office any more. |
That's what I'm talking about! It's looking good. I promise to keep this thread updated with developments. All I can say now is that we're shooting for late fall. |
Thank u for ur response. |
@chriddyp Easy way: https://github.com/QQuick/Transcrypt Throw in pyodide if you want the Scipy kitchen sink. Having a custom DSL is nice yes, but having the full power of Python is even nicer. :D |
https://github.com/doconix/pyreact/blob/master/src/scripts/clock.py Needs a bit of work to smooth out the rough edges of React but I think you guys should seriously consider this method. |
Hi, I just wanted to chime in to say that I would love to see this feature as well. Using a standalone dash/plotly plot will be great for relatively lightweight plots with callbacks as a server would likely be overkill. |
While this feature is being develped, I'd like to simply access the htm image generated with dash. I've tried saving the page as htm, following the suggestion from @chriddyp that I saw in a related thread. However, when I load the file, this lasts less than a second on my browser and afterwards I get:
I'm using firefox on a Windows 10 machine. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Things are going well. I promise that I will keep this thread updated with details and progress, so please hang tight. |
I would like to implement some custom interaction in an plotly.offline (or dash) figure. This means embedding custom JS code from python into the generated figure that is hooking directly to the underlying plotly.JS.
Please, could you give me a proper reference how python code is translated (especially, how the user-provided data is exposed/available in JS) when using plotly.offline. |
Count me in as an someone looking forward to serverless Dash apps! Interactive offline plots are easy to share and offer so much utility. I would love to be able to go the step further to incorporate callback features in a standalone file that I can share in an email. Having to use a service to host a dash app is just too much overhead for me to overcome in my work ecosystem. |
Are you still working on this? Would a gamechanger for me. |
This would be huge for me as well. Is it still on the timeline? |
This feature would a great addition to our project too. Looking forward to it coming. |
Can I check out this branch and test it? |
Any update on this? |
Done in #672 |
If anybody puts together a fully serverless dash app using this, it would be great to see an example. (I may try but can't guarantee that I'll get time for it) |
is there any kind of documentation for this already? |
I've seen the examples and it looks promising. If all callbacks are performed clientside, do you think there would be any way to export the Dash app to html+.js in order to allow offline usage? |
DocumentationFor those of you looking for an example, one can be found here: |
I don't know about others, but I was asking for an example (if it's possible) of how to use this to generate a fully clientside app. I suspect it isn't possible at this stage, but would be good for the future as it enables things like s3 hosting of some basic dash apps. Though maybe we would gain very little in using dash over pure react at that point. |
Right, for now this feature is focused on performance, and does not provide a pathway to a fully serverless architecture. |
Does this let me get the corresponding html of a dash plot? I haven't been able to get the raw html yet and it is not clear to me how it can be done with this feature. Has anyone been able to do this? |
From this example did anyone figure out how to output to a single .html file? |
@chriddyp - sorry for tagging you on a closed issue! I have the same question as @mneira10 & @guyms above, seems like a few of us are looking for a way to export the html. Higher up in this thread you mentioned this is possible
would you mind sharing a example of how to do this? Apologize if this is documented somewhere, I went though a lot of the documentation and have not found it yet. Thanks again for all your great work! I asked the same question on the dash community page: https://community.plot.ly/t/export-html-of-dash-app/26754 - I'll be sure to update everyone, if it gets answered or I figure it out. |
As mentioned above in #266 (comment), exporting to standalone HTML is not officially supported right now, this issue ended up focusing on the clientside callback architecture. |
In Dash, changes to component properties in the front-end trigger user-supplied Python functions (@app.callback). This framework is very flexible: users have full control over the Python code that they write in their app.callback functions.
However, app.callback functions are simple. They filter some data or change the color of the chart or display some text. These data transformations, although simple, currently need to be processed entirely over the network in the Python backend. This makes the apps slower than they could be (because of the network delay) and less portable than they could be (because they require a running Python server).
Clientside Callbacks will introduce an interface for describing data transformation relationships between components in JavaScript. These data transformations will happen entirely in the client-side without passing data over the network. The Clientside callbacks Dash framework will enable developers to swap out their python-driven @app.callback functions with javascript-executed data transformations, enabling more performant apps.
As a quick background, here is what Dash Apps currently look like in Python:
The first part describes what the app looks like.
These classes just declaratively describe the names and the props of the React
components that they generate. These objects get serialized as JSON.
The second part of dash apps describe the relationship between graphs.
This sets up "sources" ("inputs") and "sinks" ("outputs")
in the Dash front-end. Whenever any of the Input properties change, the
AJAX call gets made.
It's Reactive like a spreadsheet: as inputs change, the new values propagate
down the dependency graph, updating components in the correct order:
These reactive updates happen entirely server-side through HTTP requests.
(This allows dash developers to do complicated updates or analytics through
their python context).
I think that we could extend this framework to work client-side as well.
Instead of a custom function defining how Inputs ("sources")
update Outputs ("sinks"), we could define a library of transformations components and a syntax for relating input properties to output properties. These transformations could be just be functional React components.
Here are some conceptual examples:

In this example, we're setting the "children" property of the HTML
H3
elementto just be the "value" of the "my-input" component. When "value" changes,
the content of the
H3
element updates to match the new value.I'm wrapping the ID and property with
S
to denote that the string represents a "reactive"property corresponding to the component with the specified ID and that component's
property. (The actual API might be different, just using
s
for conceptual purposes.)Now, consider a "Dataset" component and a "Graph":
Note that not all components actually get rendered in the DOM. In this case,
the Dataset component isn't actually visible. It's just included as state.
If you wanted to view it as a table, it would look like:
You can imagine how there might be several datasets and several graphs in one
(like a dashboard or a report).
Now, we would also need a library for lightweight data transformations. I'm thinking something like Ramda.
Or, extending this with dynamic components:
Here are some high-level architectural requirements and goals for this work item:
mapbox
charts)The text was updated successfully, but these errors were encountered: