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

Location sync broken for dates, ints #1784

Closed
johnzeringue opened this issue Nov 13, 2020 · 0 comments · Fixed by #1792
Closed

Location sync broken for dates, ints #1784

johnzeringue opened this issue Nov 13, 2020 · 0 comments · Fixed by #1792

Comments

@johnzeringue
Copy link

johnzeringue commented Nov 13, 2020

ALL software version info

Python 3.9.0

bokeh==2.2.3
notebook==5.7.9
panel==0.10.1

macOS Catalina 10.15.7

Chrome 85.0.4183.121

Description of expected behavior and the observed behavior

Expected

When syncing params with the browser location, refreshing the page or sharing the URL should restore those param values.

Observed

Refreshing the page or sharing the URL does not restore param values for dates and ints. It does seem to work for strings and floats.

Editing the URL by changing ?bday="2000-01-01" to ?bday=2000-01-01 lets you share the URL (though the sync on page load immediately changes the URL back).

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
import panel.widgets as pnw

bday = pnw.DatePicker()
pn.state.location.sync(bday, {"value": "bday"})

@pn.depends(bday)
def summary(bday):
    return f"My birthday is {bday}"

app = pn.Column(bday, summary)
app.servable()

Stack traceback and/or browser JavaScript console output

2020-11-13 16:12:06,453 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x142be9c10>>, <Task finished name='Task-369' coro=<_needs_document_lock.<locals>._needs_document_lock_wrapper() done, defined at /Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/bokeh/server/session.py:51> exception=ValueError("CalendarDate 'value' only takes datetime types.")>)
Traceback (most recent call last):
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/tornado/ioloop.py", line 741, in _run_callback
    ret = callback()
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/tornado/ioloop.py", line 765, in _discard_future_result
    future.result()
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/bokeh/server/session.py", line 71, in _needs_document_lock_wrapper
    result = await result
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/tornado/gen.py", line 216, in wrapper
    result = ctx_run(func, *args, **kwargs)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/panel/reactive.py", line 194, in _change_coroutine
    self._change_event(doc)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/panel/reactive.py", line 204, in _change_event
    self._process_events(events)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/panel/reactive.py", line 187, in _process_events
    self.param.set_param(**self._process_property_change(events))
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/parameterized.py", line 1451, in set_param
    self_._batch_call_watchers()
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/parameterized.py", line 1578, in _batch_call_watchers
    watcher.fn(*events)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/panel/io/location.py", line 108, in _update_synced
    p.param.set_param(**mapped)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/parameterized.py", line 1444, in set_param
    setattr(self_or_cls, k, v)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/parameterized.py", line 302, in _f
    instance_param.__set__(obj, val)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/parameterized.py", line 304, in _f
    return f(self, obj, val)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/__init__.py", line 623, in __set__
    super(Dynamic,self).__set__(obj,val)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/parameterized.py", line 304, in _f
    return f(self, obj, val)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/parameterized.py", line 871, in __set__
    self._validate(val)
  File "/Users/johnzeringue/.pyenv/versions/3.9.0/envs/pydata-panel/lib/python3.9/site-packages/param/__init__.py", line 1891, in _validate
    raise ValueError("CalendarDate '%s' only takes datetime types."%self.name)
ValueError: CalendarDate 'value' only takes datetime types.

Screenshots or screencasts of the bug in action

Screen Shot 2020-11-13 at 4 24 00 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant