Skip to content

Commit

Permalink
Merge pull request #42 from dstansby/composite-actions
Browse files Browse the repository at this point in the history
Use brainglobe/actions composite actions for GH actions
  • Loading branch information
dstansby authored Apr 8, 2022
2 parents d363a20 + ddce540 commit 3cca91c
Show file tree
Hide file tree
Showing 49 changed files with 55 additions and 119 deletions.
44 changes: 2 additions & 42 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,7 @@ jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: checkout source
uses: actions/checkout@v2
- name: set up python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- name: cache stuff
uses: actions/cache@v2
with:
path: |
${{ env.pythonLocation }}
~/.cache/pre-commit
key: |
pre-commit-${{ env.PY }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: install dependencies
run: pip install pre-commit
- name: Install pre-commit hooks
run: pre-commit install
# This will run on all files in the repo not just those that have been
# committed. Once formatting has been applied once globally, from then on
# the files being changed by pre-commit should be just those that are
# being committed - provided that people are using the pre-commit hook to
# format their code.
- name: run pre-commit
run: pre-commit run --all-files --color always
- uses: brainglobe/actions/lint@main

test:
needs: linting
Expand All @@ -51,23 +25,9 @@ jobs:
- os: windows-latest
python-version: 3.8
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- uses: brainglobe/actions/test@main
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Test
run: pytest
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install coveralls
coveralls --service=github

deploy-source:
needs: test
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
6 changes: 2 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include cellfinder_core/config/*
include src/cellfinder_core/config/*
global-include *.pxd
prune tests
prune resources
prune .github
global-include *.pyx
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ['setuptools', 'wheel', 'cython']
build-backend = 'setuptools.build_meta'

[tool.black]
target-version = ['py36', 'py37', 'py38']
skip-string-normalization = false
Expand Down
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[options]
package_dir =
=src
packages = find:

[options.packages.find]
where = src

[bumpversion]
current_version = 0.2.8
commit = True
Expand Down
93 changes: 31 additions & 62 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,81 +1,55 @@
import platform
from os import path

from setuptools import Extension, find_packages, setup
import Cython.Build
from setuptools import Extension, setup

this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
long_description = f.read()

requirements = [
"dask[array]",
"fancylog>=0.0.7",
"imlib>=0.0.26",
"natsort",
"numpy",
"scikit-learn",
"configparser",
"pandas",
"packaging",
"scikit-image",
"tifffile",
"natsort",
"tqdm",
"multiprocessing-logging",
"psutil",
"configobj",
"scikit-learn",
"tensorflow>=2.5.0; "
+ "platform_system!='Darwin' or "
+ "platform_machine!='arm64'",
"tensorflow-macos>=2.5.0; "
+ "platform_system=='Darwin' and "
+ "platform_machine=='arm64'",
"fancylog>=0.0.7",
"imlib>=0.0.26",
"slurmio>=0.0.4",
"imio",
"dask[array]",
"tifffile",
"tqdm",
]


if platform.system() == "Windows":
# FIXME: There must be a better way of doing this.
base_tile_filter_extension = Extension(
name="cellfinder_core.detect.filters.plane.base_tile_filter",
sources=["cellfinder_core/detect/filters/plane/base_tile_filter.pyx"],
language="c++",
)

ball_filter_extension = Extension(
name="cellfinder_core.detect.filters.volume.ball_filter",
sources=["cellfinder_core/detect/filters/volume/ball_filter.pyx"],
)
base_tile_filter_extension = Extension(
name="cellfinder_core.detect.filters.plane.base_tile_filter",
sources=["src/cellfinder_core/detect/filters/plane/base_tile_filter.pyx"],
language="c++",
)

structure_detection_extension = Extension(
name="cellfinder_core.detect.filters.volume.structure_detection",
sources=[
"cellfinder_core/detect/filters/volume/structure_detection.pyx"
],
language="c++",
)
else:
base_tile_filter_extension = Extension(
name="cellfinder_core.detect.filters.plane.base_tile_filter",
sources=["cellfinder_core/detect/filters/plane/base_tile_filter.pyx"],
libraries=["m"],
language="c++",
)
ball_filter_extension = Extension(
name="cellfinder_core.detect.filters.volume.ball_filter",
sources=["src/cellfinder_core/detect/filters/volume/ball_filter.pyx"],
)

ball_filter_extension = Extension(
name="cellfinder_core.detect.filters.volume.ball_filter",
sources=["cellfinder_core/detect/filters/volume/ball_filter.pyx"],
libraries=["m"],
)
structure_detection_extension = Extension(
name="cellfinder_core.detect.filters.volume.structure_detection",
sources=[
"src/cellfinder_core/detect/filters/volume/structure_detection.pyx"
],
language="c++",
)

structure_detection_extension = Extension(
name="cellfinder_core.detect.filters.volume.structure_detection",
sources=[
"cellfinder_core/detect/filters/volume/structure_detection.pyx"
],
libraries=["m"],
language="c++",
)
extensions = [
base_tile_filter_extension,
ball_filter_extension,
structure_detection_extension,
]


setup(
Expand All @@ -99,13 +73,8 @@
},
setup_requires=["cython"],
python_requires=">=3.7",
packages=find_packages(),
include_package_data=True,
ext_modules=[
ball_filter_extension,
structure_detection_extension,
base_tile_filter_extension,
],
ext_modules=Cython.Build.cythonize(extensions),
entry_points={
"console_scripts": [
"cellfinder_download = cellfinder_core.download.cli:main",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from scipy.ndimage.filters import gaussian_filter, laplace
from scipy.ndimage import gaussian_filter, laplace
from scipy.signal import medfilt2d


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, img, soma_diameter):
n_tiles_width = math.ceil(self.img_width / self.tile_width)
n_tiles_height = math.ceil(self.img_height / self.tile_height)
self.good_tiles_mask = np.zeros(
(n_tiles_width, n_tiles_height), dtype=np.bool
(n_tiles_width, n_tiles_height), dtype=bool
)

self.x = 0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def make_sphere(ball_shape, radius, position):


def four_connected_kernel():
return np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]], dtype=np.bool)
return np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]], dtype=bool)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 4 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# For more information about tox, see https://tox.readthedocs.io/en/latest/
[tox]
envlist = py{37,38}-{linux,windows}
envlist = py{37,38,39}
isolated_build = true

[gh-actions]
python =
3.7: py37
3.8: py38

[gh-actions:env]
PLATFORM =
ubuntu-latest: linux
windows-latest: windows
3.9: py39

[testenv]
commands = pytest -v --cov=./ --cov-report=xml
commands = python -m pytest -v --color=yes --cov --cov-report=xml
deps =
pytest-cov # https://pytest-cov.readthedocs.io/en/latest/
pytest # https://docs.pytest.org/en/latest/contents.html

0 comments on commit 3cca91c

Please sign in to comment.