Skip to content

Commit

Permalink
Only send the stable portion of the version in plot.ly requests
Browse files Browse the repository at this point in the history
Addresses #1044
  • Loading branch information
jonmmease committed Jul 3, 2018
1 parent 40b31cf commit 7793c8f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plotly/api/v1/clientresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def clientresp(data, **kwargs):
dumps_kwargs = {'sort_keys': True, 'cls': utils.PlotlyJSONEncoder}

payload = {
'platform': 'python', 'version': version.__version__,
'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)
Expand Down
2 changes: 1 addition & 1 deletion plotly/api/v2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_headers():
creds = config.get_credentials()

headers = {
'plotly-client-platform': 'python {}'.format(version.__version__),
'plotly-client-platform': 'python {}'.format(version.stable_semver()),
'content-type': 'application/json'
}

Expand Down
4 changes: 2 additions & 2 deletions plotly/tests/test_core/test_api/test_v1/test_clientresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_data_only(self):
expected_data = ({
'origin': 'plot',
'args': '[{"name": "what else floats?", "y": [3, 5]}]',
'platform': 'python', 'version': version.__version__, 'key': 'bar',
'platform': 'python', 'version': version.stable_semver(), 'key': 'bar',
'kwargs': '{}', 'un': 'foo'
})
self.assertEqual(kwargs['data'], expected_data)
Expand All @@ -53,7 +53,7 @@ def test_data_and_kwargs(self):
expected_data = ({
'origin': 'plot',
'args': '[{"name": "what else floats?", "y": [3, 5]}]',
'platform': 'python', 'version': version.__version__, 'key': 'bar',
'platform': 'python', 'version': version.stable_semver(), 'key': 'bar',
'kwargs': '{"filename": "ok", "layout": {"title": "mah plot"}}',
'un': 'foo'
})
Expand Down
4 changes: 2 additions & 2 deletions plotly/tests/test_core/test_api/test_v2/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class GetHeadersTest(PlotlyApiTestCase):
def test_normal_auth(self):
headers = utils.get_headers()
expected_headers = {
'plotly-client-platform': 'python {}'.format(version.__version__),
'plotly-client-platform': 'python {}'.format(version.stable_semver()),
'authorization': 'Basic Zm9vOmJhcg==',
'content-type': 'application/json'
}
Expand All @@ -177,7 +177,7 @@ def test_proxy_auth(self):
sign_in(self.username, self.api_key, plotly_proxy_authorization=True)
headers = utils.get_headers()
expected_headers = {
'plotly-client-platform': 'python {}'.format(version.__version__),
'plotly-client-platform': 'python {}'.format(version.stable_semver()),
'authorization': 'Basic Y25ldDpob29wbGE=',
'plotly-authorization': 'Basic Zm9vOmJhcg==',
'content-type': 'application/json'
Expand Down
11 changes: 11 additions & 0 deletions plotly/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
__version__ = '3.0.0-rc.11'
__frontend_version__ = '^0.1.1'


def stable_semver():
"""
Get the stable portion of the semantic version string (the first three
numbers), without any of the trailing labels
'3.0.0-rc.11' -> '3.0.0'
"""

return __version__.split('-')[0]

0 comments on commit 7793c8f

Please sign in to comment.