Skip to content

Commit

Permalink
Merge pull request #293 from SCM-NV/restructure
Browse files Browse the repository at this point in the history
MAINT, DEP: Restructure the various `qmflows` sub packages
  • Loading branch information
BvB93 committed Apr 12, 2022
2 parents ba532c9 + 5c8097e commit 3493182
Show file tree
Hide file tree
Showing 98 changed files with 4,708 additions and 4,042 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3

- name: Install dependencies
run: pip install wheel twine
Expand Down
27 changes: 15 additions & 12 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
branches:
- master
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
Test:
Expand Down Expand Up @@ -38,12 +43,7 @@ jobs:
CP2K_DATA_DIR: "/home/runner/work/qmflows/qmflows/cp2k/data"

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install cp2k
if: matrix.os == 'ubuntu-latest'
Expand All @@ -53,13 +53,17 @@ jobs:
VERSION_SHORT=$(echo "${{ matrix.special }}" | grep -P -o "CP2K \K([\.0-9]+)")
VERSION=v"$VERSION_SHORT".0
echo ::group::"Get CP2K $VERSION data"
git clone https://github.com/cp2k/cp2k -q
cd cp2k
git -c advice.detachedHead=false checkout tags/$VERSION
echo ::endgroup::
echo ::group::"Get CP2K $VERSION binaries"
wget -nv https://github.com/cp2k/cp2k/releases/download/$VERSION/cp2k-$VERSION_SHORT-Linux-x86_64.ssmp -O cp2k.ssmp
chmod u+rx cp2k.ssmp
mv cp2k.ssmp /usr/local/bin/cp2k.popt
echo ::endgroup::
;;
*)
sudo apt install cp2k ;;
Expand All @@ -73,7 +77,6 @@ jobs:
uses: s-weigand/setup-conda@v1
with:
update-conda: true
conda-channels: anaconda, conda-forge

- name: Install dependencies
shell: bash
Expand All @@ -84,7 +87,7 @@ jobs:
source $CONDA/bin/activate test
pip install rdkit-pypi
pip install --pre -e .[test] --upgrade --force-reinstall
pip install git+https://github.com/SCM-NV/PLAMS@master --upgrade
pip uninstall plams -y; pip install git+https://github.com/SCM-NV/PLAMS@master --upgrade
pip install git+https://github.com/NLeSC/noodles@master --upgrade
;;
"no optional")
Expand Down Expand Up @@ -121,23 +124,23 @@ jobs:
pytest -m 'not (slow or long)' ;;
esac
- uses: codecov/codecov-action@v2
- uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
name: codecov-umbrella

Linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python 3.10 on ubuntu-latest
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install linters
run: pip install pydocstyle pycodestyle mypy "numpy>=1.21" pytest more_itertools types-PyYAML types-setuptools
run: pip install pydocstyle pycodestyle mypy "numpy>=1.21" pytest more_itertools types-PyYAML types-setuptools "pyparsing>=3.0.8"

- name: Python info
run: |
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

## Changed

* Used [pyyaml](https://pyyaml.org/wiki/PyYAMLDocumentation) for the [templates](https://github.com/SCM-NV/qmflows/blob/master/src/qmflows/templates/templates.py) instead of *JSON*
* Used [pyyaml](https://pyyaml.org/wiki/PyYAMLDocumentation) for the [templates](https://github.com/SCM-NV/qmflows/blob/master/src/qmflows/templates/_templates.py) instead of *JSON*
* Updated documentation
* Test wiht python 3.7

Expand Down
22 changes: 21 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
"""A pytest ``conftest.py`` file."""

import os
from pathlib import Path

collect_ignore = [os.path.join('src', 'qmflows', 'settings.py')]
_ROOT = Path("src") / "qmflows"
_collect_ignore = [
_ROOT/ "settings.py",
_ROOT / "parsers" / "xyzParser.py",
_ROOT / "parsers" / "generic_parsers.py",
_ROOT / "parsers" / "parser.py",
_ROOT / "parsers" / "orca_parser.py",
_ROOT / "parsers" / "cp2KParser.py",
_ROOT / "parsers" / "adf_parser.py",
_ROOT / "templates" / "templates.py",
_ROOT / "packages" / "cp2k_mm.py",
_ROOT / "packages" / "cp2k_package.py",
_ROOT / "packages" / "orca.py",
_ROOT / "packages" / "package_wrapper.py",
_ROOT / "packages" / "packages.py",
_ROOT / "packages" / "serializer.py",
_ROOT / "packages" / "SCM.py",
]

collect_ignore = [str(i) for i in _collect_ignore]
106 changes: 68 additions & 38 deletions docs/_packages.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
qmflows.packages
================

The :class:`~qmflows.packages.packages.Package` (sub-)classes of QMFlows.
The :class:`~qmflows.packages.Package` (sub-)classes of QMFlows.

Package-related Functions
-------------------------
.. currentmodule:: qmflows.packages.packages
.. currentmodule:: qmflows.packages
.. autosummary::
run

Expand All @@ -14,81 +14,111 @@ The Package Class
.. autosummary::
Package
Package.__init__
Package.__repr__
Package.__call__
Package.prerun
Package.run_job
Package.postrun
Package.generic2specific
Package.handle_special_keywords

Package Subclasses
------------------
.. currentmodule:: qmflows.packages
.. autosummary::
~SCM.ADF
~SCM.DFTB
~cp2k_package.CP2K
~cp2k_mm.CP2KMM
~orca.ORCA
~package_wrapper.PackageWrapper
ADF
DFTB
CP2K
CP2KMM
ORCA
PackageWrapper

Package Instances
------------------
.. autosummary::
~SCM.adf
~SCM.dftb
~cp2k_package.cp2k
~cp2k_mm.cp2k_mm
~orca.orca
adf
dftb
cp2k
cp2k_mm
orca

The Result Class
-----------------
.. autosummary::
Result
Result.__init__
Result.get_property
Result.results

.. autosummary::
ADF_Result
DFTB_Result
CP2K_Result
CP2KMM_Result
ORCA_Result
ResultWrapper

API
---
.. autofunction:: qmflows.packages.packages.run
.. autofunction:: qmflows.packages.run

|
.. autoclass:: qmflows.packages.packages.Package
.. autoclass:: qmflows.packages.Package
:members: generic_mapping, result_type, pkg_name

.. automethod:: qmflows.packages.packages.Package.__init__
.. automethod:: qmflows.packages.packages.Package.__repr__
.. automethod:: qmflows.packages.packages.Package.__call__
.. automethod:: qmflows.packages.packages.Package.prerun
.. automethod:: qmflows.packages.packages.Package.run_job
.. automethod:: qmflows.packages.packages.Package.postrun
.. automethod:: qmflows.packages.packages.Package.generic2specific
.. automethod:: qmflows.packages.packages.Package.handle_special_keywords
.. automethod:: qmflows.packages.Package.__init__
.. automethod:: qmflows.packages.Package.__call__
.. automethod:: qmflows.packages.Package.prerun
.. automethod:: qmflows.packages.Package.run_job
.. automethod:: qmflows.packages.Package.postrun
.. automethod:: qmflows.packages.Package.generic2specific
.. automethod:: qmflows.packages.Package.handle_special_keywords

|
.. autoclass:: qmflows.packages.SCM.ADF
.. autoclass:: qmflows.packages.ADF

|
.. autoclass:: qmflows.packages.SCM.DFTB
.. autoclass:: qmflows.packages.DFTB

|
.. autoclass:: qmflows.packages.cp2k_package.CP2K
.. autoclass:: qmflows.packages.CP2K

|
.. autoclass:: qmflows.packages.cp2k_mm.CP2KMM
.. autoclass:: qmflows.packages.CP2KMM

|
.. autoclass:: qmflows.packages.orca.ORCA
.. autoclass:: qmflows.packages.ORCA

|
.. autoclass:: qmflows.packages.PackageWrapper
:noindex:

|
.. autoclass:: qmflows.packages.Result
:members: prop_mapping

.. automethod:: qmflows.packages.Result.__init__
.. automethod:: qmflows.packages.Result.get_property
.. autoproperty:: qmflows.packages.Result.results

|
.. autoclass:: qmflows.packages.package_wrapper.PackageWrapper
.. autoclass:: qmflows.packages.ADF_Result
.. autoclass:: qmflows.packages.DFTB_Result
.. autoclass:: qmflows.packages.CP2K_Result
.. autoclass:: qmflows.packages.CP2KMM_Result
.. autoclass:: qmflows.packages.ORCA_Result
.. autoclass:: qmflows.packages.ResultWrapper
:noindex:

|
.. autodata:: qmflows.packages.SCM.adf
.. autodata:: qmflows.packages.SCM.dftb
.. autodata:: qmflows.packages.cp2k_package.cp2k
.. autodata:: qmflows.packages.cp2k_mm.cp2k_mm
.. autodata:: qmflows.packages.orca.orca
.. autofunction:: qmflows.packages.adf
.. autofunction:: qmflows.packages.dftb
.. autofunction:: qmflows.packages.cp2k
.. autofunction:: qmflows.packages.cp2k_mm
.. autofunction:: qmflows.packages.orca
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,5 @@

rst_epilog = """
.. |Package| replace:: :class:`~qmflows.packages.Package`
.. |Settings| replace:: :class:`~qmflows.settings.Settings`
.. |Settings| replace:: :class:`~qmflows.Settings`
"""
2 changes: 1 addition & 1 deletion docs/dictionaries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ translation of the generic keywords and properties extraction.


to translate the generic keywords provided by the user to specific keywords used for each package.
For instance these files are used by the :class:`~qmflows.packages.packages.Package` class.
For instance these files are used by the :class:`~qmflows.packages.Package` class.
2 changes: 1 addition & 1 deletion docs/package_wrapper.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PackageWrapper
==============

.. automodule:: qmflows.packages.package_wrapper
.. automodule:: qmflows.packages._package_wrapper
14 changes: 7 additions & 7 deletions docs/packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
Packages
========

The base class :class:`~qmflows.packages.packages.Package` is the library core, it provides the general scaffold to call a quantum code.
The base class :class:`~qmflows.packages.Package` is the library core, it provides the general scaffold to call a quantum code.
On top of this infrastructure it has been created several subclasses that contain the specific details for each quantum code.
The available interfaces to quantum codes are:

* :class:`~qmflows.packages.SCM.ADF`
* :class:`~qmflows.packages.SCM.DFTB`
* :class:`~qmflows.packages.cp2k_package.CP2K`
* :class:`~qmflows.packages.cp2k_mm.CP2KMM`
* :class:`~qmflows.packages.orca.ORCA`
* :class:`~qmflows.packages.ADF`
* :class:`~qmflows.packages.DFTB`
* :class:`~qmflows.packages.CP2K`
* :class:`~qmflows.packages.CP2KMM`
* :class:`~qmflows.packages.ORCA`



**This class must not be call directly**, instead the correspoding class for the quantum package should be called or in case that there is not an interface to your quantum code,
you can make a new subclass that implement the following method:

* ``run_job`` -- This methods takes a :class:`~qmflows.settings.Settings` object a molecule and call a function to create the input automatically and takes cares of the bookkeeping associated with creating new folders, calling the package and retrieving and Object-result.
* ``run_job`` -- This methods takes a :class:`~qmflows.Settings` object a molecule and call a function to create the input automatically and takes cares of the bookkeeping associated with creating new folders, calling the package and retrieving and Object-result.


Instead of implementing all the runners and the bookkeeping functions ourselves, we use the plams_ library.
Expand Down
8 changes: 4 additions & 4 deletions docs/parsers.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Extracting numerical properties from output files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quantum packages simulations generate output file in different formats. For examples the SCM_ simulation suite
(:class:`~qmflows.packages.SCM.ADF` and :class:`~qmflows.packages.SCM.DFTB` in *QMFlows*) generate binary outputs,
while other packages like :class:`~qmflows.packages.cp2k_package.CP2K` and :class:`~qmflows.packages.orca.ORCA` generate ascii text files.
(:class:`~qmflows.packages.ADF` and :class:`~qmflows.packages.DFTB` in *QMFlows*) generate binary outputs,
while other packages like :class:`~qmflows.packages.CP2K` and :class:`~qmflows.packages.ORCA` generate ascii text files.

*QMFlows* abstract away all the different commmunication protocols with the different output formats, allowing the user to
extract the desire property by using the convention:
Expand All @@ -21,8 +21,8 @@ pacakge are implemented*. **If the property of your interest is not available yo

Parsers
~~~~~~~
Internally *QMFlows* uses different mechanism to extract different properties from the output files. In the case of the :class:`~qmflows.packages.SCM.ADF` and
:class:`~qmflows.packages.SCM.DFTB` packages, *QMFlows* take advantages of the python interface to kftools_ files developed by the SCM_. In the case of *XML* output,
Internally *QMFlows* uses different mechanism to extract different properties from the output files. In the case of the :class:`~qmflows.packages.ADF` and
:class:`~qmflows.packages.DFTB` packages, *QMFlows* take advantages of the python interface to kftools_ files developed by the SCM_. In the case of *XML* output,
*QMFlows* direcltly uses the python built-in xml_ reader. For the output files in text format *Qmflows* uses a mixuture of awk_ and
*parsers*.

Expand Down
10 changes: 5 additions & 5 deletions docs/promise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ them form an graph (specifically an acyclic direct graph) that represent these r

**QMFlows** Builds the aforemention graph in order to realize the workflow evaluation order.
For instance the figure below represent a simulation where firstly a molecular geometry optimization is carried out using the *ADF* package and
some user defined :class:`~qmflows.settings.Settings` for the *ADF* simulation package.
some user defined :class:`~qmflows.Settings` for the *ADF* simulation package.
Subsequently, using the optimized molecular geometry from the previous step and
another :class:`~qmflows.settings.Settings` for an orca simulation a job to compute the molecular frequencies is carried out.
another :class:`~qmflows.Settings` for an orca simulation a job to compute the molecular frequencies is carried out.

.. image:: _images/simple_graph.png

Expand Down Expand Up @@ -43,10 +43,10 @@ A python script corresponding with this graph can be
>>> print(result)
Up to the invocation of the :func:`~qmflows.packages.packages.run` function none of the computations have been executed,
it is the :func:`~qmflows.packages.packages.run` function which builds and executes the dependencies.
Up to the invocation of the :func:`~qmflows.packages.run` function none of the computations have been executed,
it is the :func:`~qmflows.packages.run` function which builds and executes the dependencies.
Since *QMFlows* needs to figure out all the dependecies in the script,
the :func:`~qmflows.packages.packages.run` function takes as argument last dependency (or inner most dependy),
the :func:`~qmflows.packages.run` function takes as argument last dependency (or inner most dependy),
which in this case are the frequencies. The reason behind this, is that from the last dependency it is possible to
retrace all the dependecies.

Expand Down

0 comments on commit 3493182

Please sign in to comment.