Skip to content

Commit

Permalink
Full move to poetry, isort and added Codecov (#68)
Browse files Browse the repository at this point in the history
* With poetry, no setup.py anymore

* GH action with poetry instead of requirements

* Fixed for poetry

* Using only poetry

* Trying to get poetry to work

* Try poetry via pip

* Split actions in jobs

* Using poetry action

* Using isort

* Using isort

* Fixed missing script for pip

* Updated

* Revert to install poetry via pip, not action

* Added Codecov

* Run coverage only once

* Testing if logic

* Fixed Python 3.6 for Codecov

* Fixed if

* Fixed if syntax

* Test syntax

* Test strategy.matrix

* Typos

* steps.matrix

* Back to last working state

* Removed requirements.txt
  • Loading branch information
alanwilter authored Dec 25, 2021
1 parent e11e894 commit d8598ae
Show file tree
Hide file tree
Showing 25 changed files with 195 additions and 188 deletions.
36 changes: 24 additions & 12 deletions .github/workflows/check_acpype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
branches:
- master
jobs:
build:
check-test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -23,6 +23,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# - name: Python Poetry Action
# uses: abatilo/[email protected]

- name: Cache pip
uses: actions/cache@v2
with:
Expand All @@ -49,26 +52,35 @@ jobs:
run: |
sudo apt-get install --no-install-recommends -y openbabel
- name: Install Pip
- name: Poetry install dependencies
run: |
sudo apt-get install --no-install-recommends -y python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade openbabel-wheel
if [ -f requirements.txt ]; then python3 -m pip install -r requirements.txt; fi
# chmod +x acpype/acpype.py
# ln -s $PWD/run_acpype.py /usr/local/bin/acpype
pip3 install poetry
poetry add openbabel-wheel
poetry install
- name: Lint with flake8
run: flake8 -v --count
run: poetry run flake8 -v --count

- name: Check format with black
run: black --diff --check .
run: poetry run black --diff --check .

- name: Run isort
run: poetry run isort . --check-only --profile black

- name: Test with PyTest
run: |
# acpype -di test/AAA.pdb -c gas
pytest --color=yes
poetry run pytest --color=yes --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
if: matrix.python-version == 3.6
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true

release:
needs: check-test
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y.%-m.%-d')"
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ repos:
language: system
types: [python]
require_serial: true
- id: isort
name: isort
entry: poetry run isort .
language: system
types: [python]
require_serial: true
- id: ver_today
name: ver_today
entry: ./scripts/ver_today.sh
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/alanwilter/acpype/check_acpype?style=plastic)](https://github.com/alanwilter/acpype)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=plastic)](https://github.com/pre-commit/pre-commit)
[![Commits since release](https://img.shields.io/github/commits-since/alanwilter/acpype/2021.12.24/master?style=plastic)](https://github.com/alanwilter/acpype/commits/master)
![Codecov](https://img.shields.io/codecov/c/github/alanwilter/acpype?style=plastic)
![Codecov branch](https://img.shields.io/codecov/c/github/alanwilter/acpype/mv2poetry?style=plastic&token=a719f1fe-3a60-49a3-8804-9a44998c9e4a)
<!-- [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5601736.svg)](https://doi.org/10.1186/1756-0500-5-367)
![DOI](https://doi.org/10.1186/1756-0500-5-367) -->
<!-- ![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/alanwilter/acpype) -->
Expand Down
2 changes: 1 addition & 1 deletion acpype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# from https://packaging.python.org/guides/single-sourcing-package-version/
# using option 2
# updated automatically via pre-commit git-hook
__version__ = "2021.12.24"
__version__ = "2021.12.25"
11 changes: 6 additions & 5 deletions acpype/acs_api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import sys
import io
import json
import os
import shutil
import sys
import time
import io
import traceback
import json
from acpype.topol import ACTopol, header
from acpype.utils import while_replace, elapsedTime

from acpype.params import MAXTIME
from acpype.topol import ACTopol, header
from acpype.utils import elapsedTime, while_replace

em_mdp = io.StringIO()
AC_frcmod = io.StringIO()
Expand Down
14 changes: 8 additions & 6 deletions acpype/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@
alanwilter _at_ gmail _dot_ com
"""

import traceback
import time
import os
import sys
import time
import traceback
from shutil import rmtree
from acpype.topol import MolTopol, ACTopol, header
from acpype.parser_args import get_option_parser
from acpype.utils import while_replace, elapsedTime, set_for_pip

from acpype.logger import copy_log
from acpype.logger import set_logging_conf as logger
from acpype.params import binaries
from acpype.logger import copy_log, set_logging_conf as logger
from acpype.parser_args import get_option_parser
from acpype.topol import ACTopol, MolTopol, header
from acpype.utils import elapsedTime, set_for_pip, while_replace


def chk_py_ver():
Expand Down
4 changes: 2 additions & 2 deletions acpype/logger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
from shutil import move
import sys
import logging
from shutil import move
from tempfile import NamedTemporaryFile

tmpLogFile = NamedTemporaryFile().name
Expand Down
3 changes: 2 additions & 1 deletion acpype/parser_args.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
from acpype.params import usage, epilog, MAXTIME, outTopols

from acpype.params import MAXTIME, epilog, outTopols, usage


def get_option_parser():
Expand Down
48 changes: 38 additions & 10 deletions acpype/topol.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,49 @@
import re
import signal
import abc
import array
import math
import os
import pickle
import re
import signal
import subprocess as sub
import abc
import array
from datetime import datetime
from shutil import copy2, rmtree, which
from acpype.mol import Atom, Angle, AtomType, Bond, Dihedral

from acpype import __version__ as version
from acpype.params import minDist, minDist2, maxDist, maxDist2, MAXTIME, TLEAP_TEMPLATE, leapAmberFile, radPi, cal
from acpype.params import binaries, ionOrSolResNameList, outTopols, qDict, qConv, diffTol, specialGaffAtoms
from acpype.params import dictAtomTypeAmb2OplsGmxCode, dictAtomTypeGaff2OplsGmxCode, oplsCode2AtomTypeDict
from acpype.utils import _getoutput, while_replace, distanceAA, job_pids_family, checkOpenBabelVersion
from acpype.utils import find_bin, elapsedTime, imprDihAngle, parmMerge
from acpype.logger import set_logging_conf as logger
from acpype.mol import Angle, Atom, AtomType, Bond, Dihedral
from acpype.params import (
MAXTIME,
TLEAP_TEMPLATE,
binaries,
cal,
dictAtomTypeAmb2OplsGmxCode,
dictAtomTypeGaff2OplsGmxCode,
diffTol,
ionOrSolResNameList,
leapAmberFile,
maxDist,
maxDist2,
minDist,
minDist2,
oplsCode2AtomTypeDict,
outTopols,
qConv,
qDict,
radPi,
specialGaffAtoms,
)
from acpype.utils import (
_getoutput,
checkOpenBabelVersion,
distanceAA,
elapsedTime,
find_bin,
imprDihAngle,
job_pids_family,
parmMerge,
while_replace,
)

year = datetime.today().year
tag = version
Expand Down
13 changes: 9 additions & 4 deletions acpype/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
import sys
import math
import os
import subprocess as sub
import sys
from shutil import which

from acpype.params import Pi


Expand All @@ -12,9 +13,10 @@ def find_bin(abin):

def checkOpenBabelVersion():
"check openbabel version"
import openbabel as obl
import warnings

import openbabel as obl

warnings.filterwarnings("ignore")
return int(obl.OBReleaseVersion().replace(".", ""))

Expand Down Expand Up @@ -248,7 +250,10 @@ def job_pids_family(jpid):


def _getoutput(cmd):
"""to simulate commands.getoutput in order to work with python 2.6 up to 3.x"""
"""
To simulate commands.getoutput
shell=True is necessary despite security issues
"""
out = sub.Popen(cmd, shell=True, stderr=sub.STDOUT, stdout=sub.PIPE).communicate()[0][:-1]
return out.decode()

Expand Down
19 changes: 10 additions & 9 deletions legacy/CcpnToAcpype.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from __future__ import print_function
from builtins import range
from builtins import object
from shutil import rmtree
from acpype.cli import elapsedTime, header, ACTopol
import time
import traceback
import sys

import os
import string
import random
import string
import sys
import time
import traceback
from builtins import object, range
from shutil import rmtree

from ccpnmr.format.converters import PdbFormat # type: ignore
from ccpnmr.format.converters import Mol2Format # type: ignore
from ccpnmr.format.converters import PdbFormat # type: ignore

from acpype.cli import ACTopol, elapsedTime, header

letters = string.ascii_letters

Expand Down
Loading

0 comments on commit d8598ae

Please sign in to comment.