Skip to content

Commit

Permalink
Devops: adopt PEP 621 and move build spec to pyproject.toml
Browse files Browse the repository at this point in the history
Following PEP 621 it is now possible to fully define the build procedure
of your package in `pyproject.toml`. Since this PEP is now well
supported, and for example `pip` can use it, we migrate to it since it
provides a bunch of benefits:

 * No longer need the deprecated `setup.py` to install the package.
 * Version number is now dynamically fetched from the package.
 * The `MANIFEST.in` is no longer necessary. The `flit` build tool will
   automatically include anything. The `pyproject.toml` has a tool
   section for `flit` that excludes the `tests` and `docs` folders.
 * Move configuration of pre-commit tools to `pyproject.toml`.
  • Loading branch information
sphuber committed Apr 8, 2022
1 parent c500b99 commit d293943
Show file tree
Hide file tree
Showing 11 changed files with 184 additions and 172 deletions.
54 changes: 30 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: pre-commit/action@v2.0.0
- 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 -e .[pre-commit]

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

tests:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ['3.7', '3.8', '3.9']

services:
rabbitmq:
Expand All @@ -28,25 +34,25 @@ jobs:
- 5672:5672

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- 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 -e .[tests]
- name: Install python dependencies
run: pip install -e .[tests]

- name: Run pytest
run: pytest -sv --cov=plumpy test
- name: Run pytest
run: pytest -sv --cov=plumpy test

- name: Create xml coverage
run: coverage xml
- name: Create xml coverage
run: coverage xml

- name: Upload coverage to Codecov
if: github.repository == 'aiidateam/plumpy'
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
name: plumpy
- name: Upload coverage to Codecov
if: github.repository == 'aiidateam/plumpy'
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
name: plumpy
92 changes: 36 additions & 56 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,41 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/mgedmin/check-manifest
rev: "0.44"
hooks:
- id: check-manifest
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.32.0
hooks:
- id: yapf
name: yapf
types: [python]
args: ['-i']
additional_dependencies: ['toml']

- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.30.0
hooks:
- id: yapf
name: yapf
types: [python]
args: ["-i"]

- repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.2
hooks:
- id: pylint
additional_dependencies: [
"pyyaml~=5.4", "nest_asyncio~=1.4.0", "aio-pika~=6.6",
"aiocontextvars~=0.2.2; python_version<'3.7'", "kiwipy[rmq]~=0.7.4"
]
args:
[
"--max-line-length=120",
"--disable=import-outside-toplevel",
"--disable=missing-docstring",
"--disable=bad-continuation",
"--disable=global-statement",
"--disable=too-few-public-methods",
"--disable=inconsistent-return-statements",
"--disable=locally-disabled",
"--disable=too-many-ancestors",
"--disable=too-many-arguments",
"--disable=too-many-instance-attributes",
]
exclude: >
(?x)^(
docs/source/conf.py|
test/.*|
)$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
hooks:
- id: mypy
args: [--config-file=tox.ini]
additional_dependencies: ['aio_pika~=6.6']
files: >
(?x)^(
plumpy/.*py|
)$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
hooks:
- id: mypy
args: [--config-file=tox.ini]
additional_dependencies: ["aio_pika~=6.6"]
files: >
(?x)^(
plumpy/.*py|
)$
- repo: https://github.com/PyCQA/pylint
rev: v2.12.2
hooks:
- id: pylint
language: system
exclude: >
(?x)^(
docs/source/conf.py|
test/.*|
)$
7 changes: 0 additions & 7 deletions .style.yapf

This file was deleted.

21 changes: 0 additions & 21 deletions MANIFEST.in

This file was deleted.

7 changes: 4 additions & 3 deletions plumpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# pylint: disable=undefined-variable
# type: ignore
# type: ignore[name-defined]
__version__ = '0.20.0'

import logging

from .loaders import *
Expand All @@ -16,12 +18,11 @@
from .process_listener import *
from .mixins import *
from .utils import *
from .version import *
from .workchains import *

__all__ = (
events.__all__ + exceptions.__all__ + processes.__all__ + utils.__all__ + futures.__all__ + mixins.__all__ +
persistence.__all__ + communications.__all__ + process_comms.__all__ + version.__all__ + process_listener.__all__ +
persistence.__all__ + communications.__all__ + process_comms.__all__ + process_listener.__all__ +
workchains.__all__ + loaders.__all__ + ports.__all__ + process_states.__all__
)

Expand Down
4 changes: 2 additions & 2 deletions plumpy/ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def absorb(
if isinstance(port, PortNamespace):

# If the name does not appear at the start of any of the include rules we continue:
if include and not any([rule.startswith(port_name) for rule in include]):
if include and not any(rule.startswith(port_name) for rule in include):
continue

# Determine the sub exclude and include rules for this specific namespace
Expand Down Expand Up @@ -613,8 +613,8 @@ def validate( # pylint: disable=arguments-differ
:param port_values: an arbitrarily nested dictionary of parsed port values
:param breadcrumbs: a tuple of the path to having reached this point in validation
:return: None or tuple containing 0: error string 1: tuple of breadcrumb strings to where the validation failed
"""
# pylint: disable=arguments-renamed
breadcrumbs_local = (*breadcrumbs, self.name)
message: Optional[str]

Expand Down
2 changes: 1 addition & 1 deletion plumpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
_LOGGER = logging.getLogger(__name__)

SAVED_STATE_TYPE = MutableMapping[str, Any] # pylint: disable=invalid-name
PID_TYPE = Hashable
PID_TYPE = Hashable # pylint: disable=invalid-name


class EventHelper:
Expand Down
4 changes: 0 additions & 4 deletions plumpy/version.py

This file was deleted.

111 changes: 111 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
[build-system]
requires = ['flit_core >=3.4,<4']
build-backend = 'flit_core.buildapi'

[project]
name = 'plumpy'
dynamic = ['version']
description = 'A Python workflow library.'
authors = [
{name = 'Martin Uhrin', email = 'martin.uhrin@gmail.com'},
{name = 'Sebastiaan Huber'},
{name = 'Jason Yu'},
{name = 'Leopold Talirz'},
{name = 'Dominik Gresch'},
]
readme = 'README.md'
license = {file = 'LICENSE'}
classifiers = [
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
]
keywords = ['workflow', 'multithreaded', 'rabbitmq']
requires-python = '>=3.7'
dependencies = [
'aio-pika~=6.6',
'kiwipy[rmq]~=0.7.4',
'nest_asyncio~=1.5',
'pyyaml~=5.4',
]

[project.urls]
Home = 'https://github.com/aiidateam/plumpy'
Source = 'https://github.com/aiidateam/plumpy'
Documentation = 'https://plumpy.readthedocs.io'

[project.optional-dependencies]
docs = [
'ipython~=7.0',
'jinja2==2.11.3',
'markupsafe==2.0.1',
'myst-nb~=0.11.0',
'sphinx~=3.2.0',
'sphinx-book-theme~=0.0.39',
]
pre-commit = [
'mypy==0.790',
'pre-commit~=2.2',
'pylint==2.12.2',
]
tests = [
'ipykernel==6.12.1',
'pytest==6.2.5',
'pytest-asyncio==0.16.0',
'pytest-cov==3.0.0',
'pytest-notebook==0.7.0',
'shortuuid==1.0.8',
]

[tool.flit.module]
name = 'plumpy'

[tool.flit.sdist]
exclude = [
'docs/',
'examples/',
'test/',
]

[tool.pylint.format]
max-line-length = 120

[tool.pylint.messages_control]
disable = [
'bad-continuation',
'consider-using-f-string',
'duplicate-code',
'global-statement',
'import-outside-toplevel',
'inconsistent-return-statements',
'locally-disabled',
'missing-docstring',
'protected-access',
'raise-missing-from',
'too-few-public-methods',
'too-many-ancestors',
'too-many-arguments',
'too-many-instance-attributes',
]

[tool.pytest.ini_options]
minversion = '6.0'
testpaths = [
'test',
]
filterwarnings = [
'ignore::DeprecationWarning:frozendict:',
]

[tool.yapf]
align_closing_bracket_with_visual_indent = true
based_on_style = 'google'
coalesce_brackets = true
column_limit = 120
dedent_closing_brackets = true
indent_dictionary_value = false
split_arguments_when_comma_terminated = true
Loading

0 comments on commit d293943

Please sign in to comment.