-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathclientresp.py
48 lines (33 loc) · 1.36 KB
/
clientresp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Interface to deprecated /clientresp API. Subject to deletion."""
from __future__ import absolute_import
import warnings
import json as _json
from _plotly_utils.utils import PlotlyJSONEncoder
from chart_studio import config, utils
from chart_studio.api.v1.utils import request
def clientresp(data, **kwargs):
"""
Deprecated endpoint, still used because it can parse data out of a plot.
When we get around to forcing users to create grids and then create plots,
we can finally get rid of this.
:param (list) data: The data array from a figure.
"""
from plotly import version
creds = config.get_credentials()
cfg = config.get_config()
dumps_kwargs = {'sort_keys': True, 'cls': PlotlyJSONEncoder}
payload = {
'platform': 'python', 'version': version.stable_semver(),
'args': _json.dumps(data, **dumps_kwargs),
'un': creds['username'], 'key': creds['api_key'], 'origin': 'plot',
'kwargs': _json.dumps(kwargs, **dumps_kwargs)
}
url = '{plotly_domain}/clientresp'.format(**cfg)
response = request('post', url, data=payload)
# Old functionality, just keeping it around.
parsed_content = response.json()
if parsed_content.get('warning'):
warnings.warn(parsed_content['warning'])
if parsed_content.get('message'):
print(parsed_content['message'])
return response