MCPcopy Index your code
hub / github.com/plotly/dash / make_app

Function make_app

tests/integration/renderer/test_benchmarking.py:7–96  ·  view source on GitHub ↗
(num_groups=500, items_per_group=20)

Source from the content-addressed store, hash-verified

5
6
7def make_app(num_groups=500, items_per_group=20):
8 app = Dash(__name__)
9
10 NUM_GROUPS = num_groups
11 ITEMS_PER_GROUP = items_per_group
12
13 children = []
14 for g in range(NUM_GROUPS):
15 group_children = []
16 for i in range(ITEMS_PER_GROUP):
17 group_children.append(
18 html.Div(
19 [
20 dcc.Input(
21 id={"type": "input", "group": g, "index": i},
22 value=f"g{g}-i{i}",
23 ),
24 html.Div(
25 id={"type": "output", "group": g, "index": i},
26 ),
27 ]
28 )
29 )
30 children.append(
31 html.Details(
32 [
33 html.Summary(f"Group {g}"),
34 html.Div(group_children),
35 ]
36 )
37 )
38
39 for g in range(NUM_GROUPS):
40
41 @callback(
42 Output({"type": "output", "group": g, "index": ALL}, "children"),
43 Input({"type": "input", "group": g, "index": ALL}, "value"),
44 prevent_initial_call=True,
45 )
46 def update(v, _g=g):
47 return f"Updated: {v}"
48
49 for g in range(NUM_GROUPS - 1):
50
51 @callback(
52 Output({"type": "output", "group": g + 1, "index": ALL}, "style"),
53 Input({"type": "input", "group": g, "index": ALL}, "value"),
54 prevent_initial_call=True,
55 )
56 def cross_update(values, _g=g):
57 return [{"color": "blue"} for _ in values]
58
59 for g in range(0, NUM_GROUPS, 3):
60
61 @callback(
62 Output({"type": "output", "group": g, "index": ALL}, "title"),
63 Input({"type": "input", "group": g, "index": ALL}, "value"),
64 State({"type": "output", "group": g, "index": ALL}, "children"),

Callers 1

Calls 6

clientside_callbackMethod · 0.95
DashClass · 0.90
OutputClass · 0.90
InputClass · 0.90
StateClass · 0.90
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…