-
-
Notifications
You must be signed in to change notification settings - Fork 498
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
Layout builder example not working #6600
Comments
When I restart jupyterlab and preview again it looks like If I drag the panels I can see content in the 3 first ones. But I have no way to reset the configuration from the UI. This will make it really hard for newbies. I tried clearing the notebook ("Kernel" - "Restart and clear" + "Edit" - "Clear output of all cells") . But it did not help. |
A comment is also that the guide is a mix of a tutorial, how-to guide and an explanation. Its not really clear what it is. As a tutorial it lacks content and is hard for users (like me) to reproduce. My recommendation would be to make it a tutorial. The target audience is newbees and non-panel users that want to share their notebooks as dashboards. So I believe it should be really, really detailed in the descriptions such that users "cannot fail". |
Good feedback, thanks. On balance I think a video is probably the best way to convey how to use it.
This is very surprising to me, the code forces the backend to be agg.
Now that you can't blame on Panel 😄 |
Matplotlib plots are set to scale, if you forced it to fill the space you'd have to distort it horribly. |
But I end up in a state like this and cannot solve. That is on Panel to solve. bad-state.mp4 |
Could you look at your browser console? Are there any weird errors? |
Doesn't look like there's anything related to Panel, but it does seem like there's an issue with the layout persistence. The layout persists in two levels:
I have not been able to reproduce the issue you seem to be having which is that the data written to the .layout file does not persist. |
It's a hidden file, try |
I think I've also encountered the issue, could you try removing spaces from the filename? |
Its there {"cells": {"ae3c447a-fa81-499e-a9ce-1d4f03c0865d": {"width": 62.6789, "height": 506, "visible": true}, "e1dbb77f-7860-4b2f-9837-03d9f513b7c3": {"width": 100, "height": 10, "visible": true}, "7352e53c-e521-45ba-8e3f-83050c4e8561": {"width": 100, "height": 10, "visible": true}, "3cbfb569-34fc-44c2-b8fe-096452cdf5e0": {"width": 100, "height": 10, "visible": true}}, "order": ["ae3c447a-fa81-499e-a9ce-1d4f03c0865d", "e1dbb77f-7860-4b2f-9837-03d9f513b7c3", "7352e53c-e521-45ba-8e3f-83050c4e8561", "3cbfb569-34fc-44c2-b8fe-096452cdf5e0"]} |
Think I may have found an issue when restoring the layout data from the hidden file. |
Reading the docs again it appears to me the save button is only for use outside of Jupyter Panel Preview? If that is the case I think it should not be shown when running in the Jupyter Panel Preview. |
Yes I agree. |
UPDATED
Keeps resizing to something not usefulnot-useful.mp4{
"cells": [
{
"cell_type": "markdown",
"id": "862ab307-51f8-4a4e-83bb-0b04acb25b22",
"metadata": {},
"source": [
"# Matplotlib Plot"
]
},
{
"cell_type": "markdown",
"id": "afaa1656-8aa0-41e0-a01d-4b0c581c178f",
"metadata": {},
"source": [
"A cell with text and a code snippet\n",
"\n",
"```python\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"fruits = [\"apple\", \"blueberry\", \"cherry\", \"orange\"]\n",
"counts = [40, 100, 30, 55]\n",
"bar_labels = [\"red\", \"blue\", \"_red\", \"orange\"]\n",
"bar_colors = [\"tab:red\", \"tab:blue\", \"tab:red\", \"tab:orange\"]\n",
"\n",
"ax.bar(fruits, counts, label=bar_labels, color=bar_colors)\n",
"\n",
"ax.set_ylabel(\"fruit supply\")\n",
"ax.set_title(\"Fruit supply by kind and color\")\n",
"ax.legend(title=\"Fruit colors\")\n",
"\n",
"plt.show()\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "93933ba6-da4b-4def-80ad-b9a480b6cac3",
"metadata": {},
"source": [
"## TODO: Document this properly"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "04e0edc3-ae14-43ad-8e5f-7669d7f09f80",
"metadata": {},
"outputs": [],
"source": [
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"fruits = [\"apple\", \"blueberry\", \"cherry\", \"orange\"]\n",
"counts = [40, 100, 30, 55]\n",
"bar_labels = [\"red\", \"blue\", \"_red\", \"orange\"]\n",
"bar_colors = [\"tab:red\", \"tab:blue\", \"tab:red\", \"tab:orange\"]\n",
"\n",
"ax.bar(fruits, counts, label=bar_labels, color=bar_colors)\n",
"\n",
"ax.set_ylabel(\"fruit supply\")\n",
"ax.set_title(\"Fruit supply by kind and color\")\n",
"ax.legend(title=\"Fruit colors\")\n",
"\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
} I've tried resetting everything using script below. But without any change. import json
import sys
from pathlib import Path
def reset_notebook_metadata(notebook_path):
with open(notebook_path, 'r', encoding='utf-8') as f:
notebook = json.load(f)
for cell in notebook['cells']:
if 'metadata' in cell:
metadata = cell['metadata']
if 'panel-layout' in metadata:
metadata.pop('panel-layout')
metadata = notebook['metadata']
if 'panel-cell-order' in metadata:
metadata.pop('panel-cell-order')
with open(notebook_path, 'w', encoding='utf-8') as f:
json.dump(notebook, f, indent=2)
print(f"'panel-layout' metadata removed for {notebook_path}")
def delete_layout_file(notebook_path):
path = Path(notebook_path)
layout = "." + path.name + ".layout"
path = path.parent/layout
if path.exists():
path.unlink()
print(f"{path} removed for {notebook_path}")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python reset_layout.py NameOfNotebook.ipynb")
else:
notebook_path = sys.argv[1]
reset_notebook_metadata(notebook_path)
delete_layout_file(notebook_path)
I tried renaming and suddenly it works. Is something persisted in my browser cache and should not be? You can see the rename below not-working-with-name.mp4Resize button not shown if panel is scrolledresize-not-shown-if-scrolled.mp4Make it clear how error message should be and are handled.I would like to see a clear error message in the preview in this situation. For example on a JupyterHub it would not be easy for users to see the error in the (terminal) logs. Reset Height NicelyWhen I delete panes and reset the layout they don't always show up with a good height. reset-height-nicely.mp4Not clear how to fully clear all layout stateI'm not sure I can do anything but delete Make it clear when state has not been synced to notebookThe editable.mp4Make sure older .layout file is not used with new .ipynb notebook.It is not clear to me what will happen if I have an old .layout file and I rename or create a new corresponding notebook. I would prefer the .layout file to be fully reset in that case in stead of reused. Maybe its possible to do this via a unique id in the notebook? Or by comparing creation timestamps? Rename .layout file with NotebookIf a notebook is renamed it would be nice if the .layout file was renamed too. Delete .layout file with NotebookIf a notebook is deleted it would be nice if the .layout file was deleted too. |
That old error page seems to be indicating it's using an old version of Panel. |
I've redone my tests and updated the above post. |
Thanks so much for the detailed testing.
I absolutely cannot reproduce this.
It is not, you still seem to be picking up a wrong version of Panel. Jupyter installs are finnicky, check what
Again, this is due to an older version of Panel.
Very open to suggestions here, worth noting that apps that have an error have the same behavior but I suppose there you usually have access to the logs/terminal.
Yeah, there needs to be some mechanism for this. If I change the reset to be a full reset then I could probably achieve this.
Great idea, UI suggestions very welcome.
Indeed, will have to be changed in |
My mistake was testing panel==1.4.0a1 instead of 1.4.1a1. I've retested with 1.4.1a1 and updated posted above. |
The example from the docs still does not work for me. Added video and info above. |
Very strange, absolutely cannot reproduce that issue. |
Could it be that 1.4.1a1 still isn't the version it's running as the jupyter serverextension? |
Jupyter sadly is very finicky since extensions can be installed in various places and precedence of each one is unclear to me, e.g. you can have an extension installed globally and in a particular environment. |
Are you sure that nothing is persisted in the browser cache/ storage system when doing this. To me that could be an explanation. Under one name it works. Under another it does not. Also I cannot "reset" the not working name by removing metadata and .layout file. |
Seems like the first step to getting to the bottom of this will be to make the reset actually reset everything, local storage, .layout file and notebook metadata. |
If the jupyterlab restart was actually required the only thing I can think of was that your JLab server was still running the old version before the restart. |
Anyway, I'll work on the full reset next. |
I've have been restarting it many times this morning after installing panel==1.4.1a1. |
I think docs need improvement. I did not understand localstorage also involved for notebooks in preview. I thought that was only for served apps with |
Since we removed the save button in the preview it should no longer allow you to use localstorage (in the preview). Seems likely you had something in localstorage from before we hid the save button. The precedence hierarchy generally is:
|
Do you cache anything during the "layout" computation? Could that be an explanation? |
I was trying to use the layout builder with example in the how-to guide https://panel.holoviz.org/how_to/notebook/layout_builder.html.
But it does not work for me as the matplotlib plot is not displayed??
panel==1.4.0 bokeh=3.4.0 pyviz_comms=3.0.2
The text was updated successfully, but these errors were encountered: