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

Add rerender option for HoloViews pane #1021

Merged
merged 1 commit into from
Jan 28, 2020
Merged

Add rerender option for HoloViews pane #1021

merged 1 commit into from
Jan 28, 2020

Conversation

philippjfr
Copy link
Member

@Jacob-Barhak Want to try this out, basically just do this with your hv objects:

pn.pane.HoloViews(holomap, rerender=True).save('test.html', embed=True)

@codecov
Copy link

codecov bot commented Jan 28, 2020

Codecov Report

Merging #1021 into master will decrease coverage by 0.04%.
The diff coverage is 69.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1021      +/-   ##
==========================================
- Coverage      86%   85.95%   -0.05%     
==========================================
  Files         105      105              
  Lines       11893    11909      +16     
==========================================
+ Hits        10228    10236       +8     
- Misses       1665     1673       +8
Impacted Files Coverage Δ
panel/io/embed.py 88.52% <100%> (ø) ⬆️
panel/pane/holoviews.py 83.21% <68.62%> (-1.35%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4bb0d7...5f5616f. Read the comment docs.

@Jacob-Barhak
Copy link
Contributor

You will have to better explain what this option does, yet installing the new version from master and using this new rerender option only makes things worse - moving sliders seem not to work at all now at least in one case - I will run a few more tests to make sure, yet if there is any difference than before, it is only worse.
Hopefully the problem is on my side.

@philippjfr
Copy link
Member Author

It will almost certainly be slower and result in much larger files but I've not encountered a situation where it doesn't work.

@philippjfr
Copy link
Member Author

philippjfr commented Jan 28, 2020

Just to explain both the issues you are having with HoloViews and what this workaround is meant to achieve. Embedding in Panel (and previously the HoloMap support in HoloViews) work by collecting all the widgets in an app that have a discrete set of values and then taking their cross product to come up with the state space. The embedding code then iterates over that state space and records the events that are generated as each change is applied. This works well for simple cases but can exhibit issues with more complex cases when combined with HoloViews. Specifically HoloViews tries to compute the minimal set of events to go from one state to the next. Imagine you have states A, B and C, the embedding code will go from A->B and record the events, and then go from B->C and record the events. However, since it's computing minimal diffs the transition from C->B may not include all the events to fully restore the view to the original state A, because it has only recorded the diff to go from A->B and A and B may be more similar than C and A. This problem is particularly acute when we change column labels.

The correct solution would be to ensure that during embedding HoloViews always includes all the events necessary to fully restore the state. An alternative solution would be to find a path through the state space that applies all the events to get to that state consecutively. Both are pretty difficult problems, particularly while also still minimizing the size of the resulting data. This PR is a total hammer to solve this problem, instead of saying "let's try to compute a minimal diff between A and B" it says, let's just embed the entire plot for each state change. This will result in much bigger file sizes and trigger a full rerender of the plot but it also guarantees all the state changes are recorded in full.

@Jacob-Barhak
Copy link
Contributor

Jacob-Barhak commented Jan 28, 2020 via email

@philippjfr
Copy link
Member Author

Does state A represent a certain value in Widget 1 or does it represent a
set of values in all widgets?

It represents a set of values across all widgets.

If a state represents a combination of widget values, then have you
considered creating a null state that you always pass through that resets
everything before moving to the desired end state? This may reduce the
combination numbers - yet again, this is only if I understand the term
state correctly.

This may be a very good idea, can't say offhand if it'll work but it's definitely worth investigating

Your approach of embedding all states seems nice, since I do not care about
file size, yet this approach does not work for me - the plot just does not
change anything.

Do you have a smaller example I could try?

@Jacob-Barhak
Copy link
Contributor

Jacob-Barhak commented Jan 28, 2020 via email

@philippjfr
Copy link
Member Author

If I understand you correctly now, it seems that your Render solution is
probably similar to what I meant by passing through a null state

It's similar but in fact a null state may be better overall. Instead of embedding a new plot each time the null state could iterate over all the plots and reset all properties to their defaults. So the basic layout and structure of plots stays the same but everything else about them is reset.

@Jacob-Barhak
Copy link
Contributor

Jacob-Barhak commented Jan 28, 2020 via email

@philippjfr philippjfr deleted the hv_rerender branch January 31, 2020 02:52
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