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

Default value of scroll_position should be 0? #6078

Closed
1 task done
nenb opened this issue Dec 18, 2023 · 2 comments
Closed
1 task done

Default value of scroll_position should be 0? #6078

nenb opened this issue Dec 18, 2023 · 2 comments
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@nenb
Copy link
Contributor

nenb commented Dec 18, 2023

ALL software version info

Panel - 1.3.4
Bokeh - 3.3.2
CPython - 3.9.18
Chrome - 120.0.6099.62

Description of expected behavior and the observed behavior

The ragna OSS package is getting an error when it tries to create more than 25 chats using the ChatInterface widget. I'm still struggling to produce a MRE with panel alone, but I've included a relevant traceback below. Based on the output from the traceback, I was wondering if the default value for the scroll_position class attribute should be 0 rather than None (see the commit here). Preliminary investigations suggest that this does seem to resolve the problem.

The traceback does seem to suggest some other possible issues eg remaining_events can be referenced before defined in a finally block if the try block exits early, but this might possibly just be an artefact of the original error.

Stack traceback and/or browser JavaScript console output

Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7f2825d1ba90>>, <Task finished name='Task-768' coro=<async_execute.<locals>.wrapper() done, defined at /home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/io/server.py:177> exception=UnboundLocalError("local variable 'remaining_events' referenced before assignment")>)
Traceback (most recent call last):
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/io/document.py", line 249, in unlocked
    yield
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/reactive.py", line 302, in _apply_update
    self._update_model(events, msg, root, model, doc, comm)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/layout/base.py", line 119, in _update_model
    super()._update_model(events, msg, root, model, doc, comm)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/reactive.py", line 623, in _update_model
    super()._update_model(events, msg, root, model, doc, comm)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/reactive.py", line 330, in _update_model
    model.update(**msg)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/core/has_props.py", line 481, in update
    setattr(self, k, v)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/core/has_props.py", line 334, in __setattr__
    return super().__setattr__(name, value)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/core/property/descriptors.py", line 331, in __set__
    value = self.property.prepare_value(obj, self.name, value)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/core/property/bases.py", line 365, in prepare_value
    raise ValueError(f"failed to validate {obj_repr}.{name}: {error}")
ValueError: failed to validate Column(id='p1296', ...).scroll_position: expected a value of type Integral, got None of type NoneType

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/io/document.py", line 298, in unlocked
    curdoc.unhold()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/document/document.py", line 776, in unhold
    self.callbacks.unhold()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/document/callbacks.py", line 431, in unhold
    self.trigger_on_change(event)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/document/callbacks.py", line 413, in trigger_on_change
    invoke_with_curdoc(doc, invoke_callbacks)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/document/callbacks.py", line 443, in invoke_with_curdoc
    return f()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/document/callbacks.py", line 412, in invoke_callbacks
    cb(event)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/document/callbacks.py", line 276, in <lambda>
    self._change_callbacks[receiver] = lambda event: event.dispatch(receiver)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/document/events.py", line 353, in dispatch
    super().dispatch(receiver)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/document/events.py", line 219, in dispatch
    cast(DocumentPatchedMixin, receiver)._document_patched(self)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/bokeh/server/session.py", line 244, in _document_patched
    raise RuntimeError("_pending_writes should be non-None when we have a document lock, and we should have the lock when the document changes")
RuntimeError: _pending_writes should be non-None when we have a document lock, and we should have the lock when the document changes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/tornado/ioloop.py", line 750, in _run_callback
    ret = callback()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/tornado/ioloop.py", line 774, in _discard_future_result
    future.result()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/io/server.py", line 183, in wrapper
    state._handle_exception(e)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/io/state.py", line 440, in _handle_exception
    raise exception
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/io/server.py", line 181, in wrapper
    return await func(*args, **kw)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 774, in _async_caller
    await function()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/depends.py", line 37, in _depends
    return await func(*args, **kw)
  File "/home/nenb/nicks_projects/ragna/ragna/deploy/_ui/components/file_uploader.py", line 45, in did_finish_upload
    await self.after_upload_callback(json.loads(self.uploaded_documents_json))
  File "/home/nenb/nicks_projects/ragna/ragna/deploy/_ui/modal_configuration.py", line 141, in did_finish_upload
    await self.new_chat_ready_callback(new_chat_id)
  File "/home/nenb/nicks_projects/ragna/ragna/deploy/_ui/main_page.py", line 84, in open_new_chat
    await self.refresh_data()
  File "/home/nenb/nicks_projects/ragna/ragna/deploy/_ui/main_page.py", line 42, in refresh_data
    self.chats = await self.api_wrapper.get_chats()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 525, in _f
    instance_param.__set__(obj, val)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 527, in _f
    return f(self, obj, val)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 1545, in __set__
    obj.param._call_watcher(watcher, event)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 2486, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 2468, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 781, in _sync_caller
    return function()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/depends.py", line 41, in _depends
    return func(*args, **kw)
  File "/home/nenb/nicks_projects/ragna/ragna/deploy/_ui/main_page.py", line 46, in after_update_chats
    self.left_sidebar.chats = self.chats
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 525, in _f
    instance_param.__set__(obj, val)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 527, in _f
    return f(self, obj, val)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 1545, in __set__
    obj.param._call_watcher(watcher, event)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 2486, in _call_watcher
    self_._execute_watcher(watcher, (event,))
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 2468, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/param.py", line 925, in update_pane
    self._replace_pane()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/param.py", line 880, in _replace_pane
    self._update_inner(new_object)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/pane/base.py", line 704, in _update_inner
    new_pane, internal = self._update_from_object(
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/pane/base.py", line 680, in _update_from_object
    cls._recursive_update(old_object, object)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/pane/base.py", line 649, in _recursive_update
    old.param.update(**new_params)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 2282, in update
    restore = self_._update(*args, **kwargs)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 2322, in _update
    self_._batch_call_watchers()
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 2506, in _batch_call_watchers
    self_._execute_watcher(watcher, events)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/param/parameterized.py", line 2468, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/reactive.py", line 374, in _param_change
    self._apply_update(named_events, properties, model, ref)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/reactive.py", line 302, in _apply_update
    self._update_model(events, msg, root, model, doc, comm)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/nenb/miniforge3/envs/ragna-dev/lib/python3.9/site-packages/panel/io/document.py", line 300, in unlocked
    if remaining_events:
UnboundLocalError: local variable 'remaining_events' referenced before assignment

Screenshots or screencasts of the bug in action

  • I may be interested in making a pull request to address this
@ahuang11
Copy link
Contributor

Yes, I think it should default to 0.

The TS model's default is 0 too.

    this.define<Column.Props>(({ Int, Boolean }) => ({
      scroll_position: [Int, 0],
      auto_scroll_limit: [Int, 0],
      scroll_button_threshold: [Int, 0],
      view_latest: [Boolean, false],
    }));
  }

Thanks for tracing this!

@philippjfr
Copy link
Member

Thanks @nenb! Quite unfortunate this was submitted minutes after the 1.3.5 release :/

@philippjfr philippjfr added this to the v1.4.0 milestone Dec 19, 2023
@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Dec 19, 2023
@philippjfr philippjfr modified the milestones: v1.4.0, v1.3.6 Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

3 participants