Skip to content

Commit

Permalink
Merge branch 'mega-fix' into compatibility-with-vedo-2023.5.0+dev26a
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTatarnikov committed Nov 16, 2023
2 parents d2f605f + ebde569 commit 0dcdbee
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
if: runner.os == 'macOS'
run: brew install hdf5

# Helps set up VTK with a headless display
- uses: pyvista/setup-headless-display-action@v2

# Run tests
- uses: neuroinformatics-unit/actions/test@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions brainrender/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def export(self, savepath):
"""
logger.debug(f"Exporting scene to {savepath}")
_backend = self.backend
_default_backend = vsettings.default_backend

if not self.is_rendered:
self.render(interactive=False)
Expand All @@ -302,9 +303,8 @@ def export(self, savepath):

# Create new plotter and save to file
plt = Plotter()
plt.add(self.clean_renderables, render=False)
plt.add(self.clean_renderables).render()
plt = plt.show(interactive=False)
plt.camera[-2] = -1

with open(path, "w") as fp:
fp.write(plt.get_snapshot())
Expand All @@ -314,7 +314,7 @@ def export(self, savepath):
)

# Reset settings
vsettings.notebookBackend = None
vsettings.default_backend = _default_backend
self.backend = _backend

return str(path)
Expand Down
18 changes: 12 additions & 6 deletions tests/test_export_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@
from brainrender import Scene


@pytest.mark.local
def test_export_for_web():
@pytest.fixture
def scene():
"""Provide a scene with a brain region"""
s = Scene(title="BR")

th = s.add_brain_region("TH")

s.add_label(th, "TH")
return s

path = s.export("test.html")

def test_export_for_web(scene):
"""Check that exporting to html creates the expected file"""
path = scene.export("test.html")
assert path == "test.html"

path = Path(path)
assert path.exists()

path.unlink()


def test_export_for_web_raises(scene):
"""Check that exporting with invalid file extention raises ValueError"""
with pytest.raises(ValueError):
path = s.export("test.py")
scene.export("test.py")
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ extras =
commands =
pytest -v --color=yes --cov=brainrender --cov-report=xml
passenv =
CI
GITHUB_ACTIONS
DISPLAY
XAUTHORITY
NUMPY_EXPERIMENTAL_ARRAY_FUNCTION
PYVISTA_OFF_SCREEN

0 comments on commit 0dcdbee

Please sign in to comment.