Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove references to plotly.js CDN
Latest plotly.js used to be on a CDN, but it isn't anymore.
  • Loading branch information
marthacryan committed Sep 11, 2024
commit 08a175dbdb077f683b3ffe08aa83dbad70079147
7 changes: 0 additions & 7 deletions packages/python/plotly/plotly/io/_base_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from plotly import utils, optional_imports
from plotly.io import to_json, to_image, write_image, write_html
from plotly.io._orca import ensure_server
from plotly.io._utils import plotly_cdn_url
from plotly.offline.offline import _get_jconfig, get_plotlyjs
from plotly.tools import return_figure_from_figure_or_data

Expand Down Expand Up @@ -286,11 +285,6 @@ def activate(self):
{mathjax_config}
if (typeof require !== 'undefined') {{
require.undef("plotly");
requirejs.config({{
paths: {{
'plotly': ['{plotly_cdn}']
}}
}});
require(['plotly'], function(Plotly) {{
window._Plotly = Plotly;
}});
Expand All @@ -299,7 +293,6 @@ def activate(self):
""".format(
win_config=_window_plotly_config,
mathjax_config=_mathjax_config,
plotly_cdn=plotly_cdn_url().rstrip(".js"),
)

else:
Expand Down
5 changes: 2 additions & 3 deletions packages/python/plotly/plotly/io/_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import webbrowser

from _plotly_utils.optional_imports import get_module
from plotly.io._utils import validate_coerce_fig_to_dict, plotly_cdn_url
from plotly.io._utils import validate_coerce_fig_to_dict
from plotly.offline.offline import _get_jconfig, get_plotlyjs

_json = get_module("json")
Expand Down Expand Up @@ -270,9 +270,8 @@ def to_html(
elif include_plotlyjs == "cdn":
load_plotlyjs = """\
{win_config}
<script charset="utf-8" src="{cdn_url}"></script>\
""".format(
win_config=_window_plotly_config, cdn_url=plotly_cdn_url()
win_config=_window_plotly_config
)

elif include_plotlyjs == "directory":
Expand Down
7 changes: 0 additions & 7 deletions packages/python/plotly/plotly/io/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,3 @@ def validate_coerce_output_type(output_type):
Must be one of: 'Figure', 'FigureWidget'"""
)
return cls


def plotly_cdn_url(cdn_ver=get_plotlyjs_version()):
"""Return a valid plotly CDN url."""
return "https://cdn.plot.ly/plotly-{cdn_ver}.min.js".format(
cdn_ver=cdn_ver,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import plotly
import plotly.io as pio
from plotly.io._utils import plotly_cdn_url

packages_root = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(plotly.__file__))))
Expand All @@ -36,9 +35,6 @@
<script type="text/javascript">\
window.PlotlyConfig = {MathJaxConfig: 'local'};</script>"""

cdn_script = '<script charset="utf-8" src="{cdn_url}"></script>'.format(
cdn_url=plotly_cdn_url()
)

directory_script = '<script charset="utf-8" src="plotly.min.js"></script>'

Expand Down Expand Up @@ -124,7 +120,6 @@ def test_including_plotlyjs_truthy_html(self):

self.assertIn(plotly_config_script, html)
self.assertIn(PLOTLYJS, html)
self.assertNotIn(cdn_script, html)
self.assertNotIn(directory_script, html)

def test_including_plotlyjs_truthy_div(self):
Expand All @@ -137,7 +132,6 @@ def test_including_plotlyjs_truthy_div(self):

self.assertIn(plotly_config_script, html)
self.assertIn(PLOTLYJS, html)
self.assertNotIn(cdn_script, html)
self.assertNotIn(directory_script, html)

def test_including_plotlyjs_false_html(self):
Expand All @@ -156,7 +150,6 @@ def test_including_plotlyjs_false_html(self):

self.assertNotIn(plotly_config_script, html)
self.assertNotIn(PLOTLYJS, html)
self.assertNotIn(cdn_script, html)
self.assertNotIn(directory_script, html)

def test_including_plotlyjs_false_div(self):
Expand All @@ -166,7 +159,6 @@ def test_including_plotlyjs_false_div(self):
)
self.assertNotIn(plotly_config_script, html)
self.assertNotIn(PLOTLYJS, html)
self.assertNotIn(cdn_script, html)
self.assertNotIn(directory_script, html)

def test_including_plotlyjs_cdn_html(self):
Expand All @@ -182,7 +174,6 @@ def test_including_plotlyjs_cdn_html(self):
)
self.assertIn(plotly_config_script, html)
self.assertNotIn(PLOTLYJS, html)
self.assertIn(cdn_script, html)
self.assertNotIn(directory_script, html)

def test_including_plotlyjs_cdn_div(self):
Expand All @@ -192,7 +183,6 @@ def test_including_plotlyjs_cdn_div(self):
)
self.assertIn(plotly_config_script, html)
self.assertNotIn(PLOTLYJS, html)
self.assertIn(cdn_script, html)
self.assertNotIn(directory_script, html)

def test_including_plotlyjs_directory_html(self):
Expand All @@ -209,7 +199,6 @@ def test_including_plotlyjs_directory_html(self):
)
self.assertIn(plotly_config_script, html)
self.assertNotIn(PLOTLYJS, html)
self.assertNotIn(cdn_script, html)
self.assertIn(directory_script, html)

# plot creates plotly.min.js in the output directory
Expand All @@ -230,7 +219,6 @@ def test_including_plotlyjs_directory_div(self):

self.assertIn(plotly_config_script, html)
self.assertNotIn(PLOTLYJS, html)
self.assertNotIn(cdn_script, html)
self.assertIn(directory_script, html)

# plot does NOT create a plotly.min.js file in the output directory
Expand All @@ -257,7 +245,6 @@ def test_including_plotlyjs_path_html(self):
)
)
self.assertNotIn(PLOTLYJS, html)
self.assertNotIn(cdn_script, html)
self.assertNotIn(directory_script, html)
self.assertIn(include_plotlyjs, html)

Expand All @@ -275,7 +262,6 @@ def test_including_plotlyjs_path_div(self):
fig, include_plotlyjs=include_plotlyjs, output_type="div"
)
self.assertNotIn(PLOTLYJS, html)
self.assertNotIn(cdn_script, html)
self.assertNotIn(directory_script, html)
self.assertIn(include_plotlyjs, html)

Expand Down
5 changes: 0 additions & 5 deletions packages/python/plotly/plotly/tests/test_io/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import plotly.graph_objs as go
import plotly.io as pio
from plotly.io._utils import plotly_cdn_url


if sys.version_info >= (3, 3):
Expand Down Expand Up @@ -36,10 +35,6 @@ def fig1(request):
# ----


def test_versioned_cdn_included(fig1):
assert plotly_cdn_url() in pio.to_html(fig1, include_plotlyjs="cdn")


def test_html_deterministic(fig1):
div_id = "plotly-root"
assert pio.to_html(fig1, include_plotlyjs="cdn", div_id=div_id) == pio.to_html(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import plotly.graph_objs as go
import plotly.io as pio
from plotly.offline import get_plotlyjs
from plotly.io._utils import plotly_cdn_url

if sys.version_info >= (3, 3):
import unittest.mock as mock
Expand Down Expand Up @@ -137,10 +136,6 @@ def assert_not_full_html(html):
assert not html.startswith("<html")


def assert_html_renderer_connected(html):
assert plotly_cdn_url().rstrip(".js") in html


def assert_offline(html):
assert get_plotlyjs() in html

Expand Down Expand Up @@ -312,9 +307,7 @@ def test_repr_html(renderer):
template = (
'<div> <script type="text/javascript">'
"window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n "
'<script charset="utf-8" src="'
+ plotly_cdn_url()
+ '"></script> '
'<script charset="utf-8" src="' + '"></script> '
'<div id="cd462b94-79ce-42a2-887f-2650a761a144" class="plotly-graph-div" '
'style="height:100%; width:100%;"></div> <script type="text/javascript">'
" window.PLOTLYENV=window.PLOTLYENV || {};"
Expand Down