Giter Site home page Giter Site logo

Comments (10)

tcbegley avatar tcbegley commented on May 22, 2024 6

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.

tcbegley avatar tcbegley commented on May 22, 2024 5

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.

happyshows avatar happyshows commented on May 22, 2024 4

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

tcbegley avatar tcbegley commented on May 22, 2024 3

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.

CaseGuide avatar CaseGuide commented on May 22, 2024 2

Hooray! @tcbegley

from dash-bootstrap-components.

toddkarin avatar toddkarin commented on May 22, 2024 2

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.

CaseGuide avatar CaseGuide commented on May 22, 2024 1

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

@happyshows

from dash-bootstrap-components.

CaseGuide avatar CaseGuide commented on May 22, 2024 1

Thank you, this looks perfect. Added integrating a progress bar to our next sprint. @tcbegley

from dash-bootstrap-components.

tcbegley avatar tcbegley commented on May 22, 2024

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.

Awrad-Emad avatar Awrad-Emad commented on May 22, 2024

@chriddyp I would appreciate if you can provide an example as I have a similar problem.

from dash-bootstrap-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.