Skip to content

Commit

Permalink
Update repo config against aiida-core v2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jan 22, 2024
1 parent c9d6962 commit 7466b79
Show file tree
Hide file tree
Showing 38 changed files with 353 additions and 1,137 deletions.
95 changes: 24 additions & 71 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,36 @@ name: ci
on: [push, pull_request]

jobs:

tests:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.8"]
aiida-version: ["stable"]

services:
postgres:
image: postgres:10
env:
POSTGRES_DB: test_aiida
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672

steps:
- uses: actions/checkout@v2

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

- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[testing]
- name: Run test suite
env:
# show timings of tests
PYTEST_ADDOPTS: "--durations=0"
run: pytest --cov aiida_quantum_transport --cov-append .

docs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[docs]
- name: Build docs
run: cd docs && make
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[docs]
- name: Build docs
run: cd docs && make

pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,docs,testing]
- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,docs,testing]
- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
32 changes: 16 additions & 16 deletions .github/workflows/publish-on-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ jobs:
if: github.repository == 'edan-bainglass/aiida-quantum-transport' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

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

- name: Install flit
run: |
python -m pip install --upgrade pip
python -m pip install flit~=3.4
- name: Install flit
run: |
python -m pip install --upgrade pip
python -m pip install flit~=3.4
- name: Build and publish
run: |
flit publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.pypi_token }}
- name: Build and publish
run: |
flit publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.pypi_token }}
92 changes: 60 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,67 @@
# Install pre-commit hooks via:
# pre-commit install
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-json
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-merge-conflict
- id: check-yaml
- id: check-json
- id: fix-encoding-pragma
args: [--remove]
- id: mixed-line-ending
args: [--fix=lf]

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/ikamensh/flynt/
rev: 1.0.1
hooks:
- id: flynt
args: [--line-length=120, --fail-on-change]

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/executablebooks/mdformat
rev: "0.7.16"
hooks:
- id: mdformat

- repo: local
hooks:
- id: pylint
language: system
types: [file, python]
name: pylint
description: "This hook runs the pylint static code analyzer"
exclude: &exclude_files >
(?x)^(
docs/.*|
)$
entry: pylint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-toml
args: [--autofix]
exclude: >-
(?x)^(
pyproject.toml
)$
- id: pretty-format-yaml
args: [--autofix, --preserve-quotes, --offset, "2"]
exclude: >-
(?x)^(
tests/.*|
environment.yml
)$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
args: [--config-file=pyproject.toml]
exclude: &exclude_files >
(?x)^(
docs/.*|
tests/.*(?<!\.py)$
)$
1 change: 0 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: 2

python:
version: "3.8"
install:
- method: pip
path: .
Expand Down
87 changes: 23 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,91 +13,50 @@ intended to help developers get started with their AiiDA plugins.

## Repository contents

* [`.github/`](.github/): [Github Actions](https://github.com/features/actions) configuration
* [`ci.yml`](.github/workflows/ci.yml): runs tests, checks test coverage and builds documentation at every new commit
* [`publish-on-pypi.yml`](.github/workflows/publish-on-pypi.yml): automatically deploy git tags to PyPI - just generate a [PyPI API token](https://pypi.org/help/#apitoken) for your PyPI account and add it to the `pypi_token` secret of your github repository
* [`aiida_quantum_transport/`](aiida_quantum_transport/): The main source code of the plugin package
* [`data/`](aiida_quantum_transport/data/): A new `DiffParameters` data class, used as input to the `DiffCalculation` `CalcJob` class
* [`calculations.py`](aiida_quantum_transport/calculations.py): A new `DiffCalculation` `CalcJob` class
* [`cli.py`](aiida_quantum_transport/cli.py): Extensions of the `verdi data` command line interface for the `DiffParameters` class
* [`helpers.py`](aiida_quantum_transport/helpers.py): Helpers for setting up an AiiDA code for `diff` automatically
* [`parsers.py`](aiida_quantum_transport/parsers.py): A new `Parser` for the `DiffCalculation`
* [`docs/`](docs/): A documentation template ready for publication on [Read the Docs](http://aiida-diff.readthedocs.io/en/latest/)
* [`examples/`](examples/): An example of how to submit a calculation using this plugin
* [`tests/`](tests/): Basic regression tests using the [pytest](https://docs.pytest.org/en/latest/) framework (submitting a calculation, ...). Install `pip install -e .[testing]` and run `pytest`.
* [`.gitignore`](.gitignore): Telling git which files to ignore
* [`.pre-commit-config.yaml`](.pre-commit-config.yaml): Configuration of [pre-commit hooks](https://pre-commit.com/) that sanitize coding style and check for syntax errors. Enable via `pip install -e .[pre-commit] && pre-commit install`
* [`.readthedocs.yml`](.readthedocs.yml): Configuration of documentation build for [Read the Docs](https://readthedocs.org/)
* [`LICENSE`](LICENSE): License for your plugin
* [`README.md`](README.md): This file
* [`conftest.py`](conftest.py): Configuration of fixtures for [pytest](https://docs.pytest.org/en/latest/)
* [`pyproject.toml`](setup.json): Python package metadata for registration on [PyPI](https://pypi.org/) and the [AiiDA plugin registry](https://aiidateam.github.io/aiida-registry/) (including entry points)

See also the following video sequences from the 2019-05 AiiDA tutorial:

* [run aiida-diff example calculation](https://www.youtube.com/watch?v=2CxiuiA1uVs&t=403s)
* [aiida-diff CalcJob plugin](https://www.youtube.com/watch?v=2CxiuiA1uVs&t=685s)
* [aiida-diff Parser plugin](https://www.youtube.com/watch?v=2CxiuiA1uVs&t=936s)
* [aiida-diff computer/code helpers](https://www.youtube.com/watch?v=2CxiuiA1uVs&t=1238s)
* [aiida-diff input data (with validation)](https://www.youtube.com/watch?v=2CxiuiA1uVs&t=1353s)
* [aiida-diff cli](https://www.youtube.com/watch?v=2CxiuiA1uVs&t=1621s)
* [aiida-diff tests](https://www.youtube.com/watch?v=2CxiuiA1uVs&t=1931s)
* [Adding your plugin to the registry](https://www.youtube.com/watch?v=760O2lDB-TM&t=112s)
* [pre-commit hooks](https://www.youtube.com/watch?v=760O2lDB-TM&t=333s)

For more information, see the [developer guide](https://aiida-diff.readthedocs.io/en/latest/developer_guide) of your plugin.

- [`.github/`](.github/): [Github Actions](https://github.com/features/actions) configuration
- [`ci.yml`](.github/workflows/ci.yml): runs tests, checks test coverage and builds documentation at every new commit
- [`publish-on-pypi.yml`](.github/workflows/publish-on-pypi.yml): automatically deploy git tags to PyPI - just generate a [PyPI API token](https://pypi.org/help/#apitoken) for your PyPI account and add it to the `pypi_token` secret of your github repository
- [`src/aiida_quantum_transport/`](src/aiida_quantum_transport/): The main source code of the plugin package
- [`data/`](src/aiida_quantum_transport/data/): Custom data classes
- [`calculations.py`](src/aiida_quantum_transport/calculations.py): Quantum Transport AiiDA calculation classes
- [`cli.py`](src/aiida_quantum_transport/cli.py): Custom `verdi` CLI commands
- [`helpers.py`](src/aiida_quantum_transport/helpers.py): Helpers for setting up an AiiDA code
- [`parsers.py`](src/aiida_quantum_transport/parsers.py): Custom parser classes
- [`docs/`](docs/): The documentation of the plugin
- [`tests/`](tests/): Basic regression tests using the [pytest](https://docs.pytest.org/en/latest/) framework (submitting a calculation, ...). Install `pip install -e .[testing]` and run `pytest`.
- [`conftest.py`](tests/conftest.py): Configuration of fixtures for [pytest](https://docs.pytest.org/en/latest/)
- [`.gitignore`](.gitignore): Telling git which files to ignore
- [`.pre-commit-config.yaml`](.pre-commit-config.yaml): Configuration of [pre-commit hooks](https://pre-commit.com/) that sanitize coding style and check for syntax errors. Enable via `pip install -e .[pre-commit] && pre-commit install`
- [`.readthedocs.yml`](.readthedocs.yml): Configuration of documentation build for [Read the Docs](https://readthedocs.org/)
- [`LICENSE`](LICENSE): License for your plugin
- [`README.md`](README.md): This file
- [`pyproject.toml`](setup.json): Python package metadata for registration on [PyPI](https://pypi.org/) and the [AiiDA plugin registry](https://aiidateam.github.io/aiida-registry/) (including entry points)

## Features

* Add input files using `SinglefileData`:
```python
SinglefileData = DataFactory('singlefile')
inputs['file1'] = SinglefileData(file='/path/to/file1')
inputs['file2'] = SinglefileData(file='/path/to/file2')
```

* Specify command line options via a python dictionary and `DiffParameters`:
```python
d = { 'ignore-case': True }
DiffParameters = DataFactory('quantum_transport')
inputs['parameters'] = DiffParameters(dict=d)
```

* `DiffParameters` dictionaries are validated using [voluptuous](https://github.com/alecthomas/voluptuous).
Find out about supported options:
```python
DiffParameters = DataFactory('quantum_transport')
print(DiffParameters.schema.schema)
```
Under development

## Installation

```shell
pip install aiida-quantum-transport
verdi quicksetup # better to set up a new profile
verdi plugin list aiida.calculations # should now show your calclulation plugins
verdi quicksetup
verdi plugin list aiida.calculations
```


## Usage

Here goes a complete example of how to submit a test calculation using this plugin.

A quick demo of how to submit a calculation:

```shell
verdi daemon start # make sure the daemon is running
cd examples
./example_01.py # run test calculation
verdi process list -a # check record of calculation
```

The plugin also includes verdi commands to inspect its data types:
```shell
verdi data quantum_transport list
verdi data quantum_transport export <PK>
```

## Development

```shell
Expand All @@ -114,11 +73,11 @@ See the [developer guide](http://aiida-quantum-transport.readthedocs.io/en/lates
## License

MIT

## Contact

[email protected]


[ci-badge]: https://github.com/edan-bainglass/aiida-quantum-transport/workflows/ci/badge.svg?branch=master
[ci-link]: https://github.com/edan-bainglass/aiida-quantum-transport/actions
[cov-badge]: https://coveralls.io/repos/github/edan-bainglass/aiida-quantum-transport/badge.svg?branch=master
Expand Down
Loading

0 comments on commit 7466b79

Please sign in to comment.