-
Notifications
You must be signed in to change notification settings - Fork 52
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
[MRG] Update GUI to latest version of ipywidgets and voila #696
[MRG] Update GUI to latest version of ipywidgets and voila #696
Conversation
… objects when adding figures. This is to function with ipywidgets 8.* implementation of selection index change validation for Tab objects.
…d removed version pins of voila and ipympl.
…lib 8.x deprecation of ax._get_lines.prop_cycler.
… objects when adding figures. This is to function with ipywidgets 8.* implementation of selection index change validation for Tab objects.
…d removed version pins of voila and ipympl.
…latest-ipywidgets-version
@@ -711,6 +739,7 @@ def compose(self): | |||
]) | |||
return config_panel, fig_output_container | |||
|
|||
@unlink_relink(attribute='figs_config_tab_link') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to think of one line comment on ipywidgets figure linking logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps: "Unlinks Tab objects to avoid index error from asynchronous addition of new tabs."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I missed the discussion on this, is it a bugfix or something related to the new version of ipywidgets?
Just documenting the failed tests for areas that need to be addressed yet.
This is pretty consistent with ipywidgets 8.x API changes to FileUpload and accessing collection widget attributes. Good to know! |
…ignment for collections. Changed del in favor of the pop method to remove from lists and dicts because it was causing an error. Added comments.
… widget. Updated "value" trait from a dict to list.
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ 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 ☔ View full report in Codecov by Sentry. |
@ntolley Seems like the macOS tests are passing now. It's failing on docs and link check? Are you familiar with these errors? |
New error for me as well @gtdang Looks like it's a weird consequence of one of the version changes with the |
@gtdang I did some digging and I think the answer is to add |
…is as dependency so we must explicitly include for CI tests.
@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. |
@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. |
…uild stage to 20min." This reverts commit c882122.
hnn_core/gui/_viz_manager.py
Outdated
@@ -99,6 +99,35 @@ def plot_type_coupled_change(new_plot_type, target_data_selection): | |||
target_data_selection.disabled = False | |||
|
|||
|
|||
def unlink_relink(attribute: str): | |||
""" | |||
Wrapper function to unlink widgets to perform edits and re-link them on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check PEP 257 convention ... need a one-line description first ... longer description may follow later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Wrapper function" as in decorator, right?
hnn_core/gui/_viz_manager.py
Outdated
@@ -99,6 +99,35 @@ def plot_type_coupled_change(new_plot_type, target_data_selection): | |||
target_data_selection.disabled = False | |||
|
|||
|
|||
def unlink_relink(attribute: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't do type annotations ... I think it will have to be a repo-wide change, let's stick to repo conventions for now to keep things consistent
hnn_core/gui/_viz_manager.py
Outdated
@@ -565,8 +600,8 @@ def _add_figure(b, widgets, data, scale=0.95, dpi=96): | |||
with widgets['figs_output']: | |||
display(widgets['figs_tabs']) | |||
|
|||
widgets['figs_tabs'].children = widgets['figs_tabs'].children + ( | |||
fig_outputs, ) | |||
widgets['figs_tabs'].children = \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backslashes are not preferred ... would suggest using paranthesis if possible
hnn_core/tests/test_gui.py
Outdated
from hnn_core import Dipole, Network, Params | ||
from hnn_core.gui import HNNGUI | ||
from hnn_core.gui._viz_manager import _idx2figname, _no_overlay_plot_types | ||
from hnn_core.gui._viz_manager import _idx2figname, _no_overlay_plot_types, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paranthesis instead of backslash
def test_unlink_relink_widget(): | ||
"""Tests the unlinking and relinking of widgets decorator.""" | ||
|
||
# Create a basic version of the VizManager class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use VizManager
class directly for testing? what's the bottleneck?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mostly out of principle to make the test small and clear so that the scope of the test is just the functionality of the decorator, which makes it easier to detect if the a bug is coming from within the function vs externally.
The full functionality tests of the VizManager liketest_gui_add_figure
would already catch/debug bugs that occur in VizManager and its use of the decorator.
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 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. |
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 |
ughgh ... any workarounds for now? maybe: https://html2canvas.hertzen.com/ ? |
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. |
will |
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. |
@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! |
@@ -106,7 +106,7 @@ def run(self): | |||
'h5io' | |||
], | |||
extras_require={ | |||
'gui': ['ipywidgets <=7.7.1', 'ipympl<0.9', 'voila<=0.3.6'], | |||
'gui': ['ipywidgets>=8.0.0', 'ipykernel', 'ipympl', 'voila'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll need to update README:
https://jonescompneurolab.github.io/hnn-core/stable/index.html
let me know once you fix it and I'll go ahead and merge @gtdang !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Updated!
Thanks @gtdang ! Congratulations on your first merged PR 🥳 🍺 🎉 |
Completed
Though only to the scope of what was causes crashes with what I was testing (composition and simulation launch).There could be more areas were it should be updated.FileUpload
widget API_counter
trait ofFileUpload
.ipykernel
as a GUI dependency. ipywidgets removed its dependency of ipykernel to allow more flexibility to use other kernels. This might only need to be a test dependency?Remarks
I've only tested the using the GUI to launch the default simulation and adding some of the plots. Will need to test/search for more updates to the ipywidgets 8.x API. I suspect features like file-upload also need to be updated.Questions
FileUpload
button widget has a counter displayed showing the number of files uploaded. This counter cannot be disabled. (FileUpload displayed counter should be optional jupyter-widgets/ipywidgets#2904) For the network connectivity and drives upload button, the current code always keeps this number at 0. Do we want to keep it that way or should it counter increment to 1 if the user loads a param file?Personally I don't think the counter is great for our application and wish it could be removed... I think the user does need to have some confirmation that a file has been loaded though. An informational display of what files have been loaded for network and drive would be nice. And this could even show that a default file has been loaded at the start.We decided to keep the counter always at 0.To do: