Skip to content

Commit 4d5aa7d

Browse files
committed
Warn if importing component libraries in callbacks.
1 parent 1cb7455 commit 4d5aa7d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

dash/dash.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,9 @@ def long_callback(
12851285
def dispatch(self):
12861286
body = flask.request.get_json()
12871287

1288+
app_studio = "app_studio" in ComponentRegistry.registry
1289+
nlibs = len(ComponentRegistry.registry)
1290+
12881291
g = AttributeDict({})
12891292

12901293
g.inputs_list = inputs = body.get( # pylint: disable=assigning-non-slot
@@ -1365,6 +1368,7 @@ def dispatch(self):
13651368
except KeyError as missing_callback_function:
13661369
msg = f"Callback function not found for output '{output}', perhaps you forgot to prepend the '@'?"
13671370
raise KeyError(msg) from missing_callback_function
1371+
13681372
ctx = copy_context()
13691373
# noinspection PyArgumentList
13701374
response.set_data(
@@ -1378,6 +1382,12 @@ def dispatch(self):
13781382
)
13791383
)
13801384
)
1385+
1386+
if not app_studio and nlibs != len(ComponentRegistry.registry):
1387+
print(
1388+
"Warning: component library imported during callback, move to top-level for full support.",
1389+
file=sys.stderr,
1390+
)
13811391
return response
13821392

13831393
def _setup_server(self):

0 commit comments

Comments
 (0)