jonescompneurolab / hnn-core

Simulation and optimization of neural circuits for MEG/EEG source estimates
https://jonescompneurolab.github.io/hnn-core/
BSD 3-Clause "New" or "Revised" License
53 stars 52 forks source link

[MRG] Update GUI to latest version of ipywidgets and voila #696

Closed gtdang closed 7 months ago

gtdang commented 9 months ago

Completed

Remarks

Questions

To do:

gtdang commented 8 months ago

Just documenting the failed tests for areas that need to be addressed yet.

FAILED hnn_core/tests/test_gui.py::test_gui_upload_params - traitlets.traitlets.TraitError: The 'value' trait of a FileUpload instance expected a tuple, not the dict...
FAILED hnn_core/tests/test_gui.py::test_gui_upload_data - traitlets.traitlets.TraitError: The 'value' trait of a FileUpload instance expected a tuple, not the dict...
FAILED hnn_core/tests/test_gui.py::test_gui_take_screenshots - AttributeError: 'Tab' object has no attribute '_titles'
FAILED hnn_core/tests/test_gui.py::test_gui_adaptive_spectrogram - AttributeError: 'Tab' object has no attribute '_titles'

This is pretty consistent with ipywidgets 8.x API changes to FileUpload and accessing collection widget attributes. Good to know!

codecov-commenter commented 8 months ago

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (1216038) 91.34% compared to head (2d4bd76) 91.35%. Report is 7 commits behind head on master.

:exclamation: Current head 2d4bd76 differs from pull request most recent head 96e4a6a. Consider uploading reports for the commit 96e4a6a to get more accurate results

Files Patch % Lines
hnn_core/gui/_viz_manager.py 83.87% 5 Missing :warning:
hnn_core/gui/gui.py 92.30% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #696 +/- ## ========================================== + Coverage 91.34% 91.35% +0.01% ========================================== Files 25 25 Lines 4599 4606 +7 ========================================== + Hits 4201 4208 +7 Misses 398 398 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

gtdang commented 8 months ago

@ntolley Seems like the macOS tests are passing now. It's failing on docs and link check? Are you familiar with these errors?

ntolley commented 8 months ago

New error for me as well @gtdang

Looks like it's a weird consequence of one of the version changes with the ipywidgets?

ntolley commented 8 months ago

@gtdang I did some digging and I think the answer is to add ipykernel as an explicit dependency:

https://stackoverflow.com/questions/76855161/no-such-kernel-named-python3-ipywidgets-ipykernel-dependency-issue

https://github.com/jupyter-widgets/ipywidgets/issues/3731

gtdang commented 8 months ago

@ntolley adding ipykernel as a GUI dependency seemed to do the trick!

Now the docs build is timing out as it's taking longer than 10mins. Does this tend to happen? If so, we could try increasing the timeout limit from the default 10m.

gtdang commented 8 months ago

@ntolley adding ipykernel as a GUI dependency seemed to do the trick!

Now the docs build is timing out as it's taking longer than 10mins. Does this tend to happen? If so, we could try increasing the timeout limit from the default 10m.

Hm never mind. It seems like the GUI captures are not rendering for creating the docs. I'll have to dig into why this is happening with the updated dependencies.

gtdang commented 8 months ago

@ntolley I updated the circleci config file to bump the build timeout to 20mins. It passed this time however looking the logs the build took <2min... So I'm thinking that change wasn't necessary and the timeout was just some inconsistency/stability issue on the vm. But I guess it doesn't hurt to keep it at 20mins? I'm not sure what plan you are on and if runtime is limited.

jasmainak commented 8 months ago

But I guess it doesn't hurt to keep it at 20mins?

we need to find a solution to this ... @gtdang if you are willing to help that would be great. IMO, the GUI docs should be run separately. Currently running make html-noplot also runs the GUI examples ... it's a bug

we need a dedicated machine for running the GUI docs because they are slow ... either on a paid plan on CircleCI or through the Brown infrastructure. Not sure how we'd link it to pull requests if we do it on the Brown infrastructure though.

jasmainak commented 8 months ago

But I guess it doesn't hurt to keep it at 20mins?

Let's merge this PR with the 10 min limit and try to find a long-term solution in separate pull requests

gtdang commented 8 months ago

But I guess it doesn't hurt to keep it at 20mins?

Let's merge this PR with the 10 min limit and try to find a long-term solution in separate pull requests

We actually found another issue on Wednesday with the .capture() method no longer rendering the GUI--an issue for the GUI docs/tutorials. After some digging it's related to https://github.com/jupyter-widgets/ipywidgets/issues/3871. So we'll need to find an alternative solution for capturing the state of the GUI and displaying it. Should we hold off on merging until that is figured out?

jasmainak commented 8 months ago

ughgh ... any workarounds for now?

maybe: https://html2canvas.hertzen.com/ ?

ntolley commented 8 months ago

Not a bad option @jasmainak !

Truthfully I think it may be best to keep this PR focused on making the GUI functional, and in a separate one either fix the docs or test a new solution all together

gtdang commented 8 months ago

Not a bad option @jasmainak !

Truthfully I think it may be best to keep this PR focused on making the GUI functional, and in a separate one either fix the docs or test a new solution all together

I agree. I think the docs solution will be in a separate PR. I'm not in love the the current implementation of the GUI tutorials (even when it is working properly). It's a bit confusing and resource intensive for for the end user. I think screenshots would more clear for the user, although it has the tradeoff being less a streamlined process for writers. There are ways to automate screen captures pyautogui. We can discuss more when we meet this week.

jasmainak commented 8 months ago

will pyautogui require xvfb or a virtual screen to make it work in the CIs? My concern is that exact coordinates for the CI may be difficult to guess ... but I'm open to anything that works and is a stable solution

gtdang commented 8 months ago

will pyautogui require xvfb or a virtual screen to make it work in the CIs? My concern is that exact coordinates for the CI may be difficult to guess ... but I'm open to anything that works and is a stable solution

Yes it would be a 2 step process of first running the simulation and grabbing the screenshots and then creating the documentation using the images. It shouldn't need to be done every time we regenerate docs though, only if the UI changes. You can actually give it images of buttons/tabs for it to find the coordinates to click. The images should also have the mouse cursor to highlight context.

For html2canvas... I would be against adding a js runtime dependency just for screen caps. Also the execution would be pretty difficult because you would have to invoke the js after each cell execution... not at the end of the full notebook execution.

ntolley commented 7 months ago

@jasmainak I'm good with going ahead and merging this PR as I think in the long term we are going to move to a screenshot method for tutorials (either automated or manual). In any case I think the purpose of this PR is achieved, the next one to work on is #651

Merge button is yours if you're good with its current state!

jasmainak commented 7 months ago

Thanks @gtdang ! Congratulations on your first merged PR 🥳 🍺 🎉