Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/gha-dependencies-0…
Browse files Browse the repository at this point in the history
…e111ef9fd
  • Loading branch information
superstar54 authored Feb 13, 2025
2 parents b0daa24 + 52b281f commit f1edb23
Show file tree
Hide file tree
Showing 181 changed files with 8,146 additions and 5,725 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
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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_VER=7.4
ARG QE_DIR=/opt/conda/envs/quantum-espresso-${QE_VER}
ARG HQ_VER=0.19.0

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 All @@ -58,6 +59,12 @@ RUN wget -c -O hq.tar.gz https://github.com/It4innovations/hyperqueue/releases/d
tar xf hq.tar.gz -C /opt/conda/

ENV PSEUDO_FOLDER=/tmp/pseudo
# temporary solution to install aiida-pseudos from repo to avoid downloading issues
RUN --mount=from=uv,source=/uv,target=/bin/uv \
--mount=from=build_deps,source=${UV_CACHE_DIR},target=${UV_CACHE_DIR},rw \
uv pip install --system --strict --cache-dir=${UV_CACHE_DIR} \
"aiida-pseudo@git+https://github.com/aiidateam/aiida-pseudo"

RUN mkdir -p ${PSEUDO_FOLDER} && \
python -m aiidalab_qe download-pseudos --dest ${PSEUDO_FOLDER}

Expand All @@ -83,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
142 changes: 142 additions & 0 deletions calculation_history.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"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 | View history'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"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": "markdown",
"metadata": {},
"source": [
"# AiiDAlab Quantum ESPRESSO - Calculation history"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"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",
"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=[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 = CalculationHistory()\n",
"calculation_history.main"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"calculation_history.load_table()"
]
}
],
"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"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit f1edb23

Please sign in to comment.