Skip to content

Commit

Permalink
Merge pull request #348 from brainglobe/slow-tests
Browse files Browse the repository at this point in the history
Remove the markers to disable specific slowly running tests
  • Loading branch information
alessandrofelder committed May 17, 2024
2 parents 004e84d + c31da8a commit 2e10fab
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 106 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ jobs:
python-version: "3.11"

steps:
- name: Cache atlases
uses: actions/cache@v3
with:
path: ~/.brainglobe
key: brainglobe

- name: Install hdf5 libs for Mac
if: runner.os == 'macOS'
run: brew install hdf5
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ year = {2021}

## Contributing

Contributions to brainrender are more than welcome. Please see the [developers guide](https://brainglobe.info/community/developers/index.html). Note that some tests are only run locally, by specifying `--runslow --runlocal` in `pytest`.
Contributions to brainrender are more than welcome. Please see the [developers guide](https://brainglobe.info/community/developers/index.html).
6 changes: 5 additions & 1 deletion examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from examples import (
add_cells,
add_cylinder,
add_labels,
add_mesh_from_file,
add_cylinder,
animation,
brain_regions,
brainglobe_atlases,
cell_density,
custom_camera,
gene_expression,
line,
neurons,
probe_tracks,
ruler,
screenshot,
settings,
slice,
# streamlines,
user_volumetric_data,
video,
volumetric_data,
web_export,
)
1 change: 0 additions & 1 deletion examples/brainglobe_atlases.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@

# Create a brainrender scene using the zebrafish atlas
scene = Scene(atlas_name="mpin_zfish_1um", title="zebrafish")

# Render!
scene.render()
20 changes: 9 additions & 11 deletions examples/user_volumetric_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,21 @@

print(f"[{orange}]Running example: {Path(__file__).name}")

download_path = Path.home() / ".brainglobe" / "brainrender" / "example-data"
filename = "T_AVG_s356tTg.tif"
scene = Scene(atlas_name="mpin_zfish_1um")

retrieved_paths = pooch.retrieve(
# for some reason the list of returned by pooch does not seem to be
# in the same order every time
_ = pooch.retrieve(
url="https://api.mapzebrain.org/media/Lines/brn3cGFP/average_data/T_AVG_s356tTg.zip",
known_hash="54b59146ba08b4d7eea64456bcd67741db4b5395235290044545263f61453a61",
path=Path.home()
/ ".brainglobe"
/ "brainrender"
/ "example-data", # zip will be downloaded here
path=download_path,
progressbar=True,
processor=pooch.Unzip(
extract_dir=""
# path to unzipped dir,
# *relative* to the path set in 'path'
),
processor=pooch.Unzip(extract_dir="."),
)

datafile = Path(retrieved_paths[0]) # [0] is zip file
datafile = download_path / filename


# 1. load the data
Expand Down
14 changes: 0 additions & 14 deletions tests/conftest.py

This file was deleted.

31 changes: 4 additions & 27 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
import pytest

from brainrender import settings

settings.INTERACTIVE = False


@pytest.mark.slow
@pytest.mark.local
def test_examples():
import examples

examples.add_cells
examples.add_mesh_from_file
examples.animation
examples.brain_regions
examples.brainglobe_atlases
examples.cell_density
examples.custom_camera
examples.gene_expression
examples.neurons
examples.ruler
examples.settings
examples.slice
# examples.streamlines
examples.user_volumetric_data
examples.video
examples.volumetric_data
"""
Run every script in the examples directory
"""
import examples # noqa
24 changes: 11 additions & 13 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,26 +301,24 @@ def test_slice(scene):
assert np.all(ca1_clone.bounds() != ca1.bounds())


@pytest.mark.slow
@pytest.mark.local
def test_user_volumetric_data():
download_path = (
Path.home() / ".brainglobe" / "brainrender" / "example-data"
)
filename = "T_AVG_s356tTg.tif"
scene = Scene(atlas_name="mpin_zfish_1um")
retrieved_paths = pooch.retrieve(

# for some reason the list of returned by pooch does not seem to be
# in the same order every time
_ = pooch.retrieve(
url="https://api.mapzebrain.org/media/Lines/brn3cGFP/average_data/T_AVG_s356tTg.zip",
known_hash="54b59146ba08b4d7eea64456bcd67741db4b5395235290044545263f61453a61",
path=Path.home()
/ ".brainglobe"
/ "brainrender"
/ "example-data", # zip will be downloaded here
path=download_path,
progressbar=True,
processor=pooch.Unzip(
extract_dir=""
# path to unzipped dir,
# *relative* to the path set in 'path'
),
processor=pooch.Unzip(extract_dir="."),
)

datafile = Path(retrieved_paths[0])
datafile = download_path / filename
data = load_any(datafile)
source_space = AnatomicalSpace("ira")
target_space = scene.atlas.space
Expand Down
71 changes: 33 additions & 38 deletions tests/test_streamlines.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
import pandas as pd
import pytest

from brainrender import Scene
from brainrender.actors.streamlines import (
Streamlines,
make_streamlines,
)
from brainrender.atlas_specific import get_streamlines_for_region


@pytest.mark.local
def test_download():
streams = get_streamlines_for_region("TH", force_download=False)
assert len(streams) == 54
assert isinstance(streams[0], pd.DataFrame)


@pytest.mark.local
@pytest.mark.slow
def test_download_slow():
streams = get_streamlines_for_region("TH", force_download=True)
assert len(streams) == 54
assert isinstance(streams[0], pd.DataFrame)


@pytest.mark.local
def test_streamlines():
s = Scene(title="BR")
streams = get_streamlines_for_region("TH", force_download=False)
s.add(Streamlines(streams[0]))
s.add(*make_streamlines(*streams[1:3]))

with pytest.raises(TypeError):
Streamlines([1, 2, 3])

# s.render(interactive=False)
del s
# import pandas as pd
# import pytest
#
# from brainrender import Scene
# from brainrender.actors.streamlines import (
# Streamlines,
# make_streamlines,
# )
# from brainrender.atlas_specific import get_streamlines_for_region
#
#
# def test_download():
# streams = get_streamlines_for_region("TH", force_download=False)
# assert len(streams) == 54
# assert isinstance(streams[0], pd.DataFrame)
#
#
# def test_download_slow():
# streams = get_streamlines_for_region("TH", force_download=True)
# assert len(streams) == 54
# assert isinstance(streams[0], pd.DataFrame)
#
#
# def test_streamlines():
# s = Scene(title="BR")
# streams = get_streamlines_for_region("TH", force_download=False)
# s.add(Streamlines(streams[0]))
# s.add(*make_streamlines(*streams[1:3]))
#
# with pytest.raises(TypeError):
# Streamlines([1, 2, 3])
#
# del s

0 comments on commit 2e10fab

Please sign in to comment.