Repository navigation
MRG+1: store GUI config options - #3948
Conversation
This should be a trivial overhead, assume YAGNI until we hit a problem
This shouldn't be the case. |
|
Sorry that was ambiguous, I meant literally |
|
Actually we should fix |
|
Ok, I'll do that in a separate PR |
302dc06 to
8b51459
Compare
| str(info.object.mri_obj.opacity), set_env=False) | ||
| except Exception as error: | ||
| print("Error saving GUI configuration:\n%s" % (error,)) | ||
|
|
There was a problem hiding this comment.
@Eric89GXL it would be straight forward to also modify set_config() to accept a dict as first argument and write multiple entries in one call, should I?
There was a problem hiding this comment.
I'd say not for now. It's easy enough (and rare enough) that we need to do for key, val in update_dict: set_config(key, val)
larsoner
left a comment
There was a problem hiding this comment.
Otherwise LGTM, should be nice when using GUIs
| <http://www.slideshare.net/mne-python/mnepython-scale-mri>`_. | ||
| """ | ||
| config = get_config(home_dir=os.environ.get('_MNE_FAKE_HOME_DIR')) | ||
| prepare_bem = config.get('MNE_COREG_PREPARE_BEM', 'True') == 'True' |
There was a problem hiding this comment.
I think because this goes to JSON we've been using 'true' instead of 'True'
| return frame.edit_traits(), frame | ||
| else: | ||
| frame.configure_traits() | ||
| return frame |
There was a problem hiding this comment.
Refactor repeated code into function?
There was a problem hiding this comment.
It's not quite the same... above we have a view argument
There was a problem hiding this comment.
Yes but is it equivalent to view=None in the case it's not used?
|
|
||
|
|
||
| def _testing_mode(): | ||
| """Helper to determine if we're running tests.""" |
There was a problem hiding this comment.
FYI the suggested standard is to us imperative tone, so """Determine if we're...""" is preferred (but is a non-essential change). "Helper" is implied anyway by the private function-ness
| self.view_options_panel.edit_traits() | ||
|
|
||
| def save_config(self, home_dir=None): | ||
| "Write configuration values" |
| def plot(self): | ||
| """Add the points to the mayavi pipeline""" | ||
| _scale = self.scene.camera.parallel_scale if not _testing_mode() else 1 | ||
| _scale = self.scene.camera.parallel_scale |
There was a problem hiding this comment.
Did this and the other similar change fail on 4.4.0 and now works on 4.5.0?
There was a problem hiding this comment.
I thought so, after tentatively removing some _testing_mode() checks... but travis looks like I might have been rash in removing all of them...
There was a problem hiding this comment.
Travis seems to fail even on tests that don't even install mayavi, and it fails even though according to the log all tests passed, what does that mean?
There was a problem hiding this comment.
Hm, the GUI tests work on OS X but not on linux. Is it possible there is something about the environment? Mayavi's travis.yml starts /etc/init.d/xvfb here, but our travis.yml also seems to run it, just in a different way?
|
It's a bit broken on all PRs currently
|
|
I guess then we'll have to wait... I was wondering whether it might also make sense to save SUBJECTS_DIR form the coregistration GUI. For current users it seems like it might break a workflow, but for new users it seems like it would be more logical. Or we could save it to MNE_COREG_SUBJECTS_DIR. |
|
I like the coreg specific one
|
|
Please no vulgarity in commit messages :) |
|
lol sorry |
46d0aeb to
ed8b4c5
Compare
|
You can try changing the call if you think it would help. I doubt it will
help though, since our call has been used for a long time and also by other
3D libraries that check rendering. Maybe mayavi doesn't use the testing
backend? We need to do it in order to avoid window popups.
|
8b01acc to
2b8e232
Compare
Codecov Report
@@ Coverage Diff @@
## master #3948 +/- ##
==========================================
+ Coverage 85.96% 86.05% +0.09%
==========================================
Files 349 349
Lines 62519 62696 +177
Branches 9571 9592 +21
==========================================
+ Hits 53742 53956 +214
+ Misses 6090 6043 -47
- Partials 2687 2697 +10Continue to review full report at Codecov.
|
96f9f35 to
e785a01
Compare
| options, args = parser.parse_args() | ||
|
|
||
| if options.low_res_head: | ||
| head_high_res = False |
There was a problem hiding this comment.
probably worth adding if options.high_res_head: raise ValueError(...)
There was a problem hiding this comment.
sys.exit(1) since it's a script?
There was a problem hiding this comment.
I don't think you need it, the raise will already exit
There was a problem hiding this comment.
I meant whether printing a reason and calling sys.exit() would be more appropriate since we're in a script and the conflicting arguments were specified in bash, not in a Python function call.
There was a problem hiding this comment.
I don't think it makes much difference. I'd do raise but it's up to you
|
The problem must be in But I can't find what the kit2fiff GUI is doing that the coreg GUI is not... Do you remember what exactly it is that has to be disabled? |
I have gotten this problem locally with Mayavi before. Not sure what causes it, other than it clearly being a bug with Mayavi/VTK. I'll see if I can replicate locally. Can you? Probably not since IIRC you're on OSX and this is an X server-related error... |
|
I can't replicate it. I would personally leave the skip in there and deal with it later :) But if you really want to try to fix it, this seems to be caused by some cleanup / exit routines. You could try extra hard to make sure everything is closed (look at Mayavi, VTK, etc. for such functions) and garbage-collected ( The most enlightening thing might be to do |
f10b21c to
831443a
Compare
831443a to
2d4f1b1
Compare
|
Hm, no better error message... |
2d4f1b1 to
1a0667e
Compare
|
Shoot. Well maybe just |
|
... but only do that if on Travis |
1a0667e to
a922bd2
Compare
larsoner
left a comment
There was a problem hiding this comment.
Otherwise LGTM, +1 for merge assuming it's ready from your end
| options, args = parser.parse_args() | ||
|
|
||
| if options.low_res_head: | ||
| head_high_res = False |
There was a problem hiding this comment.
I don't think you need it, the raise will already exit
| "and 1, got %r" % (head_opacity,)) | ||
| self._initial_head_opacity = head_opacity | ||
|
|
||
| subjects_dir = get_subjects_dir(subjects_dir) |
There was a problem hiding this comment.
You're getting rid of this because the default is already taken elsewhere?
There was a problem hiding this comment.
|
I added the ValueError to |
|
LGTM, +1 for merge Anyone else want to have a look? |
|
Thanks @christianbrodbeck |
@Eric89GXL This uses
get_configandset_configto restore some options across GUI sessions. I can add other options that would be useful. From a cursory search I did not find where to retrieve the view size.This reads and writes the config file multiple times; I assume that's not a huge deal but maybe we could make getting/setting of multiple keys more efficient. Reading with
get_config()has the disadvantage that environment variables are ignored.