Skip to content
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

Update Workflows #317

Merged
merged 38 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
31671c2
downgrade mac-os to 13
pauladkisson Apr 29, 2024
9a0afd2
downgrade to macos-12
pauladkisson Apr 29, 2024
edb9e85
removed setup-conda
pauladkisson Apr 29, 2024
d229fc6
added macos-13 to update testing data
pauladkisson Apr 29, 2024
d4a8330
removed conda
pauladkisson Apr 29, 2024
0886d36
added 3.12
pauladkisson Apr 29, 2024
031d80c
added quotes to version numbers
pauladkisson Apr 29, 2024
7b422a3
Merge branch 'main' into workflow
pauladkisson Apr 29, 2024
c135135
added macos-latest
pauladkisson Apr 29, 2024
c644eba
removed macos-latest
pauladkisson Apr 29, 2024
de710b1
added dev testing
pauladkisson Apr 30, 2024
6c7250a
unpin xdist
pauladkisson Apr 30, 2024
8429225
condense tests into 1 line for better output
pauladkisson Apr 30, 2024
c46a6cb
downgrade python setup for wheel support
pauladkisson Apr 30, 2024
9cf698c
added macos-latest with scanimage skips
pauladkisson Apr 30, 2024
7c9e8a2
continue on collection errors
pauladkisson Apr 30, 2024
1c01b40
added platform check for scanimage import
pauladkisson Apr 30, 2024
0fdc21d
added platform check for scanimage import
pauladkisson Apr 30, 2024
ef308b1
switched to try-except
pauladkisson Apr 30, 2024
06fb8c0
fixed ignores
pauladkisson Apr 30, 2024
fa3280a
fixed ignores
pauladkisson Apr 30, 2024
041cde7
updated dev install
pauladkisson Apr 30, 2024
ba6050f
fixed ignores
pauladkisson Apr 30, 2024
69e86fe
added formatting
pauladkisson Apr 30, 2024
062c043
added macos-latest to update-testing-data
pauladkisson Apr 30, 2024
4c35b05
switched back to if-else import
pauladkisson Apr 30, 2024
4f44179
updated changelog
pauladkisson Apr 30, 2024
c95957d
try pytestmark
CodyCBakerPhD May 1, 2024
2821f04
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 1, 2024
f90d4bf
remove CI split
CodyCBakerPhD May 1, 2024
e40d6c4
add reason
CodyCBakerPhD May 1, 2024
ef563ad
merge
pauladkisson May 1, 2024
ed5452a
moved skips to inside pytest files so that they get skipped when runn…
pauladkisson May 1, 2024
56e9f34
updated codecov to v4
pauladkisson May 1, 2024
a7c6327
lowercase darwin
pauladkisson May 1, 2024
d229674
captialized Darwin
pauladkisson May 1, 2024
2602fe8
add skips to test_io
pauladkisson May 1, 2024
f4d0e68
added concurrency to testing workflows
pauladkisson May 1, 2024
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
57 changes: 57 additions & 0 deletions .github/workflows/dev-testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Dev Testing
on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
run:
name: Ubuntu tests with Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow --tags
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Global Setup
run: |
pip install -U pip
pip install pytest-xdist
git config --global user.email "[email protected]"
git config --global user.name "CI Almighty"
pip install wheel==0.41.2 # needed for scanimage

- name: Install full requirements
run: |
pip install .[test]
pip install .[full]

- name: Clone and Install NeuroConv
run: |
git clone https://github.com/catalystneuro/neuroconv.git
cd neuroconv
pip install --no-cache-dir .[full,test]
cd ../
- name: Get ophys_testing_data current head hash
id: ophys
run: echo "::set-output name=HASH_OPHYS_DATASET::$(git ls-remote https://gin.g-node.org/CatalystNeuro/ophys_testing_data.git HEAD | cut -f1)"
- name: Cache ophys dataset - ${{ steps.ophys.outputs.HASH_OPHYS_DATASET }}
uses: actions/cache@v2
id: cache-ophys-datasets
with:
path: ./ophys_testing_data
key: ophys-datasets-042023-ubuntu-latest-${{ steps.ophys.outputs.HASH_OPHYS_DATASET }}

- name: Run NeuroConv tests
run: |
pytest -n auto --dist loadscope neuroconv/tests/test_ophys neuroconv/tests/test_on_data/test_imaging_interfaces.py neuroconv/tests/test_on_data/test_segmentation_interfaces.py
11 changes: 7 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
workflows: [update-testing-data]
types: [completed]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
on-failure:
name: Notify on failure
Expand Down Expand Up @@ -37,10 +41,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, "3.10", 3.11]
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-latest, macos-13] # macos-13 is the latest version of macOS with Intel chip
steps:
- uses: s-weigand/setup-conda@v1
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow --tags
- name: Setup Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -79,7 +82,7 @@ jobs:
run: pytest -n auto --dist loadscope --cov=./ --cov-report xml:./codecov.xml
- if: ${{ matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'}}
name: Upload full coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./codecov.xml
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Features

* Updated testing workflows to include python 3.12, m1/intel macos, and dev tests to check neuroconv: [PR #317](https://github.com/catalystneuro/roiextractors/pull/317)

### Fixes

* Remove unecessary scipy import error handling [#315]((https://github.com/catalystneuro/roiextractors/pull/315)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@

from .setup_paths import OPHYS_DATA_PATH, OUTPUT_PATH

import platform

# Remove this check once scanimage tiff reader is available on ARM -- see https://gitlab.com/vidriotech/scanimagetiffreader-python/-/issues/31
is_m_series_mac = platform.system() == "Darwin" and platform.machine() == "arm64"


def custom_name_func(testcase_func, param_num, param):
return (
Expand Down Expand Up @@ -68,6 +73,9 @@ class TestExtractors(TestCase):

@parameterized.expand(imaging_extractor_list, name_func=custom_name_func)
def test_imaging_extractors(self, extractor_class, extractor_kwargs):
if extractor_class == ScanImageTiffImagingExtractor and is_m_series_mac:
return

extractor = extractor_class(**extractor_kwargs)
check_imaging_return_types(extractor)

Expand All @@ -88,6 +96,9 @@ def test_imaging_extractors(self, extractor_class, extractor_kwargs):
@parameterized.expand(imaging_extractor_list, name_func=custom_name_func)
def test_imaging_extractors_canonical_shape(self, extractor_class, extractor_kwargs):
"""Test that get_video and get_frame methods for their shapes and types under different indexing scenarios"""
if extractor_class == ScanImageTiffImagingExtractor and is_m_series_mac:
return

extractor = extractor_class(**extractor_kwargs)
image_size = extractor.get_image_size()
num_channels = extractor.get_num_channels()
Expand Down
14 changes: 11 additions & 3 deletions tests/test_scan_image_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@
from pathlib import Path
from tempfile import mkdtemp
from shutil import rmtree, copy

from hdmf.testing import TestCase
from numpy.testing import assert_array_equal
from ScanImageTiffReader import ScanImageTiffReader
import pytest

from roiextractors import TiffImagingExtractor, ScanImageTiffImagingExtractor

from roiextractors.extractors.tiffimagingextractors.scanimagetiff_utils import _get_scanimage_reader
from .setup_paths import OPHYS_DATA_PATH

import platform

is_m_series_mac = platform.system() == "Darwin" and platform.machine() == "arm64"
if (
is_m_series_mac
): # Remove this check once scanimage tiff reader is available on ARM -- see https://gitlab.com/vidriotech/scanimagetiffreader-python/-/issues/31
pytest.skip("ScanImageTiffReader does not support M-series Macs", allow_module_level=True)


class TestScanImageTiffExtractor(TestCase):
@classmethod
def setUpClass(cls):
cls.file_path = OPHYS_DATA_PATH / "imaging_datasets" / "Tif" / "sample_scanimage.tiff"
cls.tmpdir = Path(mkdtemp())
cls.imaging_extractor = ScanImageTiffImagingExtractor(file_path=cls.file_path, sampling_frequency=30.0)
ScanImageTiffReader = _get_scanimage_reader()
with ScanImageTiffReader(filename=str(cls.imaging_extractor.file_path)) as io:
cls.data = io.data()

Expand Down
8 changes: 8 additions & 0 deletions tests/test_scanimage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@

from .setup_paths import OPHYS_DATA_PATH

import platform

is_m_series_mac = platform.system() == "Darwin" and platform.machine() == "arm64"
if (
is_m_series_mac
): # Remove this check once scanimage tiff reader is available on ARM -- see https://gitlab.com/vidriotech/scanimagetiffreader-python/-/issues/31
pytest.skip("ScanImageTiffReader does not support M-series Macs", allow_module_level=True)


def test_get_scanimage_reader():
ScanImageTiffReader = _get_scanimage_reader()
Expand Down
27 changes: 24 additions & 3 deletions tests/test_scanimagetiffimagingextractor.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import pytest
from numpy.testing import assert_array_equal
from ScanImageTiffReader import ScanImageTiffReader

from roiextractors import (
ScanImageTiffSinglePlaneImagingExtractor,
ScanImageTiffMultiPlaneImagingExtractor,
ScanImageTiffSinglePlaneMultiFileImagingExtractor,
ScanImageTiffMultiPlaneMultiFileImagingExtractor,
)
from roiextractors.extractors.tiffimagingextractors.scanimagetiff_utils import extract_extra_metadata, parse_metadata

from roiextractors.extractors.tiffimagingextractors.scanimagetiff_utils import (
extract_extra_metadata,
parse_metadata,
_get_scanimage_reader,
)
from .setup_paths import OPHYS_DATA_PATH

import platform

is_m_series_mac = platform.system() == "Darwin" and platform.machine() == "arm64"
if (
is_m_series_mac
): # Remove this check once scanimage tiff reader is available on ARM -- see https://gitlab.com/vidriotech/scanimagetiffreader-python/-/issues/31
pytest.skip("ScanImageTiffReader does not support M-series Macs", allow_module_level=True)


@pytest.fixture(scope="module")
def file_path():
Expand Down Expand Up @@ -91,6 +102,8 @@ def test_ScanImageTiffSinglePlaneImagingExtractor__init__parsed_metadata_not_pro

@pytest.mark.parametrize("frame_idxs", (0, [0, 1, 2], [0, 2, 5]))
def test_get_frames(scan_image_tiff_single_plane_imaging_extractor, frame_idxs, expected_properties):
ScanImageTiffReader = _get_scanimage_reader()

frames = scan_image_tiff_single_plane_imaging_extractor.get_frames(frame_idxs=frame_idxs)
file_path = str(scan_image_tiff_single_plane_imaging_extractor.file_path)
plane = scan_image_tiff_single_plane_imaging_extractor.plane
Expand All @@ -100,6 +113,7 @@ def test_get_frames(scan_image_tiff_single_plane_imaging_extractor, frame_idxs,
frames_per_slice = expected_properties["frames_per_slice"]
if isinstance(frame_idxs, int):
frame_idxs = [frame_idxs]

raw_idxs = []
for idx in frame_idxs:
cycle = idx // frames_per_slice
Expand All @@ -111,6 +125,7 @@ def test_get_frames(scan_image_tiff_single_plane_imaging_extractor, frame_idxs,
+ channel
)
raw_idxs.append(raw_idx)

with ScanImageTiffReader(file_path) as io:
assert_array_equal(frames, io.data()[raw_idxs])

Expand All @@ -123,6 +138,8 @@ def test_get_frames_invalid(scan_image_tiff_single_plane_imaging_extractor, fram

@pytest.mark.parametrize("frame_idx", (1, 3, 5))
def test_get_single_frame(scan_image_tiff_single_plane_imaging_extractor, expected_properties, frame_idx):
ScanImageTiffReader = _get_scanimage_reader()

frame = scan_image_tiff_single_plane_imaging_extractor._get_single_frame(frame=frame_idx)
file_path = str(scan_image_tiff_single_plane_imaging_extractor.file_path)
plane = scan_image_tiff_single_plane_imaging_extractor.plane
Expand Down Expand Up @@ -155,6 +172,8 @@ def test_get_video(
start_frame,
end_frame,
):
ScanImageTiffReader = _get_scanimage_reader()

video = scan_image_tiff_single_plane_imaging_extractor.get_video(start_frame=start_frame, end_frame=end_frame)
if start_frame is None:
start_frame = 0
Expand All @@ -166,6 +185,7 @@ def test_get_video(
num_planes = expected_properties["num_planes"]
num_channels = expected_properties["num_channels"]
frames_per_slice = expected_properties["frames_per_slice"]

raw_idxs = []
for idx in range(start_frame, end_frame):
cycle = idx // frames_per_slice
Expand All @@ -177,6 +197,7 @@ def test_get_video(
+ channel
)
raw_idxs.append(raw_idx)

with ScanImageTiffReader(file_path) as io:
assert_array_equal(video, io.data()[raw_idxs])

Expand Down
Loading