Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Use of "id" in Pattern Matching Callbacks breaks args_grouping #2086

Closed
MrTeale opened this issue Jun 9, 2022 · 2 comments · Fixed by #2087
Closed

[BUG] Use of "id" in Pattern Matching Callbacks breaks args_grouping #2086

MrTeale opened this issue Jun 9, 2022 · 2 comments · Fixed by #2087

Comments

@MrTeale
Copy link
Contributor

MrTeale commented Jun 9, 2022

Describe your context
Currently running on Python 3.9.10 on MacOS Monterey (12.3.1) with the below dash libraries installed

dash                 2.5.0
dash-core-components 2.0.0
dash-cytoscape       0.3.0
dash-daq             0.5.1
dash-html-components 2.0.0
dash-table           5.0.0

Describe the bug

Using id as a key within a component's id breaks the new callback context's args_grouping function. An example of a component within my use cases looks like:

dcc.Store(id={"id": "A-store", "type": "scenario"}, storage_type="local"),
dcc.Store(id={"id": "B-store", "type": "scenario"}, storage_type="local"),
dcc.Store(id={"id": "C-store", "type": "scenario"}, storage_type="local"),

and the callback Input looks like:

Input({"type": "scenario", "id": ALL}, "data"),

Output Traceback from Error (apologies, I've had to hide some personal file paths):

Traceback (most recent call last):
  File ".....", line 172, in update_graph
    pprint(ctx.args_grouping)
  File "/Users/...../.venv_core/lib/python3.9/site-packages/dash/_callback_context.py", line 18, in assert_context
    return func(*args, **kwargs)
  File "/Users/...../.venv/lib/python3.9/site-packages/dash/_callback_context.py", line 182, in args_grouping
    recursive_update(grouping)
  File "/Users/...../.venv/lib/python3.9/site-packages/dash/_callback_context.py", line 180, in recursive_update
    recursive_update(i)
  File "/Users/...../.venv/lib/python3.9/site-packages/dash/_callback_context.py", line 179, in recursive_update
    update_args_grouping(i)
  File "/Users/...../.venv/lib/python3.9/site-packages/dash/_callback_context.py", line 157, in update_args_grouping
    prop_id = f"{str_id}.{g['property']}"
KeyError: 'property'

Expected behavior

The ability to use any key within a pattern matching ID and still have args grouping working or this limitation documented within the Dash Docs. Current documentation recommends using type, index or id as keys for readability, so this would need to change.

@MrTeale
Copy link
Contributor Author

MrTeale commented Jun 9, 2022

cc @AnnMarieW - Awesome work on this feature! Makes pattern matching a tonne easier. Figured I'd CC you since you'd know this section of Dash best.

@AnnMarieW
Copy link
Collaborator

@MrTeale - Thanks for reporting!
This will be an easy fix. Glad you like the new args_grouping 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants