When using keyword arguments in a background callback with Celery, no_update does not work
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Describe your context
dash 2.17.1
dash-ag-grid 2.4.0
dash-auth-external 1.2.1
dash-auth0-oauth 0.1.5
dash-bootstrap-components 1.6.0
dash-core-components 2.0.0
dash-cytoscape 1.0.0
dash-extensions 0.0.71
dash-html-components 2.0.0
dash-iconify 0.1.2
dash-loading-spinners 1.0.3
dash-mantine-components 0.12.1
dash-table 5.0.0
Celery 5.3.6
Describe the bug
There is a background callback.
The background manager is Celery.
The output was specified as a keyword argument, and the callback returned no_update.
However, the result received by the browser was {"_dash_no_update": "_dash_no_update"}.
The no_update did not work correctly.
@callback(
output=dict(
foo=Output("foo", "children", allow_duplicate=True),
),
inputs=dict(
bar=Input("bar", "value"),
),
prevent_initial_call=True,
background=True,
)
def background_callback(bar: str):
return dict(foo=dash.no_update)
The value {"_dash_no_update": "_dash_no_update"} is assigned to foo, causing an unintended third callback to be invoked.
I suspect this part of the code. For the dict type, the transformation from {"_dash_no_update": "_dash_no_update"} to NoUpdate is not performed. I believe this is the cause of the unintended bug. (As a side note, I use multi-page)
Expected behavior
When using a background callback with Celery, returning no_update for the Output using keyword arguments should result in nothing being returned as intended.
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
Start in dash/_callback.py around line 452 and reproduce the issue with the supplied Celery background callback using keyword arguments. Verify how the serialized no_update value is handled for dict outputs. Done means no_update produces no returned update for foo and does not trigger the unintended third callback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100