Skip to content

Conversation

@GuillaumeFavelier
Copy link
Contributor

This PR sets time_viewer='auto' and show_traces='auto'. It's still a work in progress.

It's an item of #7162

@GuillaumeFavelier
Copy link
Contributor Author

To achieve time_viewer=auto, the following 3d viz tests need to be ported to the renderer_interactive fixture:

  • test_plot_sparse_source_estimates
  • test_process_clim_plot

@agramfort
Copy link
Member

agramfort commented Mar 4, 2020 via email

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Mar 4, 2020

By default the 3d tests are done with off_screen=True to avoid opening a window but in order to use the PyVista widgets, off_screen should be disabled (they require an interactive window).
The goal of the renderer_interactive fixture is just that.

@codecov
Copy link

codecov bot commented Mar 11, 2020

Codecov Report

Merging #7380 into master will increase coverage by 0.01%.
The diff coverage is 96.29%.

@@            Coverage Diff             @@
##           master    #7380      +/-   ##
==========================================
+ Coverage   90.09%   90.10%   +0.01%     
==========================================
  Files         453      453              
  Lines       82610    82622      +12     
  Branches    13062    13065       +3     
==========================================
+ Hits        74427    74447      +20     
+ Misses       5356     5351       -5     
+ Partials     2827     2824       -3     

@GuillaumeFavelier
Copy link
Contributor Author

The latest commit is marked as test because the renderer_interactive fixture does not include mayavi for now. It needs to be fixed.

@GuillaumeFavelier
Copy link
Contributor Author

The interactive parameter of _testing_context() is unused in the _pysurfer_mayavi 3d backend:

@contextmanager
def _testing_context(interactive):
mlab = _import_mlab()
orig_backend = mlab.options.backend
mlab.options.backend = 'test'
try:
yield
finally:
mlab.options.backend = orig_backend

compared to _pyvista:

@contextmanager
def _testing_context(interactive):
from . import renderer
orig_offscreen = pyvista.OFF_SCREEN
orig_testing = renderer.MNE_3D_BACKEND_TESTING
if interactive:
pyvista.OFF_SCREEN = False
renderer.MNE_3D_BACKEND_TESTING = False
else:
pyvista.OFF_SCREEN = True
try:
yield
finally:
pyvista.OFF_SCREEN = orig_offscreen
renderer.MNE_3D_BACKEND_TESTING = orig_testing

So I think it's totally safe to add it to the list:

mne-python/mne/conftest.py

Lines 238 to 243 in 499f917

@pytest.fixture(scope="module", params=[
"pyvista",
])
def backend_name_interactive(request):
"""Get the backend name."""
yield request.param

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Mar 13, 2020

The tests using renderer_interactive are:

test_brain_timeviewer
test_brain_timeviewer_traces
test_brain_linkviewer
test_plot_sparse_source_estimates
test_process_clim_plot
test_link_brains

Among those, only:

test_plot_sparse_source_estimates
test_process_clim_plot

are supported by mayavi, the rest should expect NotImplementedError or pytest.skip()

@GuillaumeFavelier GuillaumeFavelier marked this pull request as ready for review March 13, 2020 12:22
@GuillaumeFavelier
Copy link
Contributor Author

I forgot to update Circle config yesterday... The issue with pytest-sugar is back

@GuillaumeFavelier
Copy link
Contributor Author

Oh no. It's actually another release of pytest:

image

@GuillaumeFavelier
Copy link
Contributor Author

Can we just do pytest<5.4.0 for now?

@GuillaumeFavelier
Copy link
Contributor Author

I notice a few warnings of the type:

UserWarning: Attempting to set identical left == right == 0 results in singular transformations; automatically expanding.

Also, there is an issue with time_label:

AttributeError: 'TimeSlider' object has no attribute 'time_label'

I'll push a fix.

opacity=0.5, high_resolution=False)
if renderer.get_3d_backend() == 'mayavi':
import mayavi # noqa: F401 analysis:ignore
assert isinstance(surf, mayavi.modules.surface.Surface)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we keep some variant of this? Can you instead change it to renderer_interactive.get_3d_backend()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed that was a bit too agressive, I'll add a branch for mayavi

@GuillaumeFavelier
Copy link
Contributor Author

I'll try [circle full] once #7480 is merged

@larsoner
Copy link
Member

Merged @GuillaumeFavelier

@GuillaumeFavelier
Copy link
Contributor Author

#7480 was not enough apparently since we got a timeout too, I'm trying with show_traces=False and at the same time see if I can improve the memory footprint of _Brain

@GuillaumeFavelier
Copy link
Contributor Author

So far my changes seem to help freeing memory but nothing big for _Brain (master in black, local changes in blue)

image

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Mar 20, 2020

@larsoner , @agramfort the timeout seems related to show_traces='auto' because now CircleCI passes:

https://18788-1301584-gh.circle-artifacts.com/0/dev/index.html

Is it good enough to have only time_viewer='auto'?

@agramfort
Copy link
Member

agramfort commented Mar 20, 2020 via email

@GuillaumeFavelier GuillaumeFavelier changed the title WIP: Set time_viewer and show_traces to auto MRG: Set time_viewer and show_traces to auto Mar 20, 2020
@GuillaumeFavelier
Copy link
Contributor Author

This is ready for reviews then

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larsoner merge if you're happy

@larsoner
Copy link
Member

Is it good enough to have only time_viewer='auto'?

yes ok. It can be improved later after the release.

I'm not so sure because this would be a change in behavior with no deprecation cycle.

A lesser evil would probably be to add a private _MNE_TRACES_AUTO=false env var that we set in CircleCI and detect in _brain to make it so 'auto' means False. This would make the output different from what a user would see when they ran the script with the PyVista backend and more like what it would be like with the Mayavi backend -- but I doubt anyone would really notice.

@GuillaumeFavelier
Copy link
Contributor Author

A lesser evil would probably be to add a private _MNE_TRACES_AUTO=false env var

I guess it's possible indeed, what do you think @agramfort ?

Why private though @larsoner ?

@larsoner
Copy link
Member

larsoner commented Mar 20, 2020

Why private though @larsoner ?

Hopefully eventually we can fix the memory/timeout problem and kill it the environment variable entirely. We don't want it actually to be a permanent solution (or give users yet another way to set things, they should use kwargs)

@GuillaumeFavelier
Copy link
Contributor Author

Hopefully eventually we can fix the memory/timeout problem and kill it entirely

I'll continue to investigate locally

@larsoner
Copy link
Member

Yes please do, but in the meantime the private env var workaround would make it so that we don't have to figure it out before release

@GuillaumeFavelier GuillaumeFavelier changed the title MRG: Set time_viewer and show_traces to auto WIP: Set time_viewer and show_traces to auto Mar 20, 2020
@larsoner
Copy link
Member

Pushed a commit with the CircleCI workaround and setting both show_traces and time_viewer to 'auto' as default, let's see if it gets us around the CI problem

@GuillaumeFavelier
Copy link
Contributor Author

Thank you @larsoner

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1 for merge from my end

@agramfort happy with this?

@agramfort
Copy link
Member

if @drammock and @hoechenberger are happy I am happy. Happy @drammock and @hoechenberger ?

@hoechenberger
Copy link
Member

LGTM!

@drammock drammock merged commit b884155 into mne-tools:master Mar 23, 2020
@GuillaumeFavelier GuillaumeFavelier deleted the time_viewer_auto_parameter branch June 11, 2020 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants