Skip to content

Commit

Permalink
👌 IMPROVE: Add full typing, type checking and test coverage (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Jan 5, 2021
1 parent 2c0b029 commit 16e7713
Show file tree
Hide file tree
Showing 41 changed files with 1,392 additions and 1,139 deletions.
43 changes: 11 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,6 @@ on: [push, pull_request]

jobs:

docs:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Cache python dependencies
id: cache-pip
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: pip-docs-${{ hashFiles('**/setup.json') }}
restore-keys:
pip-docs-

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install python dependencies
run:
pip install -e .[docs,tests]

- name: Build documentation
env:
READTHEDOCS: 'True'
run:
SPHINXOPTS='-nW' make -C docs html

pre-commit:

runs-on: ubuntu-latest
Expand Down Expand Up @@ -101,4 +70,14 @@ jobs:

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

- 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ target/

# Virtual environment directories
/venv*/

.vscode/
17 changes: 16 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,23 @@ repos:
'--disable=too-many-arguments',
'--disable=too-many-instance-attributes',
]
exclude: &exclude_files >
exclude: >
(?x)^(
docs/source/conf.py|
test/.*|
)$
- repo: local
hooks:
- id: mypy
name: mypy
entry: mypy
args: [--config-file=tox.ini]
language: python
types: [python]
require_serial: true
pass_filenames: true
files: >
(?x)^(
plumpy/.*py|
)$
33 changes: 10 additions & 23 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: []

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.6
install:
- method: pip
path: .
extra_requirements:
- docs
version: 3.8
install:
- method: pip
path: .
extra_requirements:
- docs

sphinx:
builder: html
fail_on_warning: true
17 changes: 17 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
codecov:
notify:
after_n_builds: 2
wait_for_ci: yes
require_ci_to_pass: yes

coverage:
precision: 2 # default, here for transparency
round: up
range: "70...100" # default, here for transparency
status:
project:
default:
threshold: 0.02%
patch:
default:
threshold: 0.1%
7 changes: 3 additions & 4 deletions docs/source/basic/concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A process can be in one of the following states:
* EXCEPTED
* KILLED

as defined in the :class:`ProcessState` enum.
as defined in the :class:`~plumpy.process_states.ProcessState` enum.

::

Expand All @@ -45,9 +45,8 @@ as defined in the :class:`ProcessState` enum.
Workchain
---------

`WorkChain` is `Process`, however, not only the `Process`.

A WorkChain is a series of instructions carried out with the ability to save state in between.
A ``WorkChain`` is a sub-class of `Process`, which additionally defines a ``outline`` in its process specification.
This is a series of instructions carried out with the ability to save state in between.

The `outline` can give a succinct summary of the logical steps that the workchain will perform.
WorkChain supporting using `If_` and `While_` to control the state flow of certain processes.
4 changes: 2 additions & 2 deletions docs/source/basic/introduction.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Introduction
============

Assumuing readers are:
Assuming readers are:

1. Users from aiida-core
2. (?)Users who want to create tools like aiida but on other research field
2. Users who want to create tools like aiida but on other research field
3. Programmers who are searching for the python workflow tools integrated with finite state machine.
13 changes: 7 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.viewcode',
]
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.viewcode', 'sphinx.ext.intersphinx']
# Add any paths that contain templates here, relative to this directory.

# The suffix(es) of source filenames.
Expand Down Expand Up @@ -133,6 +129,11 @@
(master_doc, 'plumpy.tex', 'plumpy Documentation', 'Martin Uhrin', 'manual'),
]

intersphinx_mapping = {
'python': ('https://docs.python.org/3.8', None),
'kiwipy': ('https://kiwipy.readthedocs.io/en/latest/', None)
}


def run_apidoc(_):
"""Runs sphinx-apidoc when building the documentation.
Expand Down Expand Up @@ -219,7 +220,7 @@ def setup(app):

# Warnings to ignore when using the -n (nitpicky) option
# We should ignore any python built-in exception, for instance
nitpick_ignore = [('py:class', 'Warning'), ('py:class', 'exceptions.Warning')]
nitpick_ignore = []

for line in open('nitpick-exceptions'):
if line.strip() == '' or line.startswith('#'):
Expand Down
6 changes: 3 additions & 3 deletions docs/source/gettingStarted/quickStart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Process can wait, pause, play and resume

The example below shows how process state transition with different action:

.. literalinclude:: ../../../examples/process_waitAndResume.py
.. literalinclude:: ../../../examples/process_wait_and_resume.py

Remote controled process
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Remote controlled process
~~~~~~~~~~~~~~~~~~~~~~~~~

process start.

Expand Down
49 changes: 11 additions & 38 deletions docs/source/nitpick-exceptions
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
py:class Exception
py:class ProcessState
py:class persistence.LoadSaveContext
py:class Bundle
py:class Process
py:class PersistedPickle
py:class StateMachine
py:class builtins.dict

py:class kiwipy.Communicator
py:class kiwipy.Future
py:class typing.Any
py:class typing.Callable
py:class typing.Optional
py:class typing.Tuple

py:class dict
py:class str
py:class object
py:class bool
py:class type
py:class tuple
py:class _asyncio.Future
py:class asyncio.unix_events._UnixDefaultEventLoopPolicy
py:class concurrent.futures._base.Error

py:class builtins.dict

py:obj str

py:class logging.Logger
py:class enum.Enum
py:class typing.Optional
py:class typing.Tuple
py:class typing.Any
py:class typing.Callable
py:class ValidationError

py:class plumpy.InterruptException
py:class plumpy.CancellableAction
py:class plumpy.process_states.Command
py:class plumpy.process_states.State
py:class plumpy.LoopCommunicator
py:class plumpy.ports.PortNamespace

py:func save_instance_state
py:func load_instance_state

py:class concurrent.futures._base.Error
# unavailable forward references
py:class plumpy.process_states.Command
py:class plumpy.process_states.State
1 change: 1 addition & 0 deletions plumpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# pylint: disable=undefined-variable
# type: ignore
import logging

from .loaders import *
Expand Down
1 change: 1 addition & 0 deletions plumpy/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# pylint: disable=undefined-variable
# type: ignore
from .state_machine import *
from .utils import *

Expand Down
Loading

0 comments on commit 16e7713

Please sign in to comment.