Is it possible to get Plotly (used from within Python) to be "strictly local"? In other words, is it possible to use it in a way that guarantees it won't contact the network for any reason?
This includes things like the program trying to contact the Plotly service (since that was the business model), and also things like ensuring clicking anywhere in the generated html won't either have a link to Plotly or anywhere else.
Of course, I'd like to be able to do this on a production machine connected to the network, so pulling out the network connection is not an option.
Even a simple import plotly
already attempts to connect to the network as this example shows:
import logging
logging.basicConfig(level=logging.INFO)
import plotly
The output is:
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.plot.ly
The connection is made when the get_graph_reference() function is called while the graph_reference module is initialized.
One way to avoid connecting to plot.ly servers is to set an invalid plotly_api_domain
in ~/.plotly/.config
. For me, this is not an option as the software is run on the client’s machine and I do not want to modify their configuration file. Additionally, it is also not yet possible to change the configuration directory through an environment variable.
One work-around is to monkey-patch requests.get
before importing plotly:
import requests
import inspect
original_get = requests.get
def plotly_no_get(*args, **kwargs):
one_frame_up = inspect.stack()[1]
if one_frame_up[3] == 'get_graph_reference':
raise requests.exceptions.RequestException
return original_get(*args, **kwargs)
requests.get = plotly_no_get
import plotly
This is surely not a full solution but, if nothing else, this shows that plot.ly is currently not meant to be run completely offline.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With