How to configure du.configure_upload() in dash_uploader for dash multi page apps

I’m a beginner from non computer science background. it’s a silly query

I’m trying to create a multipage dash app following this tutorial code . Dash-by-Plotly/Dash_More_Advanced_Shit/Intro to Python multipage/App-A at master · Coding-with-Adam/Dash-by-Plotly · GitHub.

Previous I’ve created dash application to take input as excel and do some merge - i’m using dash uploader for the same. ( not dcc.upload).

When i moved the app code to page3, i’m struck with error: Exception: The du.configure_upload must be called before the @du.callback can be used! Please, configure the dash-uploader.

Please help. :pray:

hey @yathav
I’m not sure yet if this is a Dash Pages thing or more related to a bug in Dash Uploader. I noticed Dash Uploader hasn’t made a commit in a while.

Related:

Hey @yathav,

I found a way to get dash-uploader working in a Dash Multipage App. In the pages section, you will need to add du.configure_upload(dash.get_app(), r’file_path’) where dash.get_app() calls back the app you defined in the app.py file. This will avoid any circular referencing from Dash. Depending on your packaging module version, you might or might not run into an error. If you do run into an error on AttributeError: module ‘packaging.version’ has no attribute ‘LegacyVersion’, try pip install packaging==21.3. This worked for me

2 Likes

thank you so much. the issue is resolved

1 Like

thanks. when i tried to create a new page which uses dash uploader. i got an error. [AssertionError: View function mapping is overwriting an existing endpoint function: get ] . please help

Hey @yathav, do you mind giving some more context on what you are trying to do?

I’m create a multi-page dash app. each page itself a micro app where it performs an task based on user input. usually user input will be excel file(s).

page-2 performs an operation based on input excel

page-3 also performs a different operation based on input excel.

i’m planning to add many pages where it performs operations based on input excel.

since excel files are large, i’m using dash uploader for input. When i wanted to use dash uploader in page2 . i’ve used du.configure_upload(dash.get_app(), r’file_path’).

can’t use the same on page3

I see what you mean. I am also getting the same error when trying to create documentation using Sphinx. My app is also a multi-page Dash app. Probably @fohrloop can give some insights here regarding the error?

Yeah one might think that I could :sweat_smile:: Unfortunately it has been too long since I have touched dash or the dash-uploader that I could comment on this. Other than that things can get complicated if there are multiple dash-uploader Upload components on the same app – since there is only one backend (flask) endpoint configured for receiving the data. Iirc, dash-uploader can only support one Upload component per app. Not sure if that is even related to this problem. My advice would be:

  • If there are multiple Upload components: reduce number of Upload components to one.
  • If there are multiple pages using single Upload component: Find out what is special about multi-page apps in Dash to find the root cause.

There might be others with the same problem: See dash-uploader/issues

If you want to make changes to dash-uploader, there is also an open maintainer position :slight_smile: