Skip to content

Conversation

@GuillaumeFavelier
Copy link
Contributor

@GuillaumeFavelier GuillaumeFavelier commented Apr 14, 2020

This PR adds a small README that describes the instructions to update the resource.py file used for _TimeViewer.

@GuillaumeFavelier GuillaumeFavelier self-assigned this Apr 14, 2020
@GuillaumeFavelier GuillaumeFavelier changed the title _TimeViewer resource guide MRG: _TimeViewer resource guide Apr 14, 2020
@codecov
Copy link

codecov bot commented Apr 14, 2020

Codecov Report

Merging #7606 into master will increase coverage by 0.00%.
The diff coverage is 75.00%.

@@           Coverage Diff           @@
##           master    #7606   +/-   ##
=======================================
  Coverage   90.08%   90.09%           
=======================================
  Files         454      454           
  Lines       83551    83568   +17     
  Branches    13228    13238   +10     
=======================================
+ Hits        75266    75287   +21     
+ Misses       5420     5418    -2     
+ Partials     2865     2863    -2     

GuillaumeFavelier and others added 8 commits April 15, 2020 10:44
Co-Authored-By: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-Authored-By: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-Authored-By: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-Authored-By: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-Authored-By: Richard Höchenberger <richard.hoechenberger@gmail.com>
@GuillaumeFavelier
Copy link
Contributor Author

Azure seems to take a bit more time. I don't think it's related to this PR.

@hoechenberger
Copy link
Member

Azure seems to take a bit more time. I don't think it's related to this PR.

I believe it's getting canceled bc the build is taking too long… anyway, LGTM.

Patching
========

The output file imports ``PyQt5`` globally, which is not consistent with MNE core
Copy link
Member

Choose a reason for hiding this comment

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

Rather than all of this, can you nest the import of resources.py wherever it's actually used in the MNE code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try that right now

@GuillaumeFavelier GuillaumeFavelier changed the title MRG: _TimeViewer resource guide WIP: _TimeViewer resource guide Apr 16, 2020
@GuillaumeFavelier
Copy link
Contributor Author

Okay, I think I'll just keep everything in mne/images:

  • the SVG icons
  • the resource config file mne.qrc
  • the resource file itself resources.py

@larsoner
Copy link
Member

That sounds like a nice solution to me

Also you have a conflict

@GuillaumeFavelier
Copy link
Contributor Author

Waiting for the CIs to come back happy. Thanks to #7606 (comment) it should be way easier to update the icons.

@hoechenberger
Copy link
Member

Okay, I think I'll just keep everything in mne/images:

Excellent

@hoechenberger
Copy link
Member

hoechenberger commented Apr 17, 2020

btw are you planning do add "images" to that directory that would not be some kind of icon? Just asking bc if not, it could make sense to name the directory "icons" instead?

@GuillaumeFavelier
Copy link
Contributor Author

You're right, icons is a better name.

@GuillaumeFavelier GuillaumeFavelier changed the title WIP: _TimeViewer resource guide MRG: _TimeViewer resource guide Apr 17, 2020
@GuillaumeFavelier GuillaumeFavelier changed the title MRG: _TimeViewer resource guide WIP: _TimeViewer resource guide Apr 17, 2020
@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Apr 17, 2020

Rather than all of this, can you nest the import of resources.py wherever it's actually used in the MNE code?

@larsoner Travis fails because of this import during test collection:

from PyQt5 import QtCore

I tried importing it where it's needed in MNE (in _TimeViewer) but I don't think it's enough.

def load_icons(self):
from PyQt5.QtGui import QIcon
from ...icons import resources # noqa

@safe_event
def clean(self):
from ...icons import resources

Do you have an idea?

@larsoner
Copy link
Member

larsoner commented Apr 17, 2020

It will be imported during test collection unless you add it to the ignore list in setup.cfg or maybe mne/conftest.py, it's in one of those

@larsoner
Copy link
Member

Ignore list, sorry mobile...

@GuillaumeFavelier
Copy link
Contributor Author

Wow, thank you! I was not aware of such a system.

@GuillaumeFavelier GuillaumeFavelier changed the title WIP: _TimeViewer resource guide MRG: _TimeViewer resource guide Apr 17, 2020
def load_icons(self):
from PyQt5.QtGui import QIcon
resources.qInitResources()
from ...icons import resources # noqa
Copy link
Member

Choose a reason for hiding this comment

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

rather than a noqa and magic init-on-import, I'd leave it closer to how it was and do

from ...icons import resources
resources.qInitResources()

BTW any problem with calling this multiple times (which will happen if you load multiple windows)? If so then a little helper init_resources that inits them exactly once could be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem at all, I tested it with link_brains().

@GuillaumeFavelier GuillaumeFavelier changed the title MRG: _TimeViewer resource guide WIP: _TimeViewer resource guide Apr 17, 2020
@GuillaumeFavelier
Copy link
Contributor Author

Oh I misunderstood: there is no problem calling init multiple times but I still did _init_resources.

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, please merge once CIs are happy

@GuillaumeFavelier GuillaumeFavelier changed the title WIP: _TimeViewer resource guide MRG: _TimeViewer resource guide Apr 17, 2020
@larsoner
Copy link
Member

Doing it once or multiple times is fine by me, up to you

@GuillaumeFavelier
Copy link
Contributor Author

It works. I'll merge like this

@larsoner larsoner merged commit 90c5c8e into mne-tools:master Apr 19, 2020
@GuillaumeFavelier GuillaumeFavelier deleted the time_viewer_resource_guide branch June 11, 2020 09:44
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.

4 participants