MCPcopy
hub / github.com/plotly/dash / set_props

Function set_props

dash/_callback_context.py:361–386  ·  view source on GitHub ↗

Set the props for a component not included in the callback outputs. If running in a WebSocket context, props are streamed immediately to the client. Otherwise, props are batched and sent with the callback response.

(component_id: typing.Union[str, dict], props: dict)

Source from the content-addressed store, hash-verified

359
360
361def set_props(component_id: typing.Union[str, dict], props: dict):
362 """
363 Set the props for a component not included in the callback outputs.
364
365 If running in a WebSocket context, props are streamed immediately to the
366 client. Otherwise, props are batched and sent with the callback response.
367 """
368 ws = _get_from_context("dash_websocket", None)
369 if ws is not None:
370 # Stream immediately via WebSocket
371 _id = stringify_id(component_id)
372
373 async def _send_props():
374 for prop_name, value in props.items():
375 await ws.set_prop(_id, prop_name, value)
376
377 # If we're in an async context, schedule the coroutine
378 try:
379 asyncio.get_running_loop()
380 asyncio.ensure_future(_send_props())
381 except RuntimeError:
382 # No running event loop - run synchronously
383 asyncio.run(_send_props())
384 else:
385 # Batch for response (existing behavior)
386 callback_context.set_props(component_id, props)

Callers 15

global_error_handlerFunction · 0.90
callback_on_errorFunction · 0.90
on_clickFunction · 0.90
on_clickFunction · 0.90
on_insertFunction · 0.90
on_clearFunction · 0.90
on_reverseFunction · 0.90
on_removeFunction · 0.90
on_errorFunction · 0.90
announceFunction · 0.90
on_clickFunction · 0.90
no_output1Function · 0.90

Calls 5

_get_from_contextFunction · 0.85
_send_propsFunction · 0.85
set_propsMethod · 0.80
stringify_idFunction · 0.70
runMethod · 0.45

Tested by 15

on_clickFunction · 0.72
on_insertFunction · 0.72
on_clearFunction · 0.72
on_reverseFunction · 0.72
on_removeFunction · 0.72
on_errorFunction · 0.72
announceFunction · 0.72
on_clickFunction · 0.72
no_output1Function · 0.72
no_output2Function · 0.72
no_outputFunction · 0.72
generate_buttonFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…