Skip to content

Commit

Permalink
Implement MVC design and lazy loading (aiidalab#802)
Browse files Browse the repository at this point in the history
This is a large-scale redesign that focuses on the separation of data/business logic from the UI. Data is contained in `Model` classes as `traitlets` traits, which are observed in the `Controller`/`View` widgets and handled by `Controller` event handlers. `Controller`s also observe changes in their respective `View`s to handle user events. The design relies predominantly on the Observer pattern, with a few exceptions handled as a Mediator pattern.

Lazy loading is implemented via `render` methods triggered when the user visits the relevant component. However, the `Model` network is decoupled from the UI and remains in sync as a source of truth. `View`s sync up with the `Model` network on render.

Some changes in the UI were included here to better fit with the MVC design and the principles of lazy loading. Clear documentation will be provided in a follow-up PR.
  • Loading branch information
edan-bainglass authored Nov 20, 2024
1 parent 150b22e commit 3d02dd5
Show file tree
Hide file tree
Showing 119 changed files with 9,911 additions and 7,422 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# Only collect code coverage with aiida-core=2.3, to speed up tests
# with higher aiida versions that for some reason run slower, see:
# https://github.com/aiidalab/aiidalab-qe/issues/766
run: pytest -v tests ${{ matrix.aiida-core-version == '2.3' && '--cov=aiidalab_qe' || '' }}
run: pytest -v tests ${{ matrix.aiida-core-version == '2.3' && '--cov=aiidalab_qe' || '' }} --skip-slow

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
31 changes: 15 additions & 16 deletions qe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
"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",
Expand All @@ -86,17 +84,23 @@
" 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",
"\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"
" app.process = query[\"pk\"][0]"
]
},
{
Expand All @@ -111,7 +115,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -126,11 +130,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
},
"vscode": {
"interpreter": {
"hash": "d4d1e4263499bec80672ea0156c357c1ee493ec2b1c70f0acce89fc37c4a6abe"
}
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ aiidalab_qe.plugins.xas = pseudo_toc.yaml
aiidalab_qe.properties =
bands = aiidalab_qe.plugins.bands:bands
pdos = aiidalab_qe.plugins.pdos:pdos
xps = aiidalab_qe.plugins.xps:xps
electronic_structure = aiidalab_qe.plugins.electronic_structure:electronic_structure
xps = aiidalab_qe.plugins.xps:xps
xas = aiidalab_qe.plugins.xas:xas

aiida.workflows =
Expand Down
Loading

0 comments on commit 3d02dd5

Please sign in to comment.