question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dash in Jupyter - more seamless jupyter notebook integration

See original GitHub issue

This answer in forum provides this function to do this using iframe:

from IPython import display
def show_app(app,  # type: dash.Dash
             port=9999,
             width=700,
             height=350,
             offline=True,
             style=True,
             **dash_flask_kwargs):
    """
    Run the application inside a Jupyter notebook and show an iframe with it
    :param app:
    :param port:
    :param width:
    :param height:
    :param offline:
    :return:
    """
    url = 'http://localhost:%d' % port
    iframe = '<iframe src="{url}" width={width} height={height}></iframe>'.format(url=url,
                                                                                  width=width,
                                                                                  height=height)
    display.display_html(iframe, raw=True)
    if offline:
        app.css.config.serve_locally = True
        app.scripts.config.serve_locally = True
    if style:
        external_css = ["https://fonts.googleapis.com/css?family=Raleway:400,300,600",
                        "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css",
                        "http://getbootstrap.com/dist/css/bootstrap.min.css", ]

        for css in external_css:
            app.css.append_css({"external_url": css})

        external_js = ["https://code.jquery.com/jquery-3.2.1.min.js",
                       "https://cdn.rawgit.com/plotly/dash-app-stylesheets/a3401de132a6d0b652ba11548736b1d1e80aa10d/dash-goldman-sachs-report-js.js",
                       "http://getbootstrap.com/dist/js/bootstrap.min.js"]

        for js in external_js:
            app.scripts.append_script({"external_url": js})

    return app.run_server(debug=False,  # needs to be false in Jupyter
                          port=port,
                          **dash_flask_kwargs)

This question on Stack Overflow provides further evidence of interest in this feature. So, I’m posting this here both as feature request and as a reference. Feel free to close this issue if you are already aware of this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

30reactions
chriddypcommented, Oct 29, 2018

We’re experimenting with a lightweight JupyterLab extension that:

  • renders the Dash app in a JupyterLab tab as an iframe.
  • runs the app in a separate process/thread to prevent the run_server call from blocking the kernel. It detects when the app has changed and then restarts the dash app.

One of the nice things about developing in Jupyter is that the data pre-processing steps are sort of “cached” in the initial cells. So, you can preserve a single cell for your app.layout and iterate pretty quickly.

dashjupyterlabextension

We’ll keep this thread updated with our progress

12reactions
chriddypcommented, Dec 6, 2018

We have open sourced this extension in this repo: https://github.com/plotly/jupyterlab-dash 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Dash in Jupyter and Workspaces
JupyterDash is a library that makes it easy to build Dash apps from Jupyter environments. In this chapter, we demonstrate using JupyterDash in...
Read more >
Setting up Plotly Dash in JupyterLab & Jupyter Notebook
In this tutorial you'll learn to set up Jupyter Lab and Jupyter Notebook to run your Plotly Dash Apps, using PC or Mac....
Read more >
Problems Running Dash In Jupyter Notebook - ADocLib
By integrating the Plotly Dash frontend with the Databricks backend we are offering a seamless process to transform AI and ML models into...
Read more >
Interactive Jupyter Dashboards > JupyterLab JupyterHub ...
Galyleo is the first Jupyter-native, open-source solution for Jupyter dashboards and analytics. You can run it in the cloud with zero laptop resources....
Read more >
It would be awesome if we could integrate Jupyter Notebooks ...
... Jupyter Notebooks with Kibana (more seamlessly, like a dashboard) ... Eland is proof that Elastic understands the value in integration ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found