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

Cannot update main when main is GridSpec #1741

Closed
MarcSkovMadsen opened this issue Nov 4, 2020 · 1 comment · Fixed by #1758
Closed

Cannot update main when main is GridSpec #1741

MarcSkovMadsen opened this issue Nov 4, 2020 · 1 comment · Fixed by #1758
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Nov 4, 2020

ALL software version info

Panel MASTER branch

Description of expected behavior and the observed behavior

When the template main is a GridSpec I would expect to be able to update the GridSpec.

For example at awesome-panel.org I was trying to prepopulate a Template across pages to get a shared look and feel. But a few pages should look different and replace one or more of the prepopulated items.

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

from panel.template import ReactTemplate
from panel.pane import Markdown

def test_grid_spec_replace():
    template=ReactTemplate()
    first = Markdown("I was here first")
    template.main[0,0]=first
    second=Markdown("But now I take over")
    template.main[0,0]=second
    return template

test_grid_spec_replace().servable()

Stack traceback and/or browser JavaScript console output

$ 2020-11-04 06:21:39,386 Starting Bokeh server version 2.2.3 (running on Tornado 6.0.4)
2020-11-04 06:21:39,387 User authentication hooks NOT provided (default user enabled)
2020-11-04 06:21:39,390 Bokeh app running at: http://localhost:5006/script
2020-11-04 06:21:39,391 Starting Bokeh server with process id: 21168
WARNING:param.GridSpec00005: Specified region overlaps with the following existing object(s) in the grid:

    (0, 0): Markdown(str)

The following shows a view of the grid (empty: 0, occupied: 1, overlapping: 2):

[[2 0 0 0 0 0 0 0 0 0 0 0]]
2020-11-04 06:21:47,318 Specified region overlaps with the following existing object(s) in the grid:

    (0, 0): Markdown(str)

The following shows a view of the grid (empty: 0, occupied: 1, overlapping: 2):

[[2 0 0 0 0 0 0 0 0 0 0 0]]
2020-11-04 06:21:47,636 WebSocket connection opened
2020-11-04 06:21:47,637 ServerConnection created

Screenshots or screencasts of the bug in action

image

Additional Context

I simply don't understand why the changes to the different parameters of a BasicTemplate needs to trigger complicated updates. I believe instead that there should be one function to update and render the template when needed. That would be much easier. I also think the current implementation has a performance cost because there will potentially be a lot of complicated updates that could have been simplified to one.

image

@MarcSkovMadsen MarcSkovMadsen added the TRIAGE Default label for untriaged issues label Nov 4, 2020
@MarcSkovMadsen
Copy link
Collaborator Author

This is a similar example. But this time an exception is raised

from panel.template import ReactTemplate
from panel.pane import Markdown
def test_grid_spec_replace2():
    template=ReactTemplate()
    first = Markdown("I was here first")
    template.main[0,0:12]=first
    second=Markdown("But now I take over")
    template.main[0,0:12]=second
    return template

test_grid_spec_replace2().servable()
$ python -m panel serve 'script.py' --dev
2020-11-04 06:42:11,350 Starting Bokeh server version 2.2.3 (running on Tornado 6.0.4)
2020-11-04 06:42:11,351 User authentication hooks NOT provided (default user enabled)
2020-11-04 06:42:11,355 Bokeh app running at: http://localhost:5006/script
2020-11-04 06:42:11,355 Starting Bokeh server with process id: 21168
2020-11-04 06:42:16,549 404 GET /home?template=react&theme=default (::1) 1.03ms
WARNING:param.GridSpec00005: Specified region overlaps with the following existing object(s) in the grid:

    (0, 0): Markdown(str)

The following shows a view of the grid (empty: 0, occupied: 1, overlapping: 2):

[[2 2 2 2 2 2 2 2 2 2 2 2]]
2020-11-04 06:42:22,961 Specified region overlaps with the following existing object(s) in the grid:

    (0, 0): Markdown(str)

The following shows a view of the grid (empty: 0, occupied: 1, overlapping: 2):

[[2 2 2 2 2 2 2 2 2 2 2 2]]
2020-11-04 06:42:22,964 Error running application handler <bokeh.application.handlers.script.ScriptHandler object at 0x00000240A6FB9488>: (0, 0, 1, 12)
File "grid.py", line 463, in __setitem__:
del self.objects[dkey] Traceback (most recent call last):
  File "C:\Users\masma\AppData\Local\Continuum\anaconda3\envs\panel_dev2\lib\site-packages\bokeh\application\handlers\code_runner.py", line 197, in run
    exec(self._code, module.__dict__)
  File "C:\repos\private\panel\script.py", line 11, in <module>
    test_grid_spec_replace2().servable()
  File "C:\repos\private\panel\script.py", line 8, in test_grid_spec_replace2
    template.main[0,0:12]=second
  File "C:\repos\private\panel\panel\layout\grid.py", line 463, in __setitem__
    del self.objects[dkey]
KeyError: (0, 0, 1, 12)

2020-11-04 06:42:23,045 WebSocket connection opened
2020-11-04 06:42:23,046 ServerConnection created

@philippjfr philippjfr added type: bug Something isn't correct or isn't working and removed TRIAGE Default label for untriaged issues labels Nov 9, 2020
@philippjfr philippjfr added this to the v0.10.2 milestone Nov 10, 2020
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

Successfully merging a pull request may close this issue.

2 participants