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

Silencing "a jupyter kernel connection is required..." message #776

Closed
agahkarakuzu opened this issue Oct 5, 2024 · 7 comments
Closed

Comments

@agahkarakuzu
Copy link

Hi!

I was wondering if there is an option to suppress this message in an output rendered through MyST:

<div class="thebe-ipywidgets-placeholder-message"><code>ipywidgets</code> - a Jupyter kernel connection is required to fully display this output.</div>

For a cleaner look, I want to add this information in the figure caption and suppress from the output (if possible).

Thank you!

@stevejpurves
Copy link
Collaborator

Hi @agahkarakuzu, one way to suppress the output is to add a placeholder to the figure, that should/would remove that message. And it will look nicer/cleaner in the process - https://mystmd.org/guide/reuse-jupyter-outputs#placeholder-content - does that fit your use case?

@agahkarakuzu
Copy link
Author

Hi @stevejpurves, thanks for responding! I already have an interactive figure (widgets are modifying traces on it when connected to a kernel) rendered from the labeled cell output at the initial values of the sliders, and the warning appears right below it. So I assume using a placeholder would remove the content of interest?

@stevejpurves
Copy link
Collaborator

stevejpurves commented Oct 7, 2024

@agahkarakuzu it would replace the entire contents of the figure (all cell outputs) only on initial render, as soon as you connected to a kernel and ran the figure (cell/notebook) it would be replaced with your widgets.

It sounds like your cell might be producing 2 outputs though? the first an interactive graph that does not require a kernel and the second containing widgets? [in which case the placeholder is not going to cut it, it would if your passive render was a static image]

@agahkarakuzu
Copy link
Author

The widget callback is creating/updating the interactive figure.

This is how it looks on the page:

Image

and on the notebook:

Image

with the following input:

#| label: interactCylinder

@interact(Ncyl=widgets.IntSlider(min=1, max=100, step=1, value=30,description="# cylinders"), R=widgets.FloatSlider(min=0.5, max=5, step=0.5, value=1.5, description="R cylinder"))
def update(Ncyl, R):
    """Update the visualization based on widget values."""
    visualize_random_cylinders(Ncyl=Ncyl, R=R, L=100)

@stevejpurves
Copy link
Collaborator

yes I thought so. I take it you would also want to remove the interactive(children=...?

so it looks like this line in the https://github.com/jupyter-book/myst-theme/blob/50c625864f091f52dc563cd3bd486e68de3625d1/packages/jupyter/src/jupyter.tsx#L90-L91 @myst-theme/jupyter package is the culprit but there's no configuration available for that right now, seems like it could be a "theme option" which would then need to be propagated through, to the PassiveOutputRenderer.

it might be better to wait on jupyter-book/myst-theme#429 though.!?

@agahkarakuzu
Copy link
Author

Thank you so much for the clarification!

I'll keep an eye on this PR as it is not really urgent and pretty glad to learn about rehydration through a PR :)

@stevejpurves
Copy link
Collaborator

great, closing this for now then

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

No branches or pull requests

2 participants