Skip to content

Commit

Permalink
Merge pull request #223 from AllenInstitute/gouwens-migrate-actions
Browse files Browse the repository at this point in the history
Use GitHub actions for CI and publishing
  • Loading branch information
gouwens authored Apr 29, 2024
2 parents 27372bd + e4f15fe commit e597e25
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 6 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
release-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U twine setuptools wheel
- name: build release distributions
run: |
python setup.py sdist
python setup.py bdist_wheel
- name: upload windows dists
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/

pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
id-token: write

steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
84 changes: 84 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Python Package using Conda

on: [push]

jobs:
build-windows:
runs-on: windows-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
C:\Miniconda\condabin\conda.bat install tqdm openjpeg ruamel.yaml
python -m pip install --upgrade pip
pip install -r test_requirements.txt -U
pip install -r requirements.txt -U
pip install -e .
- name: Test with pytest
run: |
python -m pytest tests/
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
conda install tqdm openjpeg ruamel.yaml
python -m pip install --upgrade pip
pip install -r test_requirements.txt -U
pip install -r requirements.txt -U
pip install -e .
- name: Lint with flake8
run: |
# flake8 already installed via test_requirements.txt
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
python -m pytest tests/
build-mac:
runs-on: macos-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v3
- name: Install dependencies
run: |
conda install tqdm openjpeg ruamel.yaml
brew install hdf5
export HDF5_DIR="$(brew --prefix hdf5)"
python -m pip install --upgrade pip
pip install -r test_requirements.txt -U --disable-pip-version-check
pip install -r requirements.txt -U --disable-pip-version-check
pip install -e . --disable-pip-version-check
- name: Test with pytest
run: |
python -m pytest tests/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Documentation Status](https://readthedocs.org/projects/neuron-morphology/badge/?version=latest)](https://neuron-morphology.readthedocs.io/en/latest/?badge=latest) [![Allen Institute](https://circleci.com/gh/AllenInstitute/neuron_morphology.svg?style=svg)](https://app.circleci.com/pipelines/github/AllenInstitute/neuron_morphology) [![Build status](https://ci.appveyor.com/api/projects/status/7fekclwnq58p61ax?svg=true)](https://ci.appveyor.com/project/fcollman/neuron-morphology)

[![Documentation Status](https://readthedocs.org/projects/neuron-morphology/badge/?version=latest)](https://neuron-morphology.readthedocs.io/en/latest/?badge=latest)
![build workflow](https://github.com/alleninstitute/neuron_morphology/actions/workflows/python-package-conda.yml/badge.svg)

neuron_morphology
=================
Expand Down
2 changes: 1 addition & 1 deletion neuron_morphology/feature_extractor/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RequiresRelativeSomaDepth(Mark):

@classmethod
def validate(cls, data: Data) -> bool:
return data.morphology.has_type(RELATIVE_SOMA_DEPTH)
return data.morphology.has_type(SOMA)

class RequiresSoma(Mark):
"""Indicates that these features require a soma."""
Expand Down
2 changes: 1 addition & 1 deletion neuron_morphology/features/layer/layer_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def ensure_tuple(
raise ValueError("if_none must be a tuple or \"raise\"")

if inputs is None:
if if_none is "raise":
if if_none == "raise":
raise ValueError("inputs were None")
else:
return if_none # type: ignore[]
Expand Down
4 changes: 2 additions & 2 deletions tests/pipeline/test_post_data_to_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import boto3
import zipfile
from moto import mock_s3
from moto import mock_aws
import unittest

from neuron_morphology.pipeline.post_data_to_s3 import post_object_to_s3, zip_files
Expand Down Expand Up @@ -35,7 +35,7 @@ def test_zip_files(self):

self.assertListEqual(self.mock_listing, file_list)

@mock_s3
@mock_aws
def test_post_data_to_s3(tmpdir_factory):

temp_output_dir = str(tmpdir_factory.mktemp("test"))
Expand Down

0 comments on commit e597e25

Please sign in to comment.