Skip to content

Commit

Permalink
Update no_echo metadata name to echo_update for clarity.
Browse files Browse the repository at this point in the history
Having a negative in the name was confusing to me, so I renamed the property echo_update. Set it to False to disable echos for that attribute.
  • Loading branch information
jasongrout committed Feb 23, 2022
1 parent 9cb9d26 commit 11c36db
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/schema/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ The `echo_update` messages enable a frontend to optimistically update its widget

Since the `echo_update` update messages are optional, and not all attribute updates may be echoed, it is important that only `echo_update` updates are ignored in the last step above, and `update` message updates are always applied.

For attributes where sending back an `echo_update` is considered too expensive or unnecessary, we have implemented an opt-out mechanism in the ipywidgets package. A model trait can have the `no_echo` metadata attribute to flag that the kernel should not send an `echo_update` update for that attribute to the frontends. We suggest other implementations implement a similar opt-out mechanism.
Implementation note: For attributes where sending back an `echo_update` is considered too expensive or unnecessary, we have implemented an opt-out mechanism in the ipywidgets package. A model trait can have the `echo_update` metadata attribute set to `False` to flag that the kernel should never send an `echo_update` update for that attribute to the frontends. Additionally, we have a system-wide flag to disable echoing for all attributes via the environment variable `JUPYTER_WIDGETS_ECHO`. For ipywdgets 7.7, we default `JUPYTER_WIDGETS_ECHO` to off (disabling all echo messages) and in ipywidgets 8.0 we default `JUPYTER_WIDGETS_ECHO` to on (enabling echo messages).

#### State requests: `request_state`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def _square(self, change):
def test_no_echo():
# in cases where values coming from the frontend are 'heavy', we might want to opt out
class ValueWidget(Widget):
value = Float().tag(sync=True, no_echo=True)
value = Float().tag(sync=True, echo_update=False)

widget = ValueWidget(value=1)
assert widget.value == 1
Expand Down
2 changes: 1 addition & 1 deletion python/ipywidgets/ipywidgets/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def set_state(self, sync_data):
if JUPYTER_WIDGETS_ECHO:
echo_state = {}
for attr,value in sync_data.items():
if not self.trait_metadata(attr, 'no_echo'):
if self.trait_metadata(attr, 'echo_update', default=True):
echo_state[attr] = value
if echo_state:
echo_state, echo_buffer_paths, echo_buffers = _remove_buffers(echo_state)
Expand Down
2 changes: 1 addition & 1 deletion python/ipywidgets/ipywidgets/widgets/widget_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class FileUpload(DescriptionWidget, ValueWidget, CoreWidget):
style = InstanceDict(ButtonStyle).tag(sync=True, **widget_serialization)
error = Unicode(help='Error message').tag(sync=True)
value = TypedTuple(Dict(), help='The file upload value').tag(
sync=True, no_echo=True, **_value_serialization)
sync=True, echo_update=False, **_value_serialization)

@default('description')
def _default_description(self):
Expand Down

0 comments on commit 11c36db

Please sign in to comment.