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 dynamic reports with bokeh 3.4.0 problems #1068

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

handwerkerd
Copy link
Member

@handwerkerd handwerkerd commented Apr 1, 2024

Closes #1063

I've now had 3 people ask about crashes related to this issue I'd like to figure out a nice solution to this problem.

Changes proposed in this pull request:

  • Listed version numbers for bokeh in pyproject.toml
  • Changed a few references from circle to scatter in dynamic_figures.py
  • Since the tapping default was changed from replace to xor in bokeh v3.4.0 it was possible to select more than one component at a time and that broke other functionality. This directly defines models.TapTool(mode="replace") instead of just listing tap with the default setting.

This no longer crashes, and the static report looks fine, but there is one annoying bug relating to the dynamic interactions. I'm not sure if this is due to the above changes or due to other changes in bokeh 3.4.0. The generated report looks fine, but if you click on one component and then another, then, instead of presenting the most recent one, both are highlighted and you have to unclick each component before highlighting a new one. I could use help from someone who has played with bokeh a bit more than I have (@eurunuela @javiergcas).

@handwerkerd
Copy link
Member Author

This is an example of the new problem. We should either have one highlighted component or all highlighted. I sequentially clicked on 3 components and they all remained highlighted.
image

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.69%. Comparing base (f084dc4) to head (75a7483).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1068   +/-   ##
=======================================
  Coverage   89.68%   89.69%           
=======================================
  Files          26       26           
  Lines        3482     3483    +1     
  Branches      615      615           
=======================================
+ Hits         3123     3124    +1     
  Misses        211      211           
  Partials      148      148           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@handwerkerd
Copy link
Member Author

I just ran this PR with bokeh=3.4.0 and bokeh=3.3.4. The above problem does NOT happen with v3.3.4, which means this the unaddressed issue is probably due to some other change within v3.4.0 and not the code changes in this PR.

@eurunuela
Copy link
Collaborator

I will have a look at it.

@eurunuela
Copy link
Collaborator

It is not as straightforward as I had hoped. I would suggest we limit bokeh to <=3.34 if the latest version isn't necessary for us.

@handwerkerd
Copy link
Member Author

I decided to ask a question on their support forum. https://discourse.bokeh.org/t/dynamic-figure-problem-with-bokeh-v-3-4-0-udgrade/11416

If we don't hear about a solution in the next few days, I'll limit this PR to 3.3.4. Assuming no one else sees issues, my changes from circle to scatter are probably good to merge since they should be backwards compatible (I haven't tested v1.0.0, but scatter was added to that version) and will be issues in the future.

@handwerkerd
Copy link
Member Author

I decided to look more carefully through all the PRs merged for v3.4.0. The one that stands out to me is Add support for xor selection and inversion by mattpap · Pull Request #13545 · bokeh/bokeh · GitHub It changed the default response for taps and the new behavior I’m seeing is vaguely similar to the new default. That is I now need to tap an element a second time to deselect it before clicking on a new element.

On the bokeh discussion board, I asked whether there a way to explicitly apply the previous default so that I can confirm whether or not this is the cause of our issue. They suggested I post that Q on another board, but I also wanted to share here and see if this might be something @eurunuela can already figure out how to do.

@handwerkerd
Copy link
Member Author

handwerkerd commented Apr 4, 2024

I think I've solved this problem. The issue was that bokeh's model.TapTool default setting for mode changed from replace to xor. In practice, this meant the variable selected_idx previously was always a single number, but, in bokeh v3.4.0 was a string of numbers.

When defining toolbars, we just included the word tap instead of explicitly defining a model.TapTool. By adding models.TapTool(mode="replace") to a few places in the code, I think it now works. There was a second weird thing where the 'hover' icon was now appearing twice to the left of the scatter plot. I think that was because it was being differently defined in different functions. (if people have opinions on the order of those icons, we can rearrange)

@handwerkerd handwerkerd changed the title Fix dynamic reports with bokeh 3.4.0 problem Fix dynamic reports with bokeh 3.4.0 problems Apr 4, 2024
@handwerkerd
Copy link
Member Author

@tsalo and @eurunuela This is now ready for review. One think I want to check with you is that I've now added version numbers for bokeh to pyproject.toml. Given it has version numbers, will the dependabot automatically open new PRs when future bokeh versions are released or do we need to change something else as well?

Copy link
Member

@tsalo tsalo left a comment

Choose a reason for hiding this comment

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

Setting the minimum and maximum versions will trigger dependabot when new bokeh releases are made, so we should have forewarning of future issues like this one w.r.t. bokeh.

The donut plot in the CI looks good to me.

@handwerkerd
Copy link
Member Author

@eurunuela This is my first time playing around with the bokeh parts of this code. Could you take a look to make sure this all seems good to you?

Copy link
Collaborator

@eurunuela eurunuela left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you @handwerkerd! I'm glad you found a workaround. It didn't seem very obvious when I checked, but I haven't used bokeh in a while so maybe my bokeh skills are no longer useful.

@handwerkerd handwerkerd merged commit 629fc33 into ME-ICA:main Apr 8, 2024
16 checks passed
@handwerkerd handwerkerd deleted the fix-bokeh3.4.0 branch April 8, 2024 18:56
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.

dynamics reports crashing with bokeh 3.4.0
3 participants