Skip to content

Commit

Permalink
Merge pull request #11 from cribbslab/AC-py13
Browse files Browse the repository at this point in the history
updated github actions so py3.10+ tested
  • Loading branch information
Acribbs authored Nov 25, 2024
2 parents ad5ffe0 + 6514c46 commit d8a91c5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 68 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.7", "3.8"]
python-version: ["3.10", "3.11", "3.12"]

defaults:
run:
Expand All @@ -35,20 +35,26 @@ jobs:
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda/environment.yml') }}
- name: Set installer URL
id: set-installer-url
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
echo "installer-url=https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh" >> $GITHUB_ENV
fi
- uses: conda-incubator/setup-miniconda@v2
with:
installer-url: ${{ env.installer-url }}
python-version: ${{ matrix.python-version }}
channels: conda-forge, bioconda, defaults
channel-priority: true
activate-environment: tallytrin
environment-file: conda/environment.yml
miniforge-variant: Mambaforge
- name: Show conda
run: |
conda info
conda list
mamba list
- name: Install tallytrin
run: pip install -e .
- name: Lint with flake8
Expand Down
1 change: 0 additions & 1 deletion __init__.py

This file was deleted.

31 changes: 21 additions & 10 deletions tallytrin/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
tallytrin --help
To get help for a specify workflow, type::
To get help for a specific workflow, type::
tallytrin <workflow> --help
'''
Expand All @@ -21,20 +21,20 @@
import sys
import re
import glob
import imp
import importlib.util
import tallytrin


def printListInColumns(l, ncolumns):
'''output list *l* in *ncolumns*.'''
def print_list_in_columns(l, ncolumns):
'''Output list *l* in *ncolumns*.'''
ll = len(l)

if ll == 0:
return

max_width = max([len(x) for x in l]) + 3
n = ll // ncolumns
if ll % 3 != 0:
if ll % ncolumns != 0:
n += 1

# build columns
Expand All @@ -60,7 +60,6 @@ def main(argv=None):
argv = sys.argv

# paths to look for pipelines:
#print(pipelines.__file__)
path = os.path.abspath(os.path.dirname(tallytrin.__file__))
relpath = os.path.abspath("../src")

Expand All @@ -73,7 +72,7 @@ def main(argv=None):
print((globals()["__doc__"]))
print("The list of available pipelines are:\n")
print("{}\n".format(
printListInColumns(
print_list_in_columns(
sorted([os.path.basename(x)[len("pipeline_"):-len(".py")] for x in pipelines]),
2)))
return
Expand All @@ -85,9 +84,21 @@ def main(argv=None):
# remove 'tallytrin' from sys.argv
del sys.argv[0]

(file, pathname, description) = imp.find_module(pipeline, paths)

module = imp.load_module(pipeline, file, pathname, description)
spec = None
for path in paths:
try:
spec = importlib.util.spec_from_file_location(pipeline, os.path.join(path, f"{pipeline}.py"))
if spec is not None:
break
except FileNotFoundError:
continue

if spec is None or spec.loader is None:
print(f"Error: pipeline '{command}' not found.")
sys.exit(1)

module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

module.main(sys.argv)

Expand Down
80 changes: 26 additions & 54 deletions tests/test_style.py
Original file line number Diff line number Diff line change
@@ -1,78 +1,50 @@
'''test_style
=============
Purpose
-------
Runs pep8 style tests - could be removed if you dont want to
conform to pep8 for this project?
This script is best run within nosetests::
nosetests tests/test_style.py
'''
import pep8
import pycodestyle
import glob
import os
from nose.tools import ok_

# DIRECTORIES to examine
EXPRESSIONS = (
('FirstLevel', 'scpipelines/*.py'),
('SecondLevel', 'scpipelines/version.py'))

# Codes to ignore in the pep8 BaseReport
IGNORE = set(('E101', # indentation contains mixed spaces and tabs
'E201', # whitespace after '('
'E202', # whitespace before ')'
'E122', # continuation line missing indentation or outdented
'E265', # block comment should start with '# '
'E501', # line too long (82 > 79 characters)
'E502', # the backslash is redundant between brackets
'E731', # do not assign a lambda expression, use a def
'W191',
'W291',
'W293',
'W391',
'W503', # line break before binary operator
'W601',
'W602',
'files',
'directories',
'physical lines',
'logical lines',))
# Codes to ignore in the pycodestyle BaseReport
IGNORE = {
'E101', # indentation contains mixed spaces and tabs
'E201', # whitespace after '('
'E202', # whitespace before ')'
'E122', # continuation line missing indentation or outdented
'E265', # block comment should start with '# '
'E501', # line too long (82 > 79 characters)
'E502', # the backslash is redundant between brackets
'E731', # do not assign a lambda expression, use a def
'W191',
'W291',
'W293',
'W391',
'W503', # line break before binary operator
'W601',
'W602'
}


def check_style(filename):
'''check style of filename.
'''
'''check style of filename.'''

p = pep8.StyleGuide(quiet=True)
report = p.check_files([filename])
style_guide = pycodestyle.StyleGuide(quiet=True, ignore=IGNORE)
report = style_guide.check_files([filename])

# count errors/warning excluding
# those to ignore
take = [y for x, y
in list(report.counters.items()) if x not in IGNORE]
found = ['%s:%i' % (x, y) for x, y
in list(report.counters.items()) if x not in IGNORE]
total = sum(take)
ok_(total == 0,
'pep8 style violations: %s' % ','.join(found))
# count errors/warnings excluding those to ignore
assert report.total_errors == 0, f"Style violations in {filename}"


def test_style():
'''test style of scripts
'''
'''test style of scripts'''

for label, expression in EXPRESSIONS:

files = glob.glob(expression)
files.sort()

for f in files:
if os.path.isdir(f):
continue
check_style.description = os.path.abspath(f)
yield(check_style, os.path.abspath(f))
yield check_style, os.path.abspath(f)

0 comments on commit d8a91c5

Please sign in to comment.