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

Improve the user experience for resetting Jupyterlite. #6198

Merged
merged 2 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ jupyter_execute
# this dir contains the whole website and should not be checked in on main
builtdocs/
.doit.db

lite/
lite/files/*/
.jupyterlite.doit.db

# jetbrains settings
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repos:
hooks:
- id: clean-notebook
args: [-i, tags]
exclude: '^lite/files'
exclude: '^lite/files/.*/'
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
Expand Down
46 changes: 1 addition & 45 deletions lite/files/Getting_Started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,55 +121,11 @@
"id": "f4efdeef-e3c5-4cb0-b358-b40f03c59f93",
"metadata": {},
"source": [
"The contents of Panelite are updated on every release, however Jupyterlite caches old edits to files. If you want to reset the storage and **delete all modifications you made to the contents** the click the button below."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6477040-13bc-4cbf-8939-1e893563bc1e",
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display, HTML\n",
"display(HTML(\"\"\"\n",
"<button type=\"button\" id=\"button_for_indexeddb\">Clear JupyterLite local storage</button>\n",
"<script>\n",
"window.button_for_indexeddb.onclick = function(e) {\n",
" window.indexedDB.open('JupyterLite Storage').onsuccess = function(e) {\n",
" // There are also other tables that I'm not clearing:\n",
" // \"counters\", \"settings\", \"local-storage-detect-blob-support\"\n",
" let tables = [\"checkpoints\", \"files\"];\n",
"\n",
" let db = e.target.result;\n",
" let t = db.transaction(tables, \"readwrite\");\n",
"\n",
" function clearTable(tablename) {\n",
" let st = t.objectStore(tablename);\n",
" st.count().onsuccess = function(e) {\n",
" console.log(\"Deleting \" + e.target.result + \" entries from \" + tablename + \"...\");\n",
" st.clear().onsuccess = function(e) {\n",
" console.log(tablename + \" is cleared!\");\n",
" }\n",
" }\n",
" }\n",
"\n",
" for (let tablename of tables) {\n",
" clearTable(tablename);\n",
" }\n",
" }\n",
"};\n",
"</script>\n",
"\"\"\"))"
"The contents of Panelite are updated on every release, however Jupyterlite caches old edits to files. If you want to reset the storage and **delete all modifications you made to the contents** then use the [Reset_Jupyterlite.ipynb](Reset_Jupyterlite.ipynb) notebook."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (Pyodide)",
"language": "python",
"name": "python"
},
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
Expand Down
61 changes: 61 additions & 0 deletions lite/files/Reset_Jupyterlite.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The contents of Panelite are updated on every release, however Jupyterlite caches old edits to files. If you want to reset the storage and **delete all modifications you made to the contents** then run the code below and click the button `Clear JupyterLite local storage` button."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display, HTML\n",
"display(HTML(\"\"\"\n",
"<button type=\"button\" id=\"button_for_indexeddb\">Clear JupyterLite local storage</button>\n",
"<div id=\"clear-storage-message\"></div>\n",
"<script>\n",
"window.button_for_indexeddb.onclick = function(e) {\n",
" message = document.getElementById(\"clear-storage-message\")\n",
" message.innerText=\"Running\"\n",
" window.indexedDB.open('JupyterLite Storaage').onsuccess = function(e) {\n",
" // There are also other tables that I'm not clearing:\n",
" // \"counters\", \"settings\", \"local-storage-detect-blob-support\"\n",
" let tables = [\"checkpoints\", \"files\"];\n",
"\n",
" let db = e.target.result;\n",
" let t = db.transaction(tables, \"readwrite\");\n",
"\n",
" function clearTable(tablename) {\n",
" let st = t.objectStore(tablename);\n",
" st.count().onsuccess = function(e) {\n",
" console.log(\"Deleting \" + e.target.result + \" entries from \" + tablename + \"...\");\n",
" st.clear().onsuccess = function(e) {\n",
" console.log(tablename + \" is cleared!\");\n",
" }\n",
" }\n",
" }\n",
"\n",
" for (let tablename of tables) {\n",
" clearTable(tablename);\n",
" }\n",
" }\n",
" message.innerText=\"JupyterLite local storage has successfully been reset\"\n",
"};\n",
"</script>\n",
"\"\"\"))"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}