Skip to content

Commit

Permalink
👌 Update package (#38)
Browse files Browse the repository at this point in the history
* 👌 Update package

Updated according to aiidateam/aiida-plugin-cutter#88

* Update pyproject.toml
  • Loading branch information
chrisjsewell authored Jan 18, 2022
1 parent 96bd3a5 commit 4e0ee79
Show file tree
Hide file tree
Showing 29 changed files with 393 additions and 545 deletions.
36 changes: 0 additions & 36 deletions .ci/check_version.py

This file was deleted.

6 changes: 0 additions & 6 deletions .ci/install_aiida_github.sh

This file was deleted.

2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

37 changes: 0 additions & 37 deletions .github/check_version.py

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python-version: [3.8]
python-version: ["3.8"]
backend: ['django']

services:
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
# show timings of tests
PYTEST_ADDOPTS: "--durations=0"
run: py.test --cov aiida_diff --cov-append .
run: pytest --cov aiida_diff --cov-append .

docs:
runs-on: ubuntu-latest
Expand All @@ -60,7 +60,7 @@ jobs:
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: "3.8"
- name: Install python dependencies
run: |
pip install --upgrade pip
Expand All @@ -77,7 +77,7 @@ jobs:
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: "3.8"
- name: Install python dependencies
run: |
pip install --upgrade pip
Expand Down
25 changes: 9 additions & 16 deletions .github/workflows/publish-on-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,16 @@ jobs:
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: '3.8'

- name: Upgrade setuptools and install package
- name: Install flit
run: |
python -m pip install --upgrade pip setuptools
python -m pip install -e .
python -m pip install --upgrade pip
python -m pip install flit~=3.4
- name: Assert package version
- name: Build and publish
run: |
flit publish
env:
TAG_VERSION: ${{ github.ref }}
run: python ./.github/check_version.py

- name: Build source distribution
run: python ./setup.py sdist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token }}
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.pypi_token }}
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@
# pre-commit install
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.1.0
hooks:
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-json

# yapf = yet another python formatter
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.30.0
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: yapf
name: yapf
args: ["-i"]
- id: pyupgrade
args: ["--py37-plus"]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black

- repo: local
hooks:
Expand All @@ -31,9 +37,3 @@ repos:
docs/.*|
)$
entry: pylint

- id: version-number
name: Check version numbers
entry: python ./.github/check_version.py
language: system
files: '^(setup.json)|(aiida_diff/__init__.py)'
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2

python:
version: 3.8
version: "3.8"
install:
- method: pip
path: .
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 The AiiDA Team.
Copyright (c) 2022 The AiiDA Team.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://github.com/aiidateam/aiida-diff/workflows/ci/badge.svg?branch=master)](https://github.com/aiidateam/aiida-diff/actions)
[![Coverage Status](https://coveralls.io/repos/github/aiidateam/aiida-diff/badge.svg?branch=master)](https://coveralls.io/github/aiidateam/aiida-diff?branch=master)
[![Docs status](https://readthedocs.org/projects/aiida-diff/badge)](http://aiida-diff.readthedocs.io/)
[![PyPI version](https://badge.fury.io/py/aiida-diff.svg)](https://badge.fury.io/py/aiida-diff)
[![Build Status][ci-badge]][ci-link]
[![Coverage Status][cov-badge]][cov-link]
[![Docs status][docs-badge]][docs-link]
[![PyPI version][pypi-badge]][pypi-link]

# aiida-diff

Expand All @@ -25,22 +25,16 @@ intended to help developers get started with their AiiDA plugins.
* [`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`.
* [`.coveragerc`](.coveragerc): Configuration of [coverage.py](https://coverage.readthedocs.io/en/latest) tool reporting which lines of your plugin are covered by tests
* [`.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
* [`MANIFEST.in`](MANIFEST.in): Configure non-Python files to be included for publication on [PyPI](https://pypi.org/)
* [`README.md`](README.md): This file
* [`conftest.py`](conftest.py): Configuration of fixtures for [pytest](https://docs.pytest.org/en/latest/)
* [`pytest.ini`](pytest.ini): Configuration of [pytest](https://docs.pytest.org/en/latest/) test discovery
* [`setup.json`](setup.json): Plugin metadata for registration on [PyPI](https://pypi.org/) and the [AiiDA plugin registry](https://aiidateam.github.io/aiida-registry/) (including entry points)
* [`setup.py`](setup.py): Installation script for pip / [PyPI](https://pypi.org/)

* [`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:

* [aiida-diff setup.json](https://www.youtube.com/watch?v=2CxiuiA1uVs&t=240s)
* [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)
Expand Down Expand Up @@ -109,6 +103,7 @@ verdi data diff export <PK>
```shell
git clone https://github.com/aiidateam/aiida-diff .
cd aiida-diff
pip install --upgrade pip
pip install -e .[pre-commit,testing] # install extra dependencies
pre-commit install # install pre-commit hooks
pytest -v # discover and run all tests
Expand All @@ -119,3 +114,13 @@ See the [developer guide](http://aiida-diff.readthedocs.io/en/latest/developer_g
## License

MIT


[ci-badge]: https://github.com/aiidateam/aiida-diff/workflows/ci/badge.svg?branch=master
[ci-link]: https://github.com/aiidateam/aiida-diff/actions
[cov-badge]: https://coveralls.io/repos/github/aiidateam/aiida-diff/badge.svg?branch=master
[cov-link]: https://coveralls.io/github/aiidateam/aiida-diff?branch=master
[docs-badge]: https://readthedocs.org/projects/aiida-diff/badge
[docs-link]: http://aiida-diff.readthedocs.io/
[pypi-badge]: https://badge.fury.io/py/aiida-diff.svg
[pypi-link]: https://badge.fury.io/py/aiida-diff
3 changes: 1 addition & 2 deletions aiida_diff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
"""
aiida_diff
AiiDA demo plugin that wraps the `diff` executable for computing the difference between two files.
"""

__version__ = '1.2.0'
__version__ = "1.2.0"
60 changes: 42 additions & 18 deletions aiida_diff/calculations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Calculations provided by aiida_diff.
Expand All @@ -9,7 +8,7 @@
from aiida.orm import SinglefileData
from aiida.plugins import DataFactory

DiffParameters = DataFactory('diff')
DiffParameters = DataFactory("diff")


class DiffCalculation(CalcJob):
Expand All @@ -18,28 +17,45 @@ class DiffCalculation(CalcJob):
Simple AiiDA plugin wrapper for 'diffing' two files.
"""

@classmethod
def define(cls, spec):
"""Define inputs and outputs of the calculation."""
# yapf: disable
super().define(spec)

# set default values for AiiDA options
spec.inputs['metadata']['options']['resources'].default = {
'num_machines': 1,
'num_mpiprocs_per_machine': 1,
spec.inputs["metadata"]["options"]["resources"].default = {
"num_machines": 1,
"num_mpiprocs_per_machine": 1,
}
spec.inputs['metadata']['options']['parser_name'].default = 'diff'
spec.inputs["metadata"]["options"]["parser_name"].default = "diff"

# new ports
spec.input('metadata.options.output_filename', valid_type=str, default='patch.diff')
spec.input('parameters', valid_type=DiffParameters, help='Command line parameters for diff')
spec.input('file1', valid_type=SinglefileData, help='First file to be compared.')
spec.input('file2', valid_type=SinglefileData, help='Second file to be compared.')
spec.output('diff', valid_type=SinglefileData, help='diff between file1 and file2.')

spec.exit_code(300, 'ERROR_MISSING_OUTPUT_FILES', message='Calculation did not produce all expected output files.')
spec.input(
"metadata.options.output_filename", valid_type=str, default="patch.diff"
)
spec.input(
"parameters",
valid_type=DiffParameters,
help="Command line parameters for diff",
)
spec.input(
"file1", valid_type=SinglefileData, help="First file to be compared."
)
spec.input(
"file2", valid_type=SinglefileData, help="Second file to be compared."
)
spec.output(
"diff",
valid_type=SinglefileData,
help="diff between file1 and file2.",
)

spec.exit_code(
300,
"ERROR_MISSING_OUTPUT_FILES",
message="Calculation did not produce all expected output files.",
)

def prepare_for_submission(self, folder):
"""
Expand All @@ -51,8 +67,8 @@ def prepare_for_submission(self, folder):
"""
codeinfo = datastructures.CodeInfo()
codeinfo.cmdline_params = self.inputs.parameters.cmdline_params(
file1_name=self.inputs.file1.filename,
file2_name=self.inputs.file2.filename)
file1_name=self.inputs.file1.filename, file2_name=self.inputs.file2.filename
)
codeinfo.code_uuid = self.inputs.code.uuid
codeinfo.stdout_name = self.metadata.options.output_filename
codeinfo.withmpi = self.inputs.metadata.options.withmpi
Expand All @@ -61,8 +77,16 @@ def prepare_for_submission(self, folder):
calcinfo = datastructures.CalcInfo()
calcinfo.codes_info = [codeinfo]
calcinfo.local_copy_list = [
(self.inputs.file1.uuid, self.inputs.file1.filename, self.inputs.file1.filename),
(self.inputs.file2.uuid, self.inputs.file2.filename, self.inputs.file2.filename),
(
self.inputs.file1.uuid,
self.inputs.file1.filename,
self.inputs.file1.filename,
),
(
self.inputs.file2.uuid,
self.inputs.file2.filename,
self.inputs.file2.filename,
),
]
calcinfo.retrieve_list = [self.metadata.options.output_filename]

Expand Down
Loading

0 comments on commit 4e0ee79

Please sign in to comment.