Improve jupyter backends#1139
Conversation
The itkwidgets support allows us to use Mayavi in a headless manner unlike the other backends which require offscreen support.
- `mlab.clf()` was not clearing the scene. - `obj.render()` was not working correctly. - The itkwidgets backend would not work correctly in some cases so we explicitly flush the pipeline before calling view.
| if preference_manager.root.show_helper_nodes \ | ||
| and len(self.scenes) == 0: | ||
| if (preference_manager.root.show_helper_nodes and | ||
| len(self.scenes) == 0): |
There was a problem hiding this comment.
it looks like all of the changes in this file are cosmetic - two unused variables and a bunch of style changes.
There was a problem hiding this comment.
Yes, I thought there was an issue there but there wasn't so sent in a separate commit with just PEP8 fixes for that file.
| scene = figure | ||
| disable_render = scene.scene.disable_render | ||
| scene.scene.disable_render = True | ||
| if scene.scene is not None: |
There was a problem hiding this comment.
looks like this is the fix related to the scene not being cleared correctly?
There was a problem hiding this comment.
Yes if you see each commit, the logs will make more sense. This fixes the issue with mlab.clf
| m = actor.mapper | ||
| if m is not None: | ||
| m.update(0) | ||
| m.update() |
There was a problem hiding this comment.
looks like the 0 we were passing before was the arg port - not sure why we don't need to pass it in anymore.
There was a problem hiding this comment.
I am not sure, I think this was when there was issues with the old and new pipeline. The current test failures have nothing to do with this. Those have to do with the import of a UI toolkit when tvtk is imported -- this could be in some other library.
There was a problem hiding this comment.
I need to see how this build is different from the headless test last Saturday.
|
|
||
|
|
||
| def _ipython_display_(self): | ||
| '''Method attached to Mayavi objects. |
There was a problem hiding this comment.
It was not clear from the code that this special method is what IPython looks for. Ref https://ipython.readthedocs.io/en/stable/config/integrating.html#custom-methods. It'd be nice to document this in the function/method
There was a problem hiding this comment.
I will add a comment.
There was a problem hiding this comment.
Done in latest commit.
| def __init__(self, width=None, height=None, local=True): | ||
| super().__init__(width, height, local) | ||
| from mayavi import mlab | ||
| mlab.options.backend = 'test' |
There was a problem hiding this comment.
i'm not sure why we're setting the backend to 'test' here and if this is what we should be shipping.
There was a problem hiding this comment.
The test backend does not instantiate a render window. If you do, you cannot run Mayavi in a headless fashion -- say via a remotely hosted jupyter notebook. The name "test" is not ideal but in the interest of backwards compatibility I am not sure we can or should change it.
Also use traitsui-7.2.1 in build to test if failures are related to this.
|
@corranwebster -- the only major change I am able to see between the headless test here and the one that was run on schedule from 5 days ago (https://github.com/enthought/mayavi/actions/runs/1937040765) is that traitsui was upgraded to 7.3.0 from 7.2.1. Could it be that simply importing |
Unfortunately the |
|
Quick question: did the version of Pyface also change? |
|
@corranwebster -- no the earlier code was also on pyface-7.4.1. |
|
When I try to replicate the failing test in a Python 3.9 virtualenv (not an EDM env) with no backends installed, I see the following line in the verbose output from doing and there are similar lines mentioning So I think that the failure is because some code is likely trying to load wx (and probably Qt) and failing, but things are showing up in the verbose logs that didn't before. The test probably needs to be refined to do something like inspecting |
|
@corranwebster -- so sorry I sent you on a wild goose chase! I will look into writing a better and more robust test if that is possible. Thank you very much! |
|
@corranwebster -- I did some more investigation on this, while the test may not be ideal, it does do its job. It did detect what I think is a regression. If we just do
I sent a simple PR to fix this (enthought/traitsui#1883) and all it requires is delaying the import of |
|
@rahulporuri -- can you please review this so I can merge it sooner rather than later. I can fix any issues related to the traitsui issue in a later PR. |
mlab.clf()was not clearing the scene.obj.render()was not working correctly.