def _use_isolated_frame()

in python-package/lets_plot/frontend_context/_html_contexts.py [0:0]


def _use_isolated_frame() -> bool:
    # check environment
    if has_global_value(HTML_ISOLATED_FRAME):
        return get_global_bool(HTML_ISOLATED_FRAME)

    # return _detect_isolated_frame()
    if not _is_IPython_display():
        return True  # fallback to a complete HTML page in the output

    # Some notebooks behave like a single HTML page where the JS library is loaded once per notebook.
    if (_is_jupyter_classic() or
            _is_kaggle() or
            _is_positron_notebook()):
        return False  # no iframes in the output cell

    # Most online notebook platforms are showing cell output in iframe and require
    # a complete HTML page in the output which includes both:
    # - the script loading JS library and
    # - the script that uses this JS lib to create a plot.

    if (_is_google_colab() or
            _is_azure_notebook() or
            _is_deepnote() or
            _is_databricks() or
            _is_nextjournal()
    ):
        return True  # complete HTML page in the output

    # if os.getenv("PLOTLY_RENDERER") == "colab":
    #     # good enough - something colab-like
    #     return True  # Colab -> iframe

    # try:
    #     shell = get_ipython().__class__.__name__
    #     if shell == 'ZMQInteractiveShell':
    #         return False  # Jupyter notebook or qtconsole  -> load JS librarty once per notebook
    #     elif shell == 'TerminalInteractiveShell':
    #         return True  # Terminal running IPython  -> an isolated HTML page to show somehow
    #     else:
    #         return True  # Other type (?)
    # except NameError:
    #     return True  # some other env (even standard Python interpreter) ->  an isolated HTML page to show somehow

    # Fallback to a complete HTML page in the output
    return True