fohrloop / dash-uploader

The alternative upload component for python Dash applications.
MIT License
141 stars 29 forks source link

dash-uploader background callbacks #121

Open krafftta opened 1 year ago

krafftta commented 1 year ago

Hi,

I'm implementing a multi-page dash app and I thought it would be nice if the user could change between pages while waiting for the upload to finish. Dash introduced Background Callbacks (https://dash.plotly.com/background-callbacks) where (after some extra work on setting up Celery and Redis) callbacks with the 'background' parameter set to True execute their task in the background when triggered.

I was wondering if there's a way to make use of this Dash Feature with dash-uploader. The du.callback does currently not take a background argument either.
It would be really cool if the user could chose a file and the file upload would be moved to a background task.

I don't know how easily this is realizable. If anyone knows a workaround that would be highly appreciated as well :)

Best, Tamara

mapix commented 9 months ago

@krafftta You can explicitly use Celery for asynchronous processing in the callback after dcc.Uploader has completed the upload, or, if you want to simplify, you can use something like dcc.Store to re-emit the successful upload event as a new event, and then use background tasks in the new callback. Whether dcc.Uploader is suitable for directly supporting background tasks is not easy for me to judge at the moment.