Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: close_connect #10388

Merged
merged 5 commits into from
Feb 23, 2022
Merged

Conversation

GuillaumeFavelier
Copy link
Contributor

Some functions need to be called before the closing event (i.e: dialog, ...etc) and some after (qt object cleanup). This PR adds a bit of flexibility to the GUI API to do just that.

Locally, it solves the issue with doc building.

Traceback (most recent call last):
  File "/home/guillaume/source/anaconda3/envs/mne-py38/lib/python3.8/site-packages/sphinx/events.py", line 101, in emit
    results.append(listener.handler(self.app, *args))
  File "/home/guillaume/source/sphinx-gallery/sphinx_gallery/gen_gallery.py", line 464, in generate_gallery_rst
    generate_dir_rst(src_dir, target_dir, gallery_conf,
  File "/home/guillaume/source/sphinx-gallery/sphinx_gallery/gen_rst.py", line 399, in generate_dir_rst
    intro, title, cost = generate_file_rst(
  File "/home/guillaume/source/sphinx-gallery/sphinx_gallery/gen_rst.py", line 1031, in generate_file_rst
    clean_modules(gallery_conf, fname, 'after')
  File "/home/guillaume/source/sphinx-gallery/sphinx_gallery/scrapers.py", line 596, in clean_modules
    reset_module(gallery_conf, fname, when=when)
  File "/home/guillaume/source/mne-python/doc/conf.py", line 341, in __call__
    _assert_no_instances(Brain, when)  # calls gc.collect()
  File "/home/guillaume/source/mne-python/mne/utils/misc.py", line 368, in _assert_no_instances
    assert n == 0, f'\n{n} {cls.__name__} @ {when}:\n' + '\n'.join(ref)
AssertionError: 
4 Brain @ mne/conf.py:Resetter.__call__:after:10_ieeg_localize.py:
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f6987b9c460>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f698d666b80>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f6987b0f520>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f698d6665e0>>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/guillaume/source/anaconda3/envs/mne-py38/lib/python3.8/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/home/guillaume/source/anaconda3/envs/mne-py38/lib/python3.8/site-packages/sphinx/application.py", line 270, in __init__
    self._init_builder()
  File "/home/guillaume/source/anaconda3/envs/mne-py38/lib/python3.8/site-packages/sphinx/application.py", line 328, in _init_builder
    self.events.emit('builder-inited')
  File "/home/guillaume/source/anaconda3/envs/mne-py38/lib/python3.8/site-packages/sphinx/events.py", line 109, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function generate_gallery_rst at 0x7f69f256de50> for event 'builder-inited' threw an exception (exception: 
4 Brain @ mne/conf.py:Resetter.__call__:after:10_ieeg_localize.py:
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f6987b9c460>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f698d666b80>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f6987b0f520>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f698d6665e0>>)

Extension error (sphinx_gallery.gen_gallery):
Handler <function generate_gallery_rst at 0x7f69f256de50> for event 'builder-inited' threw an exception (exception: 
4 Brain @ mne/conf.py:Resetter.__call__:after:10_ieeg_localize.py:
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f6987b9c460>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f698d666b80>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f6987b0f520>>
Brain._cleaned = True
method: <bound method Brain._clean of <mne.viz._brain._brain.Brain object at 0x7f698d6665e0>>)
make: *** [Makefile:60: html_dev-pattern] Error 2

The issue with Brain was related to _RenderWindow not being reset, indeed a regression from #10305
cc @larsoner

@GuillaumeFavelier GuillaumeFavelier self-assigned this Feb 23, 2022
@GuillaumeFavelier GuillaumeFavelier marked this pull request as draft February 23, 2022 10:24
@GuillaumeFavelier GuillaumeFavelier marked this pull request as ready for review February 23, 2022 11:06
@larsoner
Copy link
Member

Locally it does fix the two examples that have been failing, I pushed a commit to touch those so that CircleCI can verify it, then I'll merge. Thanks in advance @GuillaumeFavelier !

@larsoner larsoner mentioned this pull request Feb 23, 2022
@larsoner larsoner added this to the 1.0 milestone Feb 23, 2022
@larsoner
Copy link
Member

Thanks for the quick fix @GuillaumeFavelier !

@larsoner larsoner merged commit 61f10d5 into mne-tools:main Feb 23, 2022
larsoner added a commit to larsoner/mne-python that referenced this pull request Feb 23, 2022
* upstream/main:
  FIX: close_connect (mne-tools#10388) [circle deploy]
  FIX: Bump deps (mne-tools#10376)
  [DOC] Small fixes [skip azure] [skip actions] (mne-tools#10381)
  FIX: coreg status bar (mne-tools#10368)
@GuillaumeFavelier GuillaumeFavelier deleted the fix/close_connect branch February 23, 2022 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants