Skip to content

pre-commit, setup and args setup #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

name: Create Release

on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: notlmn/release-with-changelog@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
exclude: '^Meta'
commit-template: '- {title} ← {hash}'
template: |
### Changelog

{commits}

{range}

17 changes: 6 additions & 11 deletions .github/workflows/pythonapp.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Conda/Python pytest
name: Test

on: [push]

Expand All @@ -24,23 +24,18 @@ jobs:
# Pip install requirments
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
pip install -r requirements.dev.txt
- name: Test format
run: |
# Activate
source $(conda info --root)/etc/profile.d/conda.sh
conda activate ./env
# Make sure it is installed
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 *.py --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 *.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
pre-commit run --all-files
- name: Unittest
run: |
# Activate
source $(conda info --root)/etc/profile.d/conda.sh
conda activate ./env
# Make sure pytest is avaliabel
pip install pytest
# Test files
pytest -v test.py
pytest -vv test.py
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# test left-overs
nul
run.out

# dev
*.cprof
.pytest_cache
.vim

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
95 changes: 95 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: ["--unsafe"]
- id: check-added-large-files

- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
name: Removes unused variables
args:
- --in-place
- --remove-all-unused-imports
- --remove-unused-variables
- --expand-star-imports
- --ignore-init-module-imports

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.7.0
hooks:
- id: isort
name: Sorts imports
args: [
# Align isort with black formatting
"--multi-line=3",
"--trailing-comma",
"--force-grid-wrap=0",
"--use-parentheses",
"--line-width=99",
]

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
name: Fixes formatting
language_version: python3
args: ["--line-length=99"]


- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
name: Checks pep8 style
args: [
"--max-line-length=99",
# Ignore imports in init files
"--per-file-ignores=*/__init__.py:F401,setup.py:E121",
# ignore long comments (E501), as long lines are formatted by black
# ignore Whitespace before ':' (E203)
# ignore Line break occurred before a binary operator (W503)
"--ignore=E501,E203,W503",
]

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.790
# hooks:
# - id: mypy
# name: Checks code types
# args: ["--strict"]

# - repo: https://github.com/pycqa/pylint
# rev: pylint-2.6.0
# hooks:
# - id: pylint
# name: Checks code quality
# args:
# - --max-line-length=80
# - --ignore-imports=yes
# - -d duplicate-code

# - repo: local
# hooks:
# - id: jupyisort
# name: Sorts ipynb imports
# entry: jupytext --pipe-fmt ".py" --pipe "isort - --multi-line=3 --trailing-comma --force-grid-wrap=0 --use-parentheses --line-width=99"
# files: .ipynb
# language: python
# - id: jupyblack
# name: Fixes ipynb format
# entry: jupytext --pipe-fmt ".py" --pipe "black - --line-length=99"
# files: .ipynb
# language: python
# - id: nbconvert
# name: Removes ipynb content
# entry: jupyter nbconvert --ClearOutputPreprocessor.enabled=True --ClearMetadataPreprocessor.enabled=True RegexRemovePreprocessor.enabled=True --to=notebook --log-level=ERROR --inplace
# files: .ipynb
# language: python
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ PYTHON=python
CONDA=conda
FLAKE=flake8

.PHONY: build

all: env

setup: env pip
Expand All @@ -22,3 +24,6 @@ test-lint:
@# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
${FLAKE} *.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics


build:
${PYTHON} setup.py sdist bdist_wheel
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,36 @@ Read in xyz file with a charge and print out the SMILES
rdkit # (version 2019.9.1 or later needed for huckel option)
networkx

## Development

Setup development enviroment with

conda create env xyz2mol_dev -f requirements.yml
conda activate xyz2mol_dev
python -m pip install -r requriments.txt
python -m pip install -r requriments.dev.txt

### Testing

Run all tests with pytest

python -m pytest -vv test.py


### Code standard and commit

To keep code standard and ensure quality code, we use `pre-commit`.
Please install `pre-commit` in your local repository

pre-commit install

which will install a hook into your git, and run a format and code-quality check with each commit.

### Releases

To do a release we use GitHub actions on Git Tags.
Increment the release by

git commit . -m "We did some changes" # Do some commits
git tag v1.1.5 # Add this tag to the newest commit
git push origin v1.1.5 # This will trigger the release build
2 changes: 2 additions & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest
pre-commit
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
numpy
scipy
networkx
rmsd
pytest
flake8
10 changes: 10 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from setuptools import setup

setup(
name="xyz2mol",
version="1.0",
description="Convert Cartesian coordinates to one or more molecular graphs",
url="https://github.com/jensengroup/xyz2mol",
py_modules=["xyz2mol"],
entry_points={"console_scripts": ["xyz2mol=xyz2mol:main"]},
)
Loading