Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresOrtegaGuerrero authored Jan 24, 2025
2 parents eba389e + a9a6280 commit 2f6dc98
Show file tree
Hide file tree
Showing 84 changed files with 3,264 additions and 1,200 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Required
version: 2

sphinx:
configuration: docs/source/conf.py

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
ARG FULL_STACK_VER=2024.1023
ARG FULL_STACK_VER=2025.1025
ARG UV_VER=0.4.7
ARG QE_VER=7.2
ARG QE_DIR=/opt/conda/envs/quantum-espresso-${QE_VER}
Expand Down Expand Up @@ -49,6 +49,7 @@ RUN --mount=from=uv,source=/uv,target=/bin/uv \
# - Install QE codes and pseudopotentials
# - Archive home folder
FROM build_deps AS home_build
ARG UV_CACHE_DIR
ARG QE_DIR
ARG HQ_VER
ARG HQ_COMPUTER
Expand Down Expand Up @@ -89,7 +90,9 @@ RUN --mount=from=qe_conda_env,source=${QE_DIR},target=${QE_DIR} \
verdi daemon stop && \
mamba run -n aiida-core-services pg_ctl stop && \
touch /home/${NB_USER}/.FLAG_HOME_INITIALIZED && \
cd /home/${NB_USER} && tar -cf /opt/conda/home.tar .
# NOTE: The work folder is empty but if included clashes with the work folder in a Renku
# session whose permissions cannot be changed.
cd /home/${NB_USER} && tar -cf /opt/conda/home.tar --exclude work .

# STAGE 3 - Final stage
# - Install python dependencies
Expand Down
9 changes: 5 additions & 4 deletions before-notebook.d/00_untar-home.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ if [ ! -e $home/.FLAG_HOME_INITIALIZED ]; then
fi

echo "Extracting $HOME_TAR to $home"
# NOTE: a tar error when deployed to k8s but at the momment not cause any issue
# tar: .: Cannot utime: Operation not permitted
# tar: .: Cannot change mode to rwxr-s---: Operation not permitted
tar -xf $HOME_TAR -C "$home"
# NOTE: the added flags to tar are to address some errors that occur in k8s
# tar: .: Cannot utime: Operation not permitted -> --touch solves this problem
# tar: .: Cannot change mode to rwxr-s---: Operation not permitted -> --no-overwrite-dir solves this problem
# this only refers to the metadata and permissions of existing directories, not their contents
tar -xf $HOME_TAR -C "$home" --no-overwrite-dir --touch
else
echo "$home folder is not empty!"
ls -lrta "$home"
Expand Down
55 changes: 36 additions & 19 deletions before-notebook.d/43_start-hq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,51 @@ set -x
# But for developers, please update your cgroup version to v2.
# See: https://kubernetes.io/docs/concepts/architecture/cgroups/#using-cgroupv2

# computer memory from runtime
MEMORY_LIMIT=$(cat /sys/fs/cgroup/memory.max)
# Default to cgroupv1 paths
CPU_QUOTA_PATH="/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
CPU_PERIOD_PATH="/sys/fs/cgroup/cpu/cpu.cfs_period_us"
MEMORY_LIMIT_PATH="/sys/fs/cgroup/memory/memory.limit_in_bytes"

if [ "$MEMORY_LIMIT" = "max" ]; then
MEMORY_LIMIT=4096
echo "No memory limit set, use 4GiB"
else
MEMORY_LIMIT=$(echo "scale=0; $MEMORY_LIMIT / (1024 * 1024)" | bc)
echo "Memory Limit: ${MEMORY_LIMIT} MiB"
# Fallback if cgroupv2 paths exist
if [ -f /sys/fs/cgroup/cpu.max ]; then
CPU_QUOTA_PATH="/sys/fs/cgroup/cpu.max"
CPU_PERIOD_PATH="/sys/fs/cgroup/cpu.max"
fi

if [ -f /sys/fs/cgroup/memory.max ]; then
MEMORY_LIMIT_PATH="/sys/fs/cgroup/memory.max"
fi

# Compute number of cpus allocated to the container
CPU_LIMIT=$(awk '{print $1}' /sys/fs/cgroup/cpu.max)
CPU_PERIOD=$(awk '{print $2}' /sys/fs/cgroup/cpu.max)
# Compute memory limit
if [ -f "$MEMORY_LIMIT_PATH" ]; then
MEMORY_LIMIT=$(cat "$MEMORY_LIMIT_PATH")
if [ "$MEMORY_LIMIT" = "max" ] || [ "$MEMORY_LIMIT" -eq -1 ]; then
MEMORY_LIMIT=4096
else
MEMORY_LIMIT=$(echo "scale=0; $MEMORY_LIMIT / (1024 * 1024)" | bc)
fi
else
MEMORY_LIMIT=4096
fi
echo "Memory Limit: ${MEMORY_LIMIT} MiB"

if [ "$CPU_PERIOD" -ne 0 ]; then
CPU_NUMBER=$(echo "scale=2; $CPU_LIMIT / $CPU_PERIOD" | bc)
echo "Number of CPUs allocated: $CPU_NUMBER"
# Compute CPU limit
if [ -f "$CPU_QUOTA_PATH" ] && [ -f "$CPU_PERIOD_PATH" ]; then
CPU_LIMIT=$(cat "$CPU_QUOTA_PATH")
CPU_PERIOD=$(cat "$CPU_PERIOD_PATH")

# for HQ setting round to integer number of CPUs, the left are for system tasks
CPU_LIMIT=$(echo "scale=0; $CPU_LIMIT / $CPU_PERIOD" | bc)
if [ "$CPU_LIMIT" != "max" ] && [ "$CPU_PERIOD" -ne 0 ]; then
CPU_NUMBER=$(echo "scale=2; $CPU_LIMIT / $CPU_PERIOD" | bc)
CPU_LIMIT=$(echo "$CPU_NUMBER / 1" | bc) # Round down to integer
else
CPU_LIMIT=$(nproc)
fi
else
# if no limit (with local OCI without setting cpu limit, use all CPUs)
CPU_LIMIT=$(nproc)
echo "No CPU limit set"
fi
echo "Number of CPUs allocated: $CPU_LIMIT"

# Start hq server with a worker
# Start HQ server and worker
run-one-constantly hq server start 1>$HOME/.hq-stdout 2>$HOME/.hq-stderr &
run-one-constantly hq worker start --cpus=${CPU_LIMIT} --resource "mem=sum(${MEMORY_LIMIT})" --no-detect-resources &

Expand Down
137 changes: 65 additions & 72 deletions calculation_history.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,11 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw\n",
"\n",
"how_to = ipw.HTML(\n",
" \"\"\"\n",
" <style>\n",
" .page-title {\n",
" font-family: Arial, sans-serif;\n",
" font-size: 28px;\n",
" color: #2c3e50;\n",
" margin-top: 0;\n",
" margin-bottom: 20px;\n",
" }\n",
" .how-to-section {\n",
" font-family: Arial, sans-serif;\n",
" background-color: #f9f9f9;\n",
" border: 1px solid #ddd;\n",
" border-radius: 8px;\n",
" padding: 15px 20px;\n",
" margin-bottom: 20px;\n",
" box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);\n",
" }\n",
" .how-to-section h2 {\n",
" color: #2c3e50;\n",
" font-size: 24px;\n",
" margin-top: 0;\n",
" }\n",
" .how-to-section p {\n",
" font-size: 14px;\n",
" color: #7f8c8d;\n",
" line-height: 1.6;\n",
" }\n",
" .how-to-section ul {\n",
" list-style-type: disc;\n",
" padding-left: 20px;\n",
" }\n",
" .how-to-section ul li {\n",
" font-size: 14px;\n",
" color: #34495e;\n",
" margin-bottom: 8px;\n",
" }\n",
" .how-to-section ul li b {\n",
" color: #2c3e50;\n",
" }\n",
" </style>\n",
" <div class=\"page-title\">Calculation history</div>\n",
" <div class=\"how-to-section\">\n",
" <h2>How to use this page</h2>\n",
" <p>\n",
" This page allows you to view and manage your calculation history. Use the table below to\n",
" see all jobs in the database. You can use the following filters to narrow down your search:\n",
" </p>\n",
" <ul>\n",
" <li><b>Label search field:</b> Enter a job label to find matching jobs.</li>\n",
" <li><b>Job state dropdown:</b> Filter jobs based on their state (e.g., finished, running).</li>\n",
" <li><b>Date range picker:</b> Select a start and end date to view jobs created within that range.</li>\n",
" <li><b>Properties filter:</b> Select specific properties associated with jobs.</li>\n",
" </ul>\n",
" <p>\n",
" Each row in the table provides links to inspect, delete or download a job. To delete a job, click the \"Delete\"\n",
" link in the respective row. To view detailed information about a job, click the \"PK\" link. To download the\n",
" input/output files of a job, click the \"Download\" link.\n",
" </p>\n",
" </div>\n",
" \"\"\"\n",
")\n",
"\n",
"how_to"
"%%javascript\n",
"IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
" return false;\n",
"}\n",
"document.title='AiiDAlab QE app calculation history'"
]
},
{
Expand Down Expand Up @@ -104,11 +42,66 @@
"metadata": {},
"outputs": [],
"source": [
"from aiidalab_qe.app.utils.search_jobs import QueryInterface\n",
"import ipywidgets as ipw\n",
"from importlib_resources import files\n",
"from jinja2 import Environment\n",
"\n",
"from aiidalab_qe.app.static import templates\n",
"from aiidalab_qe.common.infobox import InfoBox\n",
"\n",
"title = ipw.HTML(\n",
" \"<h1> Calculation history</h1>\", layout=ipw.Layout(margin=\"0 0 15px 0\")\n",
")\n",
"env = Environment()\n",
"guide_template = (\n",
" files(templates).joinpath(\"calculation_history_guide.jinja\").read_text()\n",
")\n",
"guide = ipw.HTML(env.from_string(guide_template).render())\n",
"\n",
"\n",
"info_container = InfoBox(layout=ipw.Layout(margin=\"14px 2px 0\"))\n",
"guide_toggle = ipw.ToggleButton(\n",
" layout=ipw.Layout(width=\"150px\"),\n",
" button_style=\"\",\n",
" icon=\"book\",\n",
" value=False,\n",
" description=\"Page guide\",\n",
" tooltip=\"Learn how to use the app\",\n",
" disabled=False,\n",
")\n",
"\n",
"\n",
"def _on_guide_toggle(change: dict):\n",
" \"\"\"Toggle the guide section.\"\"\"\n",
" if change[\"new\"]:\n",
" info_container.children = [\n",
" guide,\n",
" ]\n",
" info_container.layout.display = \"flex\"\n",
" else:\n",
" info_container.children = []\n",
" info_container.layout.display = \"none\"\n",
"\n",
"\n",
"guide_toggle.observe(\n",
" _on_guide_toggle,\n",
" \"value\",\n",
")\n",
"\n",
"controls = ipw.VBox(children=[title, guide_toggle, info_container])\n",
"controls"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from aiidalab_qe.app.utils.search_jobs import CalculationHistory\n",
"\n",
"calculation_history = QueryInterface()\n",
"calculation_history.setup_table()\n",
"calculation_history.filters_layout"
"calculation_history = CalculationHistory()\n",
"calculation_history.main"
]
},
{
Expand All @@ -117,7 +110,7 @@
"metadata": {},
"outputs": [],
"source": [
"calculation_history.table"
"calculation_history.load_table()"
]
}
],
Expand Down
Binary file removed docs/source/_static/logo.png
Binary file not shown.
1 change: 1 addition & 0 deletions docs/source/_static/logo.png
Binary file removed docs/source/_static/logo_dark.png
Binary file not shown.
1 change: 1 addition & 0 deletions docs/source/_static/logo_dark.png
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# -- Project information -----------------------------------------------------

version = "v24.10.0a4"
version = "v24.10.0a7"
release = f"{version}-dev"
project = "Quantum ESPRESSO App"
copyright_first_year = "2023"
Expand Down
21 changes: 21 additions & 0 deletions docs/source/development/guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,24 @@ Developers have two options when using the ``InAppGuide`` widget:
A decent amount of ``InAppGuide(identifier=<identifier>)`` instances have been placed strategically throughout the app.
Developers may suggest additional core guide sections via GitHub pull requests.
For plugin developers, additional instances of either flavor are recommended to be added in any component of the plugin in conjunction with dedicated plugin-specific guides.

Plugin guides
-------------

Plugin developers can enhance user experience while using the app by introducing custom guides.
To do so, add the following key/value entry in your plugin's ``__init__.py`` file:

.. code:: python
my_plugin = {
...
"guides": <path-to-guide>,
}
where ``path-to-guide`` is the path (``Path`` object or absolute string path) to the directory containing the guide HTML files.
On app start, the guide manager will scan the plugin entry points for the ``guides`` key and load the guides accordingly.

Guide order
-----------

When naming your guide HTML documents, prefix the file name with ``#_``. The number ``#`` will determine the order in which the guides are displayed in the list.
Loading

0 comments on commit 2f6dc98

Please sign in to comment.