fix(skore): Update project summary not to rely on IPython.display.display(), but use widgets and their _repr_mimebundle_ instead.#2150
Open
FrancoisPgm wants to merge 3 commits intoprobabl-ai:mainfrom
Conversation
…et, instead use sub-widgets and their _repr_mimebundle_ methods.
Collaborator
IMO, that's a sensitive issue. If we can't find a solution, i'd rather do nothing, leave things as they are, so that at least all the notebooks work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An alternative way to fix #2070.
It appears that the root cause of the issues with
Summary's__repr__is the fact thatModelExplorerWidgetuses theIPython.display.displayfunction to display its html. As far as I understand, this functions is similar to aprintstatement in that it sends the html to the stdout when it is called. When that's at the end of a jupyter notebook cell, it get handled properly, but in other cases it can create side effects, like showing the html code in an IPython terminal (#2070) or showing the widget twice in colab notebooks because the function was called once again (#2039).Therefore a possible approach to solve this issue is to avoid relying on
IPython.display.displayto show the widget, instead building it with IPython widget objects and using their_repr_mimebundle_methods instead to let IPython manage the displaying.This PR is an attempt at such a refactor.
In its current state it entails a few drawbacks:
fig.layout.autosize = Trueafter callingdisplay().Summarywidget breaks in google colab notebooks as they use an older version of IPywidgets that does not implement_repr_mimebundle_.assert widget.current_fig is None