Skip to content

Commit

Permalink
Merge branch 'main' into electron_maxstep
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresOrtegaGuerrero authored Sep 18, 2024
2 parents 41244cf + 95e8f4b commit 7ff443d
Show file tree
Hide file tree
Showing 26 changed files with 485 additions and 98 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ concurrency:

env:
FORCE_COLOR: 1
UV_VERSION: 0.3.0

jobs:

Expand Down Expand Up @@ -45,7 +44,9 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install uv
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/${{ env.UV_VERSION }}/uv-installer.sh | sh
uses: astral-sh/setup-uv@v1
with:
version: 0.4.7

- name: Install package
run: uv pip install --system -e .[dev] aiida-core==${{ matrix.aiida-core-version }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
build/
export/
.do-not-setup-on-localhost

.mypy_cache/

# Sphinx documentation
docs/html
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
ARG FULL_STACK_VER=2024.1021
ARG UV_VER=0.2.27
ARG FULL_STACK_VER=2024.1022
ARG UV_VER=0.4.7
ARG QE_VER=7.2
ARG QE_DIR=/opt/conda/envs/quantum-espresso-${QE_VER}

Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
addopts = '--strict-config --strict-markers --durations=30 --durations-min=1 -ra'
filterwarnings = [
'ignore:Object of type .* not in session, .* operation along .* will not proceed:',
# This is needed since SQLAlchemy 2.0, see
# https://github.com/aiidalab/aiidalab-widgets-base/issues/605
'ignore:Object of type.*not in session,.*operation along.*will not proceed:',
'ignore:Creating AiiDA configuration:UserWarning:',
'ignore:metadata.*traitlets.traitlets.Unicode object:DeprecationWarning:',
# For some reason we get this error, see
# https://github.com/aiidalab/aiidalab-widgets-base/issues/551
'ignore:Exception ignored in:pytest.PytestUnraisableExceptionWarning:_pytest',
# This popped up in spglib 2.5. Since we still try to support spglib v1,
"ignore:dict interface.*is deprecated.Use attribute interface:DeprecationWarning:",
]

[tool.ruff]
Expand Down
77 changes: 46 additions & 31 deletions qe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
"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,
Expand All @@ -36,21 +47,24 @@
"\n",
" sys.modules[\"pybel\"] = __import__(\"openbabel\", globals(), locals(), [\"pybel\"]).pybel\n",
"except Exception:\n",
" pass\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display\n",
"\n",
"import urllib.parse as urlparse\n",
"from datetime import datetime\n",
"from aiidalab_qe.app.wrapper import AppWrapperContoller, AppWrapperModel, AppWrapperView\n",
"\n",
"import ipywidgets as ipw\n",
"from importlib_resources import files\n",
"from IPython.display import display\n",
"from jinja2 import Environment\n",
"model = AppWrapperModel()\n",
"view = AppWrapperView()\n",
"controller = AppWrapperContoller(model, view)\n",
"\n",
"from aiidalab_qe.app import App, static\n",
"from aiidalab_qe.version import __version__\n",
"from aiidalab_widgets_base.bug_report import (\n",
" install_create_github_issue_exception_handler,\n",
")"
"display(view)"
]
},
{
Expand All @@ -59,37 +73,38 @@
"metadata": {},
"outputs": [],
"source": [
"env = Environment()\n",
"import urllib.parse as urlparse\n",
"\n",
"template = files(static).joinpath(\"welcome.jinja\").read_text()\n",
"style = files(static).joinpath(\"style.css\").read_text()\n",
"welcome_message = ipw.HTML(env.from_string(template).render(style=style))\n",
"current_year = datetime.now().year\n",
"footer = ipw.HTML(\n",
" f'<p style=\"text-align:right;\">Copyright (c) {current_year} AiiDAlab team &#8195Version: {__version__}</p>'\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",
"\n",
"app_with_work_chain_selector = App(qe_auto_setup=True)\n",
"# if a pk is provided in the query string, set it as the value of the work_chain_selector\n",
"if \"pk\" in query:\n",
" pk = int(query[\"pk\"][0])\n",
" app_with_work_chain_selector.work_chain_selector.value = pk\n",
"\n",
"output = ipw.Output()\n",
"install_create_github_issue_exception_handler(\n",
" output,\n",
" url=\"https://github.com/aiidalab/aiidalab-qe/issues/new\",\n",
" labels=(\"bug\", \"automated-report\"),\n",
")\n",
"\n",
"with output:\n",
" display(welcome_message, app_with_work_chain_selector, footer)\n",
"\n",
"display(output)"
"view.main.children = [app_with_work_chain_selector]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"controller.enable_toggles()"
]
}
],
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install_requires =
aiida-core~=2.2,<3
Jinja2~=3.0
aiida-quantumespresso~=4.6
aiidalab-widgets-base[optimade]~=2.2.0,<2.4.0
aiidalab-widgets-base[optimade]==2.3.0a2
aiida-pseudo~=1.4
filelock~=3.8
importlib-resources~=5.2
Expand All @@ -47,7 +47,8 @@ dev =

[options.package_data]
aiidalab_qe.app.parameters = qeapp.yaml
aiidalab_qe.app.static = *
aiidalab_qe.app.static.styles = *.css
aiidalab_qe.app.static.templates = *.jinja
aiidalab_qe.app.structure.examples = *
aiidalab_qe.plugins.xas = pseudo_toc.yaml

Expand Down
6 changes: 0 additions & 6 deletions src/aiidalab_qe/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
"""Package for the AiiDAlab QE app."""

from .main import App

__all__ = [
"App",
]
8 changes: 4 additions & 4 deletions src/aiidalab_qe/app/result/summary_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ def _generate_report_html(report):
"""Read from the bulider parameters and generate a html for reporting
the inputs for the `QeAppWorkChain`.
"""
from importlib import resources
from importlib.resources import files

from jinja2 import Environment

from aiidalab_qe.app import static
from aiidalab_qe.app.static import styles, templates

def _fmt_yes_no(truthy):
return "Yes" if truthy else "No"
Expand All @@ -169,8 +169,8 @@ def _fmt_yes_no(truthy):
"fmt_yes_no": _fmt_yes_no,
}
)
template = resources.read_text(static, "workflow_summary.jinja")
style = resources.read_text(static, "style.css")
template = files(templates).joinpath("workflow_summary.jinja").read_text()
style = files(styles).joinpath("style.css").read_text()
report = {key: value for key, value in report.items() if value is not None}

return env.from_string(template).render(style=style, **report)
Expand Down
8 changes: 4 additions & 4 deletions src/aiidalab_qe/app/result/workchain_viewer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import shutil
import typing as t
from importlib import resources
from importlib.resources import files
from pathlib import Path
from tempfile import TemporaryDirectory

Expand All @@ -14,7 +14,7 @@
from aiida.cmdline.utils.common import get_workchain_report
from aiida.common import LinkType
from aiida.orm.utils.serialize import deserialize_unsafe
from aiidalab_qe.app import static
from aiidalab_qe.app.static import styles, templates
from aiidalab_qe.app.utils import get_entry_items
from aiidalab_widgets_base import ProcessMonitor, register_viewer_widget
from aiidalab_widgets_base.viewers import StructureDataViewer
Expand Down Expand Up @@ -175,8 +175,8 @@ def __init__(self, node, export_dir=None, **kwargs):
)
final_calcjob = self._get_final_calcjob(node)
env = Environment()
template = resources.read_text(static, "workflow_failure.jinja")
style = resources.read_text(static, "style.css")
template = files(templates).joinpath("workflow_failure.jinja").read_text()
style = files(styles).joinpath("style.css").read_text()
output = ipw.HTML(
env.from_string(template).render(
style=style,
Expand Down
13 changes: 13 additions & 0 deletions src/aiidalab_qe/app/static/styles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Stylesheets for the Quantum ESPRESSO app

This folder contains `css` stylesheets. These can be loaded from the styles folder using

```python
from aiidalab_widgets_base.utils.loaders import load_css

load_css(css_path="src/aiidalab_qe/app/static/styles") # load all stylesheets in the styles folder

# or

load_css(css_path="src/aiidalab_qe/app/static/styles/<stylesheet>.css") # load a single stylesheet
```
Empty file.
48 changes: 48 additions & 0 deletions src/aiidalab_qe/app/static/styles/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Override Jupyter width limitation to
make apps take full notebook width
*/
.output_subarea {
max-width: none !important;
}
/* end override */

.app-header {
margin-bottom: 1em;
}

.logo {
text-align: center;
}

#subtitle {
text-align: center;
font-style: italic;
}

.info-toggles {
margin: 0 auto;
}
.info-toggles button {
width: 100px;
margin: 1em 0.5em;
}
.info-toggles button:focus {
outline: none !important;
}

.guide ol {
list-style: none;
}
.guide p:not(:last-of-type) {
margin-bottom: 0.5em;
}

#loading {
text-align: center;
font-size: large;
}

footer {
text-align: right;
}
15 changes: 15 additions & 0 deletions src/aiidalab_qe/app/static/styles/infobox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.info-box {
display: none;
margin: 2px;
padding: 1em;
border: 3px solid orangered;
background-color: #ffedcc;
border-radius: 1em;
-webkit-border-radius: 1em;
-moz-border-radius: 1em;
-ms-border-radius: 1em;
-o-border-radius: 1em;
}
.info-box p {
line-height: 24px;
}
File renamed without changes.
Empty file.
10 changes: 10 additions & 0 deletions src/aiidalab_qe/app/static/templates/about.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="about">
<p>
The <a href="https://www.quantum-espresso.org/" target="_blank">Quantum ESPRESSO</a> app
(or QE app for short) is a graphical front end for calculating materials properties using
Quantum ESPRESSO (QE). Each property is calculated by workflows powered by the
<a href="https://www.aiida.net/" target="_bland"> AiiDA engine</a>, and maintained in the
<a href="https://aiida-quantumespresso.readthedocs.io/en/latest/" target="_blank">aiida-quantumespresso plugin</a> and many other plugins developed by the community.
for AiiDA.
</p>
</div>
42 changes: 42 additions & 0 deletions src/aiidalab_qe/app/static/templates/guide.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div class="guide">
<p>
The QE app allows you to calculate properties in a simple 4-step process:
</p>

<ol>
<li>
🔍 <strong>Step 1:</strong> Select the structure you want to run.
</li>
<li>
⚙️ <strong>Step 2:</strong> Select the properties you are interested in.
</li>
<li>
💻 <strong>Step 3:</strong> Choose the computational resources you want to run on.
</li>
<li>
🚀 <strong>Step 4:</strong> Submit your workflow.
</li>
</ol>

<p>
New users can go straight to the first step and select their structure.
</p>

<p>
Completed workflows can be selected at the top of the app.
</p>

<p>
You can also check out the
<a href="https://aiidalab-qe.readthedocs.io/tutorials/basic.html" target="_blank">basic</a> tutorial to get started
with the Quantum ESPRESSO app, or try out the
<a href="https://aiidalab-qe.readthedocs.io/tutorials/advanced.html" target="_blank">advanced</a> tutorial to learn
additional features offered by the app.
</p>

<p>
For a more in-depth dive into the app's features, please refer to the
<a href="https://aiidalab-qe.readthedocs.io/howto/index.html" target="_blank">how-to guides</a>.
</p>
</p>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<head>
<style>
{{ style }}
</style>
</head>

<body>

<div class="alert alert-danger error-container">
Expand Down
Loading

0 comments on commit 7ff443d

Please sign in to comment.