Skip to content

Commit

Permalink
Support exit code (#3)
Browse files Browse the repository at this point in the history
1) modify the `exectue` method, so that it does not raise if the calculation failed, so that we can parse the result and return an exit_code
2) use the parser from aiida-quantumespresso to parse the results
3) add docs
4) add tests
  • Loading branch information
superstar54 authored Sep 10, 2024
1 parent 36f0a8e commit 8c9181a
Show file tree
Hide file tree
Showing 29 changed files with 12,463 additions and 140 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: ci

on: [push, pull_request]

jobs:

pre-commit:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Cache Python dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: pip-pre-commit-${{ hashFiles('**/setup.json') }}
restore-keys:
pip-pre-commit-

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install Python dependencies
run: pip install -e .[pre-commit,tests]

- name: Run pre-commit
run: pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )

test:

runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.11']

steps:
- uses: actions/checkout@v2

- name: Cache Python dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: pip-${{ matrix.python-version }}-tests-${{ hashFiles('**/setup.json') }}
restore-keys:
pip-${{ matrix.python-version }}-tests

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: sudo apt update && sudo apt install --no-install-recommends libfftw3-dev quantum-espresso

- name: Install Python dependencies
run: |
pip install -e .[pre-commit,tests]
- name: Run pytest
run: |
pytest -v tests --cov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: python-${{ matrix.python-version }}
15 changes: 15 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.11"

# Build from the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Explicitly set the version of Python and its requirements
python:
install:
- requirements: docs/requirements.txt
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx_rtd_theme==1.2.2
nbsphinx==0.9.2
ipython
91 changes: 91 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import shutil
from pathlib import Path

sys.path.insert(0, os.path.abspath("../.."))


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

project = "ASE QuantumESPRESSO"
copyright = "2024, Xing Wang"
author = "Xing Wang"

# The full version, including alpha/beta/rc tags
release = "0.0.1"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"nbsphinx",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]


# Function to copy HTML files
def copy_html_files(app, exception):
"""
Copy all .html files from source to build directory, maintaining the directory structure.
"""
print("Copying HTML files to build directory")
if exception is not None: # Only copy files if the build succeeded
print(
"Build failed, but we still try to copy the HTML files to the build directory"
)
try:
src_path = Path(app.builder.srcdir)
build_path = Path(app.builder.outdir)
for html_file in src_path.rglob("*.html"):
relative_path = html_file.relative_to(src_path)
destination_file = build_path / relative_path
destination_file.parent.mkdir(parents=True, exist_ok=True)
shutil.copy(html_file, destination_file)
except Exception as e:
print(f"Failed to copy HTML files: {e}")


def setup(app):
app.connect("build-finished", copy_html_files)
13 changes: 13 additions & 0 deletions docs/source/howtos/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Quantum ESPRESSO
===========================================

Here are the collection of WorkGraphs for Quantum ESPRESSO

.. toctree::
:maxdepth: 1
:caption: Contents:

base
pw
dos
projwfc
23 changes: 23 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Welcome to WorkGraph Collections' documentation!
===================================================

Extends the functionality of ASE espresso module by providing additional calculators for Quantum ESPRESSO binaries, including pw.x, dos.x, pp.x, and others.



.. toctree::
:maxdepth: 1
:caption: Contents:

installation
quickstart
howtos/index


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
16 changes: 16 additions & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
============
Installation
============


The recommended method of installation is to use the Python package manager |pip|_:

.. code-block:: console
$ pip install ase-quantumespresso
This will install the latest version.


.. _pip: https://pip.pypa.io/en/stable/
Loading

0 comments on commit 8c9181a

Please sign in to comment.