`prevent_initial_call="initial_duplicate"` not working as expected
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Hello!
dash==2.17.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-mantine-components==0.14.4
Describe the bug
I have callbacks I wish to start on load (prevent_initial_call=False) and do not care about the order of results eg. loading data and then sending dmc notification.
These are either from the same page or different pages targeting the same output. Having the ability to send from different pages helps the consistency app as the user sees notifications persist between pages.
Setting prevent_initial_call="initial_duplicate" and allow_duplicate=True results in effectively prevent_initial_Call=True. If only set to on some of the duplicate results in the following error, which says to do the thing I am already doing.
dash.exceptions.DuplicateCallback: allow_duplicate requires prevent_initial_call to be True. The order of the call is not guaranteed to be the same on every page load. To enable duplicate callback with initial call, set prevent_initial_call='initial_duplicate' or globally in the config prevent_initial_callbacks='initial_duplicate'
I also tried setting this at the global level but results in:
TypeError: Dash() got an unexpected keyword argument 'prevent_initial_callback'
Perhaps I am misunderstanding the purpose but I just want to run the callbacks with full awareness that the order is not guaranteed (desirable in this case).
The only documentation I could find is https://community.plotly.com/t/dash-2-9-2-released-partial-property-updates-with-patch-duplicate-outputs-dcc-geolocation-scatter-group-attributes-and-more/72114#allowing-duplicate-callback-outputs-7
I've attached an MRE here https://github.com/Lxstr/dash-multi-page-app-demos/tree/prevent-initial-duplicate
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the linked MRE from the prevent-initial-duplicate branch and inspect its callback declarations and Dash constructor configuration. Compare the behavior of prevent_initial_call='initial_duplicate' with allow_duplicate=True, including the global configuration spelling. Done means the MRE callbacks can run on initial load without the reported DuplicateCallback or constructor TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100