Skip to content

Commit

Permalink
Update Workflows (#317)
Browse files Browse the repository at this point in the history
* downgrade mac-os to 13

* downgrade to macos-12

* removed setup-conda

* added macos-13 to update testing data

* removed conda

* added 3.12

* added quotes to version numbers

* added macos-latest

* removed macos-latest

* added dev testing

* unpin xdist

* condense tests into 1 line for better output

* downgrade python setup for wheel support

* added macos-latest with scanimage skips

* continue on collection errors

* added platform check for scanimage import

* added platform check for scanimage import

* switched to try-except

* fixed ignores

* fixed ignores

* updated dev install

* fixed ignores

* added formatting

* added macos-latest to update-testing-data

* switched back to if-else import

* updated changelog
  • Loading branch information
pauladkisson authored May 1, 2024
1 parent 6bddb90 commit d078f60
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 10 deletions.
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

0 comments on commit d078f60

Please sign in to comment.