Comments (10)
I've created a self-contained example of this here. Since it requires some backend infrastructure I decided to create a separate repo rather than put everything in the examples folder of this repo.
You can see the example deployed here (note I'm not paying for the deployment, so the limited resources might mean it is a bit slow to load or something).
The example lets you type a string into a dbc.Textarea
, then when you click the button it iterates slowly over the characters one by one, converting them to upper case. This long running task is handled by a task queue and a background worker. The progress is cached in Redis and used to update a dbc.Progress
component back in the app layout.
Give me a shout if anything is unclear. I have a few ideas for improving / simplifying it, but it works as is for now. I'm also going to work separately on an example for getting a progress bar while uploading files which works a little differently to this.
from dash-bootstrap-components.
Since there's clearly a lot of interest in this I'll prioritise coming up with a clean example demonstrating how this can be done.
from dash-bootstrap-components.
@tcbegley Since the loading component is officially out, could you create a minimal example on how to load a large csv file / downloading a file utilizing progress bar? Thanks
from dash-bootstrap-components.
Hi @RayPalmerTech
Really glad to hear you're enjoying dash-bootstrap-components!
This sort of thing can be a bit fiddly in Dash. It's going to be easier in the future I think with the new loading states api and Loading
component that was previewed in December.
If you want to do something more manually with Progress
, you have to do it asynchronously. I.e. start your query with one callback, then periodically check for completion on an interval and do something when the query is complete. As a starting point you might find this comment useful.
More generally you could look at using some kind of task queue like celery or redis-queue (rq). I've used the latter successfully before in a Dash app, and found this blog post helpful when setting it up. It's written for Flask apis rather than Dash callbacks, but the same principles apply.
Sorry I couldn't give you something more concrete to work with, but hopefully some of those links will be a useful starting point.
from dash-bootstrap-components.
Hooray! @tcbegley
from dash-bootstrap-components.
This works, but seems unnecessarily complicated. A future suggestion would be to have an Output() style function that can be called in the middle of a callback. This is how other GUI software works, e.g. Matlab.
from dash-bootstrap-components.
@tcbegley I would also really like an example. We're having this exact problem. We use RQ to process our functions/files but would like to use the Progress
bar to indicate how that process is coming.
from dash-bootstrap-components.
Thank you, this looks perfect. Added integrating a progress bar to our next sprint. @tcbegley
from dash-bootstrap-components.
I'm going to close this for now, but feel free to reopen if you need any of the above clarified.
from dash-bootstrap-components.
@chriddyp I would appreciate if you can provide an example as I have a similar problem.
from dash-bootstrap-components.
Related Issues (20)
- Support tooltips without IDs HOT 3
- [Bug] Console warning on dbc.Tooltip component HOT 3
- Web site is not showing components HOT 5
- Graphs in tabs example not rendering HOT 2
- Support 'clearable' in Input HOT 1
- Allow not showing up-down arrows in numeric HOT 1
- [BUG] dbc.Modal(style) is passed to fade-modal-show layer instead modal HOT 3
- Bootstrap stopped working HOT 4
- [docs] Burger hard to see in dark mode
- dbc.Spinner() intial load lags on launch HOT 2
- Enter does not change line inside textarea component HOT 1
- Debounce support for numeric value of seconds (like dcc.Input)
- [POPOVER] Legacy trigger error inside an iframe
- Allow icons and html in `dbc.AccordionItem()` title HOT 3
- Remove migration guide in docs
- selected attribute for dbc.Select HOT 1
- `dbc.Checklist` does not accept `label` as `list[Component]` like `dcc.Checklist` does HOT 3
- dash_bootstrap_components version versus python version HOT 5
- Nested tabs in `Offcanvas` component trigger scroll up event on tab change HOT 2
- Tooltip closing race condition with children change callback HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dash-bootstrap-components.