Skip to content

Commit

Permalink
Maint/pre commit (mosdef-hub#417)
Browse files Browse the repository at this point in the history
* Include pre-commit configuration files

Foyer currently lacks an automated way to enforce a style guide and
basic docstring formatting that is easily distributed to other
developers.

An example of this is mBuild, which now uses the `pre-commit` framework
to automate this during pull-requests as well as an installable git
commit hook.
This commit adds the initial configuration files for pre-commit setup.

* Inital pre-commit, formatting, docstyle, blackening, etc.

* Include blurb about pre-commit

* Include note section for networkX graph objects

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix docstring in topology_graph.py

* minor style fix

* more style fix

* add precommit hooks installation instruction

Co-authored-by: Co Quach <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Co Quach <[email protected]>
  • Loading branch information
4 people authored May 19, 2021
1 parent 314cf2c commit 26791e1
Show file tree
Hide file tree
Showing 238 changed files with 18,014 additions and 17,308 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test-output.xml
*.py[cod]
*.ipynb_checkpoints

# C extensions
*.so
Expand Down
2 changes: 1 addition & 1 deletion .landscape.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ ignore-patterns:
- __init__.py
python-targets:
- 2
- 3
- 3
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 21.4b2
hooks:
- id: black
args: [--line-length=80]
- repo: https://github.com/pycqa/isort
rev: 5.8.0
hooks:
- id: isort
name: isort (python)
args: [--profile=black, --line-length=80]
- repo: https://github.com/pycqa/pydocstyle
rev: '6.0.0'
hooks:
- id: pydocstyle
exclude: ^(foyer/tests/|docs/|devtools/|setup.py)
args: [--convention=numpy]
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ conda:
sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: false
fail_on_warning: false
16 changes: 10 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Contributions are welcomed via [pull requests on GitHub](https://github.com/mosdef-hub/foyer/pulls). Developers and/or
Contributions are welcomed via [pull requests on GitHub](https://github.com/mosdef-hub/foyer/pulls). Developers and/or
users will review requested changes and make comments. The rest of this file will serve as a set of general guidelines
for contributors.

Expand All @@ -18,7 +18,7 @@ Please try to keep the `master` branch of your fork up-to-date with the `master`

## Propose a single set of related changes

Small changes are preferred over large changes. A major contribution can often be broken down into smaller PRs. Large PRs that
Small changes are preferred over large changes. A major contribution can often be broken down into smaller PRs. Large PRs that
affect many parts of the codebase can be harder to review and are more likely to cause merge conflicts.

# Source code
Expand All @@ -32,7 +32,11 @@ It is important to have a consistent style throughout the source code. The follo
* Lines do not end with whitespace
* For other details, refer to [PEP8](https://www.python.org/dev/peps/pep-0008)

To help with the above, there are tools such as [flake8](https://pypi.org/project/flake8/) and [Black](https://github.com/ambv/black).
We use [pre-commit](https://pre-commit.com/) to automatically check our code style. Pre-commit is included in the dev environment and its git hooks can be installed using:

```bash
pre-commit install
```

## Document code with comments

Expand All @@ -45,8 +49,8 @@ can have simple one-liner docstrings.

## Write unit tests

All new functionality in Foyer should be tested with automatic unit tests that execute in a few seconds. These tests
should attempt to cover all options that the user can select. All or most of the added lines of source code should be
All new functionality in Foyer should be tested with automatic unit tests that execute in a few seconds. These tests
should attempt to cover all options that the user can select. All or most of the added lines of source code should be
covered by unit test(s). We currently use [pytest](https://docs.pytest.org/en/latest/), which can be executed simply by calling
`pytest` from the root directory of the package. Additions to force field files should include test molecules that encompass
`pytest` from the root directory of the package. Additions to force field files should include test molecules that encompass
the added or modified atom types or functionality.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## Overview
Foyer is an open-source Python tool for defining and applying force field atom-typing
rules in a format that is both human- and machine-readable. It parametrizes chemical topologies,
rules in a format that is both human- and machine-readable. It parametrizes chemical topologies,
generating, syntactically correct input files for various simulation engines. Foyer provides a framework for force field
dissemination, helping to eliminate ambiguity in atom-typing and improving reproducibility
(for more information, see [our paper](https://www.sciencedirect.com/science/article/pii/S0927025619303040) or its corresponding [pre-print](https://arxiv.org/pdf/1812.06779.pdf)).
Expand Down Expand Up @@ -50,10 +50,10 @@ ethane.save('ethane.top')
ethane.save('ethane.gro')
```

The `Foyer` package is part of the [Molecular Simulation Design Framework (MoSDeF) project](http://mosdef.org/).
Libraries in the MoSDeF ecosystem are designed to provide utilities neccessary to streamline
The `Foyer` package is part of the [Molecular Simulation Design Framework (MoSDeF) project](http://mosdef.org/).
Libraries in the MoSDeF ecosystem are designed to provide utilities neccessary to streamline
a researcher's simulation workflow. When setting up simulation studies,
we also recommend users to follow the [TRUE](https://www.tandfonline.com/doi/full/10.1080/00268976.2020.1742938)
we also recommend users to follow the [TRUE](https://www.tandfonline.com/doi/full/10.1080/00268976.2020.1742938)
(Transparent, Reproducible, Usable-by-others, and Extensible) standard, which is a set of common
practices meant to improve the reproducibility of computational simulation research.

Expand Down Expand Up @@ -110,7 +110,7 @@ Example template for disseminating force fields:
* [Installation instructions](docs/installation.rst)

### Citing Foyer:
* If you use this package, please cite [our paper](https://www.sciencedirect.com/science/article/pii/S0927025619303040) published in [Computational Materials Science](https://www.journals.elsevier.com/computational-materials-science).
* If you use this package, please cite [our paper](https://www.sciencedirect.com/science/article/pii/S0927025619303040) published in [Computational Materials Science](https://www.journals.elsevier.com/computational-materials-science).
* This manuscript is also available in its pre-print form on [arxiv](https://arxiv.org/pdf/1812.06779.pdf)
* The paper and examples in this work were developed for tag [paper_COMMAT_2019](https://github.com/mosdef-hub/foyer/tree/paper_COMMAT_2019)

Expand Down
2 changes: 1 addition & 1 deletion devtools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ License
Copyright (c) 2012-2015 Stanford University and the Authors
All rights reserved.

Redistribution and use of all files in this folder (devtools) and (../basesetup.py,
Redistribution and use of all files in this folder (devtools) and (../basesetup.py,
../setup.py) files in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Expand Down
3 changes: 0 additions & 3 deletions devtools/conda-recipe/bld.bat

This file was deleted.

50 changes: 0 additions & 50 deletions devtools/conda-recipe/meta.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ =
SPHINXPROJ =
BUILDDIR = _build

# User-friendly check for sphinx-build
Expand Down
2 changes: 1 addition & 1 deletion docs/_templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
}
</script>
{{ super() }}
{% endblock %}
{% endblock %}
1 change: 0 additions & 1 deletion docs/atom-typing_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ Forcefield

.. autoclass:: foyer.forcefield.Forcefield
:members:

Loading

0 comments on commit 26791e1

Please sign in to comment.