Skip to content

Commit

Permalink
Implement lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Oct 24, 2024
1 parent b0cfdbd commit 2ef333d
Show file tree
Hide file tree
Showing 59 changed files with 5,584 additions and 4,245 deletions.
269 changes: 134 additions & 135 deletions qe.ipynb
Original file line number Diff line number Diff line change
@@ -1,138 +1,137 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%javascript\n",
"IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
" return false;\n",
"}\n",
"document.title='AiiDAlab QE app'"
]
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%javascript\n",
"IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
" return false;\n",
"}\n",
"document.title='AiiDAlab QE app'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"\n",
"load_profile();"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aiidalab_widgets_base.utils.loaders import load_css\n",
"\n",
"load_css(css_path=\"src/aiidalab_qe/app/static/styles\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Fix pybel import path\n",
"try:\n",
" import sys\n",
"\n",
" sys.modules[\"pybel\"] = __import__(\"openbabel\", globals(), locals(), [\"pybel\"]).pybel\n",
"except Exception:\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display\n",
"\n",
"from aiidalab_qe.app.wrapper import AppWrapperContoller, AppWrapperModel, AppWrapperView\n",
"\n",
"model = AppWrapperModel()\n",
"view = AppWrapperView()\n",
"controller = AppWrapperContoller(model, view)\n",
"\n",
"display(view)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aiidalab_qe.app.main import App\n",
"from aiidalab_widgets_base.bug_report import (\n",
" install_create_github_issue_exception_handler,\n",
")\n",
"\n",
"install_create_github_issue_exception_handler(\n",
" view.output,\n",
" url=\"https://github.com/aiidalab/aiidalab-qe/issues/new\",\n",
" labels=(\"bug\", \"automated-report\"),\n",
")\n",
"\n",
"app = App(qe_auto_setup=True)\n",
"\n",
"view.main.children = [app]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import urllib.parse as urlparse\n",
"\n",
"url = urlparse.urlsplit(jupyter_notebook_url) # noqa F821\n",
"query = urlparse.parse_qs(url.query)\n",
"if \"pk\" in query:\n",
" app.process = query[\"pk\"][0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"controller.enable_toggles()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"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.9.13"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aiida import load_profile\n",
"\n",
"load_profile();"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aiidalab_widgets_base.utils.loaders import load_css\n",
"\n",
"load_css(css_path=\"src/aiidalab_qe/app/static/styles\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Fix pybel import path\n",
"try:\n",
" import sys\n",
"\n",
" sys.modules[\"pybel\"] = __import__(\"openbabel\", globals(), locals(), [\"pybel\"]).pybel\n",
"except Exception:\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display\n",
"\n",
"from aiidalab_qe.app.wrapper import AppWrapperContoller, AppWrapperModel, AppWrapperView\n",
"\n",
"model = AppWrapperModel()\n",
"view = AppWrapperView()\n",
"controller = AppWrapperContoller(model, view)\n",
"\n",
"display(view)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import urllib.parse as urlparse\n",
"\n",
"from aiidalab_qe.app.main import App\n",
"from aiidalab_widgets_base.bug_report import (\n",
" install_create_github_issue_exception_handler,\n",
")\n",
"\n",
"install_create_github_issue_exception_handler(\n",
" view.output,\n",
" url=\"https://github.com/aiidalab/aiidalab-qe/issues/new\",\n",
" labels=(\"bug\", \"automated-report\"),\n",
")\n",
"\n",
"url = urlparse.urlsplit(jupyter_notebook_url) # noqa F821\n",
"query = urlparse.parse_qs(url.query)\n",
"\n",
"app = App(qe_auto_setup=True)\n",
"# if a pk is provided in the query string, set it as the process of the app\n",
"if \"pk\" in query:\n",
" pk = query[\"pk\"][0]\n",
" app.process = pk\n",
"\n",
"view.main.children = [app]\n",
"view.app = app"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"controller.enable_toggles()"
]
}
],
"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.9.13"
},
"vscode": {
"interpreter": {
"hash": "d4d1e4263499bec80672ea0156c357c1ee493ec2b1c70f0acce89fc37c4a6abe"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 2ef333d

Please sign in to comment.