From 4e0ee7912f884528269a8ed93c1df2ef1064c53a Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 18 Jan 2022 11:51:55 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Update=20package=20(#38)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 👌 Update package Updated according to https://github.com/aiidateam/aiida-plugin-cutter/pull/88 * Update pyproject.toml --- .ci/check_version.py | 36 ---- .ci/install_aiida_github.sh | 6 - .coveragerc | 2 - .github/check_version.py | 37 ---- .github/workflows/ci.yml | 8 +- .github/workflows/publish-on-pypi.yml | 25 +-- .pre-commit-config.yaml | 30 +-- .readthedocs.yml | 2 +- LICENSE | 2 +- MANIFEST.in | 2 - README.md | 27 +-- aiida_diff/__init__.py | 3 +- aiida_diff/calculations.py | 60 ++++-- aiida_diff/cli.py | 32 ++-- aiida_diff/data/__init__.py | 19 +- aiida_diff/helpers.py | 32 ++-- aiida_diff/parsers.py | 23 +-- conftest.py | 14 +- docs/Makefile | 2 +- docs/source/conf.py | 260 +++++++------------------- docs/source/developer_guide/index.rst | 24 ++- docs/source/index.rst | 5 +- examples/example_01.py | 40 ++-- pyproject.toml | 108 +++++++++++ setup.json | 59 ------ setup.py | 19 -- tests/__init__.py | 1 - tests/test_calculations.py | 40 ++-- tests/test_cli.py | 20 +- 29 files changed, 393 insertions(+), 545 deletions(-) delete mode 100644 .ci/check_version.py delete mode 100755 .ci/install_aiida_github.sh delete mode 100644 .coveragerc delete mode 100644 .github/check_version.py delete mode 100644 MANIFEST.in delete mode 100644 setup.json delete mode 100755 setup.py diff --git a/.ci/check_version.py b/.ci/check_version.py deleted file mode 100644 index 843261e..0000000 --- a/.ci/check_version.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Check that version numbers match. - -Check version number in setup.json and aiida_diff/__init__.py and make sure -they match. -""" -from __future__ import absolute_import -from __future__ import print_function -import os -import json -import sys - -this_path = os.path.split(os.path.realpath(__file__))[0] - -# Get content of setup.json -setup_fname = 'setup.json' -setup_path = os.path.join(this_path, os.pardir, setup_fname) -with open(setup_path) as f: - setup_content = json.load(f) - -# Get version from python package -sys.path.insert(0, os.path.join(this_path, os.pardir)) -import aiida_diff # pylint: disable=wrong-import-position -version = aiida_diff.__version__ - -if version != setup_content['version']: - print("Version number mismatch detected:") - print("Version number in '{}': {}".format(setup_fname, - setup_content['version'])) - print("Version number in '{}/__init__.py': {}".format( - 'aiida_diff', version)) - sys.exit(1) - -# Overwrite version in setup.json -#setup_content['version'] = version -#with open(setup_path, 'w') as f: -# json.dump(setup_content, f, indent=4, sort_keys=True) diff --git a/.ci/install_aiida_github.sh b/.ci/install_aiida_github.sh deleted file mode 100755 index dc56b09..0000000 --- a/.ci/install_aiida_github.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -git clone https://github.com/aiidateam/aiida_core ../aiida_core -cd ../aiida_core -git checkout $AIIDA_DEVELOP_GIT_HASH -pip install -e .[docs,pre-commit,testing] -cd ${TRAVIS_BUILD_DIR} diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index f4aebfc..0000000 --- a/.coveragerc +++ /dev/null @@ -1,2 +0,0 @@ -[run] -source=aiida_diff diff --git a/.github/check_version.py b/.github/check_version.py deleted file mode 100644 index e62d084..0000000 --- a/.github/check_version.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -"""Check that version numbers match. - -Check version number in setup.json and aiida_diff/__init__.py and make sure -they match. -""" -from __future__ import absolute_import -from __future__ import print_function -import os -import json -import sys - -this_path = os.path.split(os.path.realpath(__file__))[0] - -# Get content of setup.json -SETUP_FNAME = 'setup.json' -SETUP_PATH = os.path.join(this_path, os.pardir, SETUP_FNAME) -with open(SETUP_PATH) as f: - setup_content = json.load(f) - -# Get version from python package -sys.path.insert(0, os.path.join(this_path, os.pardir)) -import aiida_diff # pylint: disable=wrong-import-position -VERSION = aiida_diff.__version__ - -if VERSION != setup_content['version']: - print('Version number mismatch detected:') - print("Version number in '{}': {}".format(SETUP_FNAME, - setup_content['version'])) - print("Version number in '{}/__init__.py': {}".format( - 'aiida_diff', VERSION)) - sys.exit(1) - -# Overwrite version in setup.json -#setup_content['version'] = version -#with open(SETUP_PATH, 'w') as f: -# json.dump(setup_content, f, indent=4, sort_keys=True) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bcc698..db513f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - python-version: [3.8] + python-version: ["3.8"] backend: ['django'] services: @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/publish-on-pypi.yml b/.github/workflows/publish-on-pypi.yml index 705bcbf..bed33ce 100644 --- a/.github/workflows/publish-on-pypi.yml +++ b/.github/workflows/publish-on-pypi.yml @@ -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 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2233a15..1dade24 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -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)' diff --git a/.readthedocs.yml b/.readthedocs.yml index cefd41b..9515c3f 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,7 +1,7 @@ version: 2 python: - version: 3.8 + version: "3.8" install: - method: pip path: . diff --git a/LICENSE b/LICENSE index 9c8f7c4..5eea571 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 2862132..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include setup.json -include LICENSE diff --git a/README.md b/README.md index 70ff2a0..51dbfb8 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) @@ -109,6 +103,7 @@ verdi data diff export ```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 @@ -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 diff --git a/aiida_diff/__init__.py b/aiida_diff/__init__.py index 90e77bd..02ee885 100644 --- a/aiida_diff/__init__.py +++ b/aiida_diff/__init__.py @@ -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" diff --git a/aiida_diff/calculations.py b/aiida_diff/calculations.py index 64ca01c..192cebb 100644 --- a/aiida_diff/calculations.py +++ b/aiida_diff/calculations.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Calculations provided by aiida_diff. @@ -9,7 +8,7 @@ from aiida.orm import SinglefileData from aiida.plugins import DataFactory -DiffParameters = DataFactory('diff') +DiffParameters = DataFactory("diff") class DiffCalculation(CalcJob): @@ -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): """ @@ -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 @@ -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] diff --git a/aiida_diff/cli.py b/aiida_diff/cli.py index f2d784a..114ab39 100644 --- a/aiida_diff/cli.py +++ b/aiida_diff/cli.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Command line interface (cli) for aiida_diff. @@ -6,54 +5,57 @@ directly into the 'verdi' command by using AiiDA-specific entry points like "aiida.cmdline.data" (both in the setup.json file). """ - import sys + import click -from aiida.cmdline.utils import decorators + from aiida.cmdline.commands.cmd_data import verdi_data from aiida.cmdline.params.types import DataParamType +from aiida.cmdline.utils import decorators from aiida.orm import QueryBuilder from aiida.plugins import DataFactory # See aiida.cmdline.data entry point in setup.json -@verdi_data.group('diff') +@verdi_data.group("diff") def data_cli(): """Command line interface for aiida-diff""" -@data_cli.command('list') +@data_cli.command("list") @decorators.with_dbenv() def list_(): # pylint: disable=redefined-builtin """ Display all DiffParameters nodes """ - DiffParameters = DataFactory('diff') + DiffParameters = DataFactory("diff") qb = QueryBuilder() qb.append(DiffParameters) results = qb.all() - s = '' + s = "" for result in results: obj = result[0] - s += '{}, pk: {}\n'.format(str(obj), obj.pk) + s += f"{str(obj)}, pk: {obj.pk}\n" sys.stdout.write(s) -@data_cli.command('export') -@click.argument('node', metavar='IDENTIFIER', type=DataParamType()) -@click.option('--outfile', - '-o', - type=click.Path(dir_okay=False), - help='Write output to file (default: print to stdout).') +@data_cli.command("export") +@click.argument("node", metavar="IDENTIFIER", type=DataParamType()) +@click.option( + "--outfile", + "-o", + type=click.Path(dir_okay=False), + help="Write output to file (default: print to stdout).", +) @decorators.with_dbenv() def export(node, outfile): """Export a DiffParameters node (identified by PK, UUID or label) to plain text.""" string = str(node) if outfile: - with open(outfile, 'w') as f: + with open(outfile, "w") as f: f.write(string) else: click.echo(string) diff --git a/aiida_diff/data/__init__.py b/aiida_diff/data/__init__.py index 137013f..622f186 100644 --- a/aiida_diff/data/__init__.py +++ b/aiida_diff/data/__init__.py @@ -1,22 +1,21 @@ -# -*- coding: utf-8 -*- """ Data types provided by plugin Register data types via the "aiida.data" entry point in setup.json. """ - # You can directly use or subclass aiida.orm.data.Data # or any other data type listed under 'verdi data' -from voluptuous import Schema, Optional +from voluptuous import Optional, Schema + from aiida.orm import Dict # A subset of diff's command line options cmdline_options = { - Optional('ignore-case'): bool, - Optional('ignore-file-name-case'): bool, - Optional('ignore-tab-expansion'): bool, - Optional('ignore-space-change'): bool, - Optional('ignore-all-space'): bool, + Optional("ignore-case"): bool, + Optional("ignore-file-name-case"): bool, + Optional("ignore-tab-expansion"): bool, + Optional("ignore-space-change"): bool, + Optional("ignore-all-space"): bool, } @@ -74,7 +73,7 @@ def cmdline_params(self, file1_name, file2_name): pm_dict = self.get_dict() for k in pm_dict.keys(): if pm_dict[k]: - parameters += ['--' + k] + parameters += ["--" + k] parameters += [file1_name, file2_name] @@ -90,5 +89,5 @@ def __str__(self): """ string = super().__str__() - string += '\n' + str(self.get_dict()) + string += "\n" + str(self.get_dict()) return string diff --git a/aiida_diff/helpers.py b/aiida_diff/helpers.py index 153fc1d..d950526 100644 --- a/aiida_diff/helpers.py +++ b/aiida_diff/helpers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Helper functions for automatically setting up computer & code. Helper functions for setting up @@ -8,20 +7,21 @@ Note: Point 2 is made possible by the fact that the ``diff`` executable is available in the PATH on almost any UNIX system. """ -import tempfile import shutil -from aiida.orm import Computer, Code +import tempfile + from aiida.common.exceptions import NotExistent +from aiida.orm import Code, Computer -LOCALHOST_NAME = 'localhost-test' +LOCALHOST_NAME = "localhost-test" executables = { - 'diff': 'diff', + "diff": "diff", } def get_path_to_executable(executable): - """ Get path to local executable. + """Get path to local executable. :param executable: Name of executable in the $PATH variable :type executable: str :return: path to executable @@ -29,8 +29,7 @@ def get_path_to_executable(executable): """ path = shutil.which(executable) if path is None: - raise ValueError( - "'{}' executable not found in PATH.".format(executable)) + raise ValueError(f"'{executable}' executable not found in PATH.") return path @@ -54,13 +53,14 @@ def get_computer(name=LOCALHOST_NAME, workdir=None): computer = Computer( label=name, - description='localhost computer set up by aiida_diff tests', + description="localhost computer set up by aiida_diff tests", hostname=name, workdir=workdir, - transport_type='local', - scheduler_type='direct') + transport_type="local", + scheduler_type="direct", + ) computer.store() - computer.set_minimum_job_poll_interval(0.) + computer.set_minimum_job_poll_interval(0.0) computer.configure() return computer @@ -81,9 +81,13 @@ def get_code(entry_point, computer): except KeyError as exc: raise KeyError( "Entry point '{}' not recognized. Allowed values: {}".format( - entry_point, list(executables.keys()))) from exc + entry_point, list(executables.keys()) + ) + ) from exc - codes = Code.objects.find(filters={'label': executable}) # pylint: disable=no-member + codes = Code.objects.find( # pylint: disable=no-member + filters={"label": executable} + ) if codes: return codes[0] diff --git a/aiida_diff/parsers.py b/aiida_diff/parsers.py index 10d1598..049eca7 100644 --- a/aiida_diff/parsers.py +++ b/aiida_diff/parsers.py @@ -1,22 +1,22 @@ -# -*- coding: utf-8 -*- """ Parsers provided by aiida_diff. Register parsers via the "aiida.parsers" entry point in setup.json. """ +from aiida.common import exceptions from aiida.engine import ExitCode +from aiida.orm import SinglefileData from aiida.parsers.parser import Parser from aiida.plugins import CalculationFactory -from aiida.common import exceptions -from aiida.orm import SinglefileData -DiffCalculation = CalculationFactory('diff') +DiffCalculation = CalculationFactory("diff") class DiffParser(Parser): """ Parser class for parsing output of calculation. """ + def __init__(self, node): """ Initialize Parser instance @@ -28,7 +28,7 @@ def __init__(self, node): """ super().__init__(node) if not issubclass(node.process_class, DiffCalculation): - raise exceptions.ParsingError('Can only parse DiffCalculation') + raise exceptions.ParsingError("Can only parse DiffCalculation") def parse(self, **kwargs): """ @@ -36,21 +36,22 @@ def parse(self, **kwargs): :returns: an exit code, if parsing fails (or nothing if parsing succeeds) """ - output_filename = self.node.get_option('output_filename') + output_filename = self.node.get_option("output_filename") # Check that folder content is as expected files_retrieved = self.retrieved.list_object_names() files_expected = [output_filename] # Note: set(A) <= set(B) checks whether A is a subset of B if not set(files_expected) <= set(files_retrieved): - self.logger.error("Found files '{}', expected to find '{}'".format( - files_retrieved, files_expected)) + self.logger.error( + f"Found files '{files_retrieved}', expected to find '{files_expected}'" + ) return self.exit_codes.ERROR_MISSING_OUTPUT_FILES # add output file - self.logger.info("Parsing '{}'".format(output_filename)) - with self.retrieved.open(output_filename, 'rb') as handle: + self.logger.info(f"Parsing '{output_filename}'") + with self.retrieved.open(output_filename, "rb") as handle: output_node = SinglefileData(file=handle) - self.out('diff', output_node) + self.out("diff", output_node) return ExitCode(0) diff --git a/conftest.py b/conftest.py index 4771b17..19937db 100644 --- a/conftest.py +++ b/conftest.py @@ -1,17 +1,15 @@ -# -*- coding: utf-8 -*- """pytest fixtures for simplified testing.""" -from __future__ import absolute_import import pytest -pytest_plugins = ['aiida.manage.tests.pytest_fixtures'] +pytest_plugins = ["aiida.manage.tests.pytest_fixtures"] -@pytest.fixture(scope='function', autouse=True) + +@pytest.fixture(scope="function", autouse=True) def clear_database_auto(clear_database): # pylint: disable=unused-argument """Automatically clear database in between tests.""" -@pytest.fixture(scope='function') +@pytest.fixture(scope="function") def diff_code(aiida_local_code_factory): - """Get a diff code. - """ - return aiida_local_code_factory(executable='diff', entry_point='diff') + """Get a diff code.""" + return aiida_local_code_factory(executable="diff", entry_point="diff") diff --git a/docs/Makefile b/docs/Makefile index cf24a3d..9f28c26 100755 --- a/docs/Makefile +++ b/docs/Makefile @@ -24,7 +24,7 @@ I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source ## Runs nit-picky and converting warnings into errors to ## make sure the documentation is properly written customdefault: - $(SPHINXBUILD) -b html -nW $(ALLSPHINXOPTS) $(BUILDDIR)/html + $(SPHINXBUILD) -b html -nW --keep-going $(ALLSPHINXOPTS) $(BUILDDIR)/html all: html diff --git a/docs/source/conf.py b/docs/source/conf.py index d5387a8..f02ecf5 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Sphinx configuration for aiida-diff # @@ -15,71 +14,65 @@ import sys import time -import aiida_diff from aiida.manage.configuration import load_documentation_profile +import aiida_diff + # -- AiiDA-related setup -------------------------------------------------- # Load the dummy profile even if we are running locally, this way the documentation will succeed even if the current # default profile of the AiiDA installation does not use a Django backend. load_documentation_profile() -# If we are not on READTHEDOCS load the Sphinx theme manually -if not os.environ.get('READTHEDOCS', None): - import sphinx_rtd_theme - html_theme = 'sphinx_rtd_theme' - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - # -- General configuration ------------------------------------------------ # 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. -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = '1.5' - # 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.ext.autodoc', - 'sphinx.ext.mathjax', - 'sphinx.ext.intersphinx', - 'sphinx.ext.viewcode', - 'sphinxcontrib.contentui', - 'aiida.sphinxext', + "sphinx.ext.autodoc", + "sphinx.ext.mathjax", + "sphinx.ext.intersphinx", + "sphinx.ext.viewcode", + "sphinxcontrib.contentui", + "aiida.sphinxext", ] intersphinx_mapping = { - 'python': ('https://docs.python.org/3', None), - 'aiida': ('https://aiida-core.readthedocs.io/en/latest', None), + "python": ("https://docs.python.org/3", None), + "aiida": ("https://aiida-core.readthedocs.io/en/latest", None), } # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -#~ master_doc = 'index' -master_doc = 'index' +# ~ master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'aiida-diff' -copyright_first_year = '2020' -copyright_owners = 'The AiiDA Team' +project = "aiida-diff" +copyright_first_year = "2022" +copyright_owners = "The AiiDA Team" current_year = str(time.localtime().tm_year) -copyright_year_string = current_year if current_year == copyright_first_year else '{}-{}'.format( - copyright_first_year, current_year) +copyright_year_string = ( + current_year + if current_year == copyright_first_year + else f"{copyright_first_year}-{current_year}" +) # pylint: disable=redefined-builtin -copyright = u'{}, {}. All rights reserved'.format(copyright_year_string, - copyright_owners) +copyright = f"{copyright_year_string}, {copyright_owners}. All rights reserved" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -88,7 +81,7 @@ # The full version, including alpha/beta/rc tags. release = aiida_diff.__version__ # The short X.Y version. -version = '.'.join(release.split('.')[:2]) +version = ".".join(release.split(".")[:2]) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -99,66 +92,31 @@ # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # exclude_patterns = ['doc.rst'] -#~ exclude_patterns = ['index.rst'] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True +# ~ exclude_patterns = ['index.rst'] # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. show_authors = True # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +pygments_style = "sphinx" # -- 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 = 'basicstrap' -## SET BELOW - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - 'display_version': True, -} +html_theme = "furo" +html_logo = "images/AiiDA_transparent_logo.png" +html_title = f"aiida-diff v{release}" +html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#~ html_theme_path = ["."] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = "images/.png" +# ~ html_theme_path = ["."] # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 @@ -168,112 +126,65 @@ # 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'] +# html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. html_show_sourcelink = False # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#~ html_show_copyright = False +# ~ html_show_copyright = False # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -html_use_opensearch = 'http://aiida-diff.readthedocs.io' +html_use_opensearch = "https://aiida-diff.readthedocs.io" # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -#html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -#html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = 'aiida-diff-doc' - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - #'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - #'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - #'preamble': '', - - # Latex figure (float) alignment - #'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -# latex_documents = [ -# ] +html_search_language = "en" -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True +# Warnings to ignore when using the -n (nitpicky) option +# We should ignore any python built-in exception, for instance +nitpick_ignore = [ + ("py:class", "Logger"), +] def run_apidoc(_): @@ -285,70 +196,37 @@ def run_apidoc(_): See also https://github.com/rtfd/readthedocs.org/issues/1139 """ source_dir = os.path.abspath(os.path.dirname(__file__)) - apidoc_dir = os.path.join(source_dir, 'apidoc') - package_dir = os.path.join(source_dir, os.pardir, os.pardir, 'aiida_diff') + apidoc_dir = os.path.join(source_dir, "apidoc") + package_dir = os.path.join(source_dir, os.pardir, os.pardir, "aiida_diff") # In #1139, they suggest the route below, but this ended up # calling sphinx-build, not sphinx-apidoc - #from sphinx.apidoc import main - #main([None, '-e', '-o', apidoc_dir, package_dir, '--force']) + # from sphinx.apidoc import main + # main([None, '-e', '-o', apidoc_dir, package_dir, '--force']) import subprocess - cmd_path = 'sphinx-apidoc' - if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv + + cmd_path = "sphinx-apidoc" + if hasattr(sys, "real_prefix"): # Check to see if we are in a virtualenv # If we are, assemble the path manually - cmd_path = os.path.abspath( - os.path.join(sys.prefix, 'bin', 'sphinx-apidoc')) + cmd_path = os.path.abspath(os.path.join(sys.prefix, "bin", "sphinx-apidoc")) options = [ - '-o', + "-o", apidoc_dir, package_dir, - '--private', - '--force', - '--no-toc', + "--private", + "--force", + "--no-toc", ] # See https://stackoverflow.com/a/30144019 env = os.environ.copy() - env['SPHINX_APIDOC_OPTIONS'] = 'members,special-members,private-members,undoc-members,show-inheritance' + env[ + "SPHINX_APIDOC_OPTIONS" + ] = "members,special-members,private-members,undoc-members,show-inheritance" subprocess.check_call([cmd_path] + options, env=env) def setup(app): - app.connect('builder-inited', run_apidoc) - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -# man_pages = [ -# ] - -# If true, show URL addresses after external links. -#man_show_urls = False - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -# texinfo_documents = [ -# ] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False - -# Warnings to ignore when using the -n (nitpicky) option -# We should ignore any python built-in exception, for instance -nitpick_ignore = [] + app.connect("builder-inited", run_apidoc) diff --git a/docs/source/developer_guide/index.rst b/docs/source/developer_guide/index.rst index 0799d1d..1af961c 100644 --- a/docs/source/developer_guide/index.rst +++ b/docs/source/developer_guide/index.rst @@ -7,9 +7,15 @@ Running the tests The following will discover and run all unit test:: + pip install --upgrade pip pip install -e .[testing] pytest -v +You can also run the tests in a virtual environment with `tox `_:: + + pip install tox tox-conda + tox -e py38 -- -v + Automatic coding style checks +++++++++++++++++++++++++++++ @@ -18,7 +24,7 @@ Enable enable automatic checks of code sanity and coding style:: pip install -e .[pre-commit] pre-commit install -After this, the `yapf `_ formatter, +After this, the `black `_ formatter, the `pylint `_ linter and the `pylint `_ code analyzer will run at every commit. @@ -27,6 +33,11 @@ If you ever need to skip these pre-commit hooks, just use:: git commit -n +You should also keep the pre-commit hooks up to date periodically, with:: + + pre-commit autoupdate + +Or consider using `pre-commit.ci `_. Continuous integration ++++++++++++++++++++++ @@ -74,11 +85,10 @@ PyPI release ++++++++++++ Your plugin is ready to be uploaded to the `Python Package Index `_. -Just register for an account and:: +Just register for an account and use `flit `_:: - pip install twine - python setup.py sdist bdist_wheel - twine upload dist/* + pip install flit + flit publish After this, you (and everyone else) should be able to:: @@ -87,10 +97,6 @@ After this, you (and everyone else) should be able to:: You can also enable *automatic* deployment of git tags to the python package index: simply generate a `PyPI API token `_ for your PyPI account and add it as a secret to your GitHub repository under the name ``pypi_token`` (Go to Settings -> Secrets). -.. note:: - - When updating the plugin package to a new version, remember to update the version number both in ``setup.json`` and ``aiida_diff/__init__.py``. - .. _ReadTheDocs: https://readthedocs.org/ .. _Sphinx: https://www.sphinx-doc.org/en/master/ diff --git a/docs/source/index.rst b/docs/source/index.rst index 6dd17d5..9cc9822 100755 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,7 +1,3 @@ -.. figure:: images/AiiDA_transparent_logo.png - :width: 250px - :align: center - The aiida-diff plugin for `AiiDA`_ ===================================================== @@ -14,6 +10,7 @@ The aiida-diff plugin for `AiiDA`_ user_guide/index developer_guide/index API documentation + AiiDA Documentation If you use this plugin for your research, please cite the following work: diff --git a/examples/example_01.py b/examples/example_01.py index 335eb91..675e82f 100644 --- a/examples/example_01.py +++ b/examples/example_01.py @@ -1,16 +1,18 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Run a test calculation on localhost. Usage: ./example_01.py """ from os import path + import click + from aiida import cmdline, engine -from aiida.plugins import DataFactory, CalculationFactory +from aiida.plugins import CalculationFactory, DataFactory + from aiida_diff import helpers -INPUT_DIR = path.join(path.dirname(path.realpath(__file__)), 'input_files') +INPUT_DIR = path.join(path.dirname(path.realpath(__file__)), "input_files") def test_run(diff_code): @@ -21,34 +23,34 @@ def test_run(diff_code): if not diff_code: # get code computer = helpers.get_computer() - diff_code = helpers.get_code(entry_point='diff', computer=computer) + diff_code = helpers.get_code(entry_point="diff", computer=computer) # Prepare input parameters - DiffParameters = DataFactory('diff') - parameters = DiffParameters({'ignore-case': True}) + DiffParameters = DataFactory("diff") + parameters = DiffParameters({"ignore-case": True}) - SinglefileData = DataFactory('singlefile') - file1 = SinglefileData(file=path.join(INPUT_DIR, 'file1.txt')) - file2 = SinglefileData(file=path.join(INPUT_DIR, 'file2.txt')) + SinglefileData = DataFactory("singlefile") + file1 = SinglefileData(file=path.join(INPUT_DIR, "file1.txt")) + file2 = SinglefileData(file=path.join(INPUT_DIR, "file2.txt")) # set up calculation inputs = { - 'code': diff_code, - 'parameters': parameters, - 'file1': file1, - 'file2': file2, - 'metadata': { - 'description': 'Test job submission with the aiida_diff plugin', + "code": diff_code, + "parameters": parameters, + "file1": file1, + "file2": file2, + "metadata": { + "description": "Test job submission with the aiida_diff plugin", }, } # Note: in order to submit your calculation to the aiida daemon, do: # from aiida.engine import submit # future = submit(CalculationFactory('diff'), **inputs) - result = engine.run(CalculationFactory('diff'), **inputs) + result = engine.run(CalculationFactory("diff"), **inputs) - computed_diff = result['diff'].get_content() - print('Computed diff between files: \n{}'.format(computed_diff)) + computed_diff = result["diff"].get_content() + print(f"Computed diff between files: \n{computed_diff}") @click.command() @@ -66,5 +68,5 @@ def cli(code): test_run(code) -if __name__ == '__main__': +if __name__ == "__main__": cli() # pylint: disable=no-value-for-parameter diff --git a/pyproject.toml b/pyproject.toml index 9771405..8e69a54 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,70 @@ +[build-system] +# build the package with [flit](https://flit.readthedocs.io) +requires = ["flit_core >=3.4,<4"] +build-backend = "flit_core.buildapi" + +[project] +# See https://www.python.org/dev/peps/pep-0621/ +name = "aiida-diff" +dynamic = ["version"] # read from aiida_diff/__init__.py +description = "AiiDA demo plugin that wraps the `diff` executable for computing the difference between two files." +authors = [{name = "The AiiDA Team"}] +readme = "README.md" +license = {file = "LICENSE"} +classifiers = [ + "Programming Language :: Python", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Development Status :: 3 - Alpha", + "Framework :: AiiDA" +] +keywords = ["aiida", "plugin"] +requires-python = ">=3.7" +dependencies = [ + "aiida-core>=1.1.0,<2.0.0", + "sqlalchemy<1.4", + "psycopg2-binary<2.9", + "voluptuous" +] + +[project.urls] +Source = "https://github.com/aiidateam/aiida-diff" + +[project.optional-dependencies] +testing = [ + "pgtest~=1.3.1", + "wheel~=0.31", + "coverage[toml]", + "pytest~=6.0", + "pytest-cov" +] +pre-commit = [ + "pre-commit~=2.2", + "pylint>=2.5.0,<2.9" +] +docs = [ + "sphinx", + "sphinxcontrib-contentui", + "sphinxcontrib-details-directive", + "furo" +] + +[project.entry-points."aiida.data"] +"diff" = "aiida_diff.data:DiffParameters" + +[project.entry-points."aiida.calculations"] +"diff" = "aiida_diff.calculations:DiffCalculation" + +[project.entry-points."aiida.parsers"] +"diff" = "aiida_diff.parsers:DiffParser" + +[project.entry-points."aiida.cmdline.data"] +"diff" = "aiida_diff.cli:data_cli" + +[tool.flit.module] +name = "aiida_diff" + [tool.pylint.format] max-line-length = 125 @@ -6,9 +73,13 @@ disable = [ "too-many-ancestors", "invalid-name", "duplicate-code", + # black compatibility + "C0330", + "C0326", ] [tool.pytest.ini_options] +# Configuration for [pytest](https://docs.pytest.org) python_files = "test_*.py example_*.py" filterwarnings = [ "ignore::DeprecationWarning:aiida:", @@ -16,3 +87,40 @@ filterwarnings = [ "ignore::DeprecationWarning:django:", "ignore::DeprecationWarning:yaml:", ] + +[tool.coverage.run] +# Configuration of [coverage.py](https://coverage.readthedocs.io) +# reporting which lines of your plugin are covered by tests +source=["aiida_diff"] + +[tool.isort] +# Configuration of [isort](https://isort.readthedocs.io) +line_length = 120 +force_sort_within_sections = true +sections = ['FUTURE', 'STDLIB', 'THIRDPARTY', 'AIIDA', 'FIRSTPARTY', 'LOCALFOLDER'] +known_aiida = ['aiida'] + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py38 + +[testenv] +usedevelop=True + +[testenv:py{37,38,39,310}] +description = Run the test suite against a python version +extras = testing +commands = pytest {posargs} + +[testenv:pre-commit] +description = Run the pre-commit checks +extras = pre-commit +commands = pre-commit run {posargs} + +[testenv:docs] +description = Build the documentation +extras = docs +commands = sphinx-build -nW --keep-going -b html {posargs} docs/source docs/build/html +commands_post = echo "open file://{toxinidir}/docs/build/html/index.html" +""" diff --git a/setup.json b/setup.json deleted file mode 100644 index f77fe36..0000000 --- a/setup.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "aiida-diff", - "author": "The AiiDA Team", - "author_email": "", - "description": "AiiDA demo plugin that wraps the `diff` executable for computing the difference between two files.", - "url": "https://github.com/aiidateam/aiida-diff", - "license": "MIT", - "classifiers": [ - "Programming Language :: Python", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Framework :: AiiDA" - ], - "version": "1.2.0", - "entry_points": { - "aiida.data": [ - "diff = aiida_diff.data:DiffParameters" - ], - "aiida.calculations": [ - "diff = aiida_diff.calculations:DiffCalculation" - ], - "aiida.parsers": [ - "diff = aiida_diff.parsers:DiffParser" - ], - "aiida.cmdline.data": [ - "diff = aiida_diff.cli:data_cli" - ] - }, - "include_package_data": true, - "setup_requires": ["reentry"], - "reentry_register": true, - "install_requires": [ - "aiida-core>=1.1.0,<2.0.0", - "sqlalchemy<1.4", - "six", - "psycopg2-binary<2.9", - "voluptuous" - ], - "extras_require": { - "testing": [ - "pgtest~=1.3.1", - "wheel~=0.31", - "coverage", - "pytest~=6.0", - "pytest-cov" - ], - "pre-commit": [ - "pre-commit~=2.2", - "pylint>=2.5.0,<2.9" - ], - "docs": [ - "sphinx", - "sphinxcontrib-contentui", - "sphinxcontrib-details-directive; python_version>='3.0'", - "sphinx-rtd-theme" - ] - } -} diff --git a/setup.py b/setup.py deleted file mode 100755 index 8142939..0000000 --- a/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -"""Setup script for aiida-diff""" -import json -from setuptools import setup, find_packages - -if __name__ == '__main__': - # Provide static information in setup.json - # such that it can be discovered automatically - with open('setup.json', 'r') as info: - kwargs = json.load(info) - setup( - packages=find_packages(include=['aiida_diff', 'aiida_diff.*']), - # this doesn't work when placed in setup.json (something to do with str type) - package_data={ - '': ['*'], - }, - long_description=open('README.md').read(), - long_description_content_type='text/markdown', - **kwargs) diff --git a/tests/__init__.py b/tests/__init__.py index 424be79..94cbb42 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Tests for the plugin. Includes both tests written in unittest style (test_cli.py) and tests written diff --git a/tests/test_calculations.py b/tests/test_calculations.py index 5519c9d..9d27370 100644 --- a/tests/test_calculations.py +++ b/tests/test_calculations.py @@ -1,11 +1,9 @@ -# -*- coding: utf-8 -*- -""" Tests for calculations - -""" +""" Tests for calculations.""" import os -from aiida.plugins import DataFactory, CalculationFactory + from aiida.engine import run from aiida.orm import SinglefileData +from aiida.plugins import CalculationFactory, DataFactory from . import TEST_DIR @@ -15,29 +13,25 @@ def test_process(diff_code): note this does not test that the expected outputs are created of output parsing""" # Prepare input parameters - DiffParameters = DataFactory('diff') - parameters = DiffParameters({'ignore-case': True}) + DiffParameters = DataFactory("diff") + parameters = DiffParameters({"ignore-case": True}) - file1 = SinglefileData( - file=os.path.join(TEST_DIR, 'input_files', 'file1.txt')) - file2 = SinglefileData( - file=os.path.join(TEST_DIR, 'input_files', 'file2.txt')) + file1 = SinglefileData(file=os.path.join(TEST_DIR, "input_files", "file1.txt")) + file2 = SinglefileData(file=os.path.join(TEST_DIR, "input_files", "file2.txt")) # set up calculation inputs = { - 'code': diff_code, - 'parameters': parameters, - 'file1': file1, - 'file2': file2, - 'metadata': { - 'options': { - 'max_wallclock_seconds': 30 - }, + "code": diff_code, + "parameters": parameters, + "file1": file1, + "file2": file2, + "metadata": { + "options": {"max_wallclock_seconds": 30}, }, } - result = run(CalculationFactory('diff'), **inputs) - computed_diff = result['diff'].get_content() + result = run(CalculationFactory("diff"), **inputs) + computed_diff = result["diff"].get_content() - assert 'content1' in computed_diff - assert 'content2' in computed_diff + assert "content1" in computed_diff + assert "content2" in computed_diff diff --git a/tests/test_cli.py b/tests/test_cli.py index bb3bdbf..704c9e7 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,20 +1,19 @@ -# -*- coding: utf-8 -*- -""" Tests for command line interface. - -""" +""" Tests for command line interface.""" from click.testing import CliRunner + from aiida.plugins import DataFactory -from aiida_diff.cli import list_, export +from aiida_diff.cli import export, list_ # pylint: disable=attribute-defined-outside-init class TestDataCli: """Test verdi data cli plugin.""" + def setup_method(self): """Prepare nodes for cli tests.""" - DiffParameters = DataFactory('diff') - self.parameters = DiffParameters({'ignore-case': True}) + DiffParameters = DataFactory("diff") + self.parameters = DiffParameters({"ignore-case": True}) self.parameters.store() self.runner = CliRunner() @@ -32,6 +31,7 @@ def test_data_diff_export(self): Tests that it can be reached and that it shows the contents of the node we have set up. """ - result = self.runner.invoke(export, [str(self.parameters.pk)], - catch_exceptions=False) - assert 'ignore-case' in result.output + result = self.runner.invoke( + export, [str(self.parameters.pk)], catch_exceptions=False + ) + assert "ignore-case" in result.output