Don't warn on empty layouts
See original GitHub issueALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)
Python version : 3.6.7 | packaged by conda-forge | (default, Nov 20 2018, 18:37:09)
IPython version : 7.2.0
Tornado version : 5.1.1
Bokeh version : 1.1.0dev9+2.g1138433
BokehJS static path : /Users/jsignell/conda/envs/bokeh-dev/lib/python3.6/site-packages/bokeh-1.1.0.dev9+2.g1138433-py3.6.egg/bokeh/server/static
node.js version : v11.6.0
npm version : 6.5.0
Description of expected behavior and the observed behavior
I think that layouts should be allowed to be empty without raising a warning. There is a legitimate use of an empty layout object to create an empty area which can later be appended to or extended. This is especially useful in panel (see issue: https://github.com/pyviz/panel/issues/285) where the layout object will re-render if the children change.
I understand that it could potentially be confusing if someone were to create an empty layout object and then think that it is just not rendering - but it doesn’t seem like that would be terribly common (if it has been in the past, then maybe this warning shouldn’t be removed).
Complete, minimal, self-contained example code that reproduces the issue
from bokeh.io import output_notebook, show
from bokeh.layouts import column
from bokeh.models.widgets import Button
output_notebook()
col = column([])
show(col)
warning will be displayed
# add a button
button = Button(label='Click me!')
col.children.append(button)
show(col)
column will render properly
Stack traceback and/or browser JavaScript console output
This is the relevant warning:
Screenshots or screencasts of the bug in action
This is the warning:
And this is the column rendering properly after adding an item to it:
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
This is something that was carried over from the old layout. I will remove this warning.
The crux of the matter is that I strongly suspect that the number of people legitimately intending to show an empty layout is minuscule [1] compared to a much greater occurrence of people unintentionally showing an empty layout by mistake, left wondering why they are staring at an empty screen with no guidance or feedback. In which case we are optimizing for the wrong (uncommon) case.
[1] Case in point, it is basically never useful to show an empty layout for any standalone, non-server case, because there is no way to update and add anything after the fact. Most usage (“standard” notebook usage, HTML file output,
components
orjson_items
embedding) is non-server.Edit: then perhaps there is the compromise: we don’t warn in the context of server apps, but we do warn always for other usage.