Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d91d2d5
Updating logging on full impressions queue
Mar 4, 2021
941c5e1
Merge pull request #220 from splitio/full_impressions_queue_log
mredolatti Mar 4, 2021
5756337
removed six
Apr 5, 2021
1ae4b26
updated travis
Apr 5, 2021
de1ada6
removed future
Apr 5, 2021
0d9fdc0
Merge pull request #222 from splitio/task/six
mmelograno Apr 6, 2021
2a385d2
more removals
Apr 6, 2021
8545f74
Merge branch 'task/deprecatePython2' of github.com:splitio/python-cli…
Apr 6, 2021
5ce20b3
fixed
Apr 7, 2021
3052e6a
Merge pull request #223 from splitio/task/future
mmelograno Apr 7, 2021
6e2b13a
Merge branch 'task/deprecatePython2' of github.com:splitio/python-cli…
Apr 7, 2021
8947da4
improvements
Apr 8, 2021
d23e979
encoding python3
Apr 8, 2021
89e6059
Merge pull request #224 from splitio/task/removingp2
mmelograno Apr 8, 2021
8a939e0
Merge branch 'task/deprecatePython2' of github.com:splitio/python-cli…
Apr 8, 2021
2173cc4
removed DS
Apr 8, 2021
6aa18c2
excluding DS_Store
Apr 8, 2021
4378b5b
Merge pull request #225 from splitio/task/stringsencoding
mmelograno Apr 9, 2021
0ad7b55
updated
Apr 12, 2021
919473e
preparing release 9.0.0
Apr 21, 2021
b82facd
merged with latest
Apr 21, 2021
190df93
Update README.md
sanzmauro Apr 26, 2021
8becd57
Merge pull request #228 from splitio/readme-dotnet
mmelograno Apr 27, 2021
9283a57
removing old uwsgi cache
Apr 27, 2021
7850aa6
preparing release
Apr 30, 2021
9bf392f
Merge pull request #229 from splitio/usgi/deprecation
mmelograno Apr 30, 2021
bd36f60
Merge pull request #226 from splitio/task/deprecatePython2
mmelograno Apr 30, 2021
b247840
added metadata into streaming client
Apr 30, 2021
b5553db
Merge branch 'development' of github.com:splitio/python-client into s…
Apr 30, 2021
d7b0cd8
Merge pull request #231 from splitio/sseHeaders
mmelograno Apr 30, 2021
6bdb1df
prep release
May 3, 2021
67ee291
Merge pull request #232 from splitio/sseHeaders
mmelograno May 3, 2021
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ target/

# vim backup files
*.swp

.DS_Store
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ git:

matrix:
include:
- python: '2.7'
- python: '3.6'
after_success:
- bash sonar-scanner.sh
Expand Down
9 changes: 9 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
9.0.0 (May 3, 2021)
- BREAKING CHANGE: Removed splitSdkMachineIp and splitSdkMachineName configs.
- BREAKING CHANGE: Deprecated `redisCharset` config.
- BREAKING CHANGE: Deprecated uWSGI local cache.
- BREAKING CHANGE: Deprecated Python2 support.
- Removed six, future and futures libs for compatibility between Python2 and Python3.
- Updated strings encoding to utf-8 by default for Redis.
- Added SDK Metadata headers to streaming client.

8.4.1 (Apr 16, 2021)
- Bumped mmh3cffi dependency which now requires c99 flag to build.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This SDK is designed to work with Split, the platform for controlled rollouts, w
[![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware)

## Compatibility
This SDK is compatible with **Python 2.7 and higher**.
This SDK is compatible with **Python 3 and higher**.

## Getting started
Below is a simple example that describes the instantiation and most basic usage of our SDK:
Expand Down Expand Up @@ -57,7 +57,7 @@ Split has built and maintains SDKs for:
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
* .NET [Github](https://github.com/splitio/.net-core-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This project provides Python programs access to the `Split.io <http://split.io/>
Installation and Requirements
-----------------------------

``splitio_client`` supports both Python 2 (2.7 or later) and Python 3 (3.3 or later). Stable versions can be installed from `PyPI <https://pypi.python.org>`_ using pip: ::
``splitio_client`` supports Python 3 (3.3 or later). Stable versions can be installed from `PyPI <https://pypi.python.org>`_ using pip: ::

pip install splitio_client

Expand Down
14 changes: 5 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
"""Setup module."""
#!/usr/bin/env python
# !/usr/bin/env python

from os import path
from setuptools import setup, find_packages

TESTS_REQUIRES = [
'flake8',
'pytest<=4.6', # for deprecated python versions: https://docs.pytest.org/en/latest/py27-py34-deprecation.html
'pytest-mock==2.0.0',
'pytest>=6.2.3',
'pytest-mock>=3.5.1',
'coverage',
'pytest-cov',
'mock;python_version<"3"'
]

INSTALL_REQUIRES = [
'requests>=2.9.1',
'pyyaml>=5.1',
'future>=0.15.2',
'docopt>=0.6.2',
'six>=1.10.0',
'enum34;python_version<"3.4"',
'futures>=3.0.5;python_version<"3"'
]

with open(path.join(path.abspath(path.dirname(__file__)), 'splitio', 'version.py')) as f:
exec(f.read()) # pylint: disable=exec-used

setup(
name='splitio_client',
version=__version__, # pylint: disable=undefined-variable
version=__version__, # pylint: disable=undefined-variable
description='Split.io Python Client',
author='Patricio Echague, Sebastian Arrubia',
author_email='pato@split.io, sebastian@split.io',
url='https://github.com/splitio/python-client',
download_url=('https://github.com/splitio/python-client/tarball/' + __version__), # pylint: disable=undefined-variable
download_url=('https://github.com/splitio/python-client/tarball/' + __version__), # pylint: disable=undefined-variable
license='Apache License 2.0',
install_requires=INSTALL_REQUIRES,
tests_require=TESTS_REQUIRES,
Expand Down
3 changes: 0 additions & 3 deletions splitio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import, division, print_function, \
unicode_literals

from splitio.client.factory import get_factory
from splitio.client.key import Key
from splitio.version import __version__
13 changes: 11 additions & 2 deletions splitio/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,29 @@ def status_code(self):
return self._status_code


def headers_from_metadata(sdk_metadata):
def headers_from_metadata(sdk_metadata, client_key=None):
"""
Generate a dict with headers required by data-recording API endpoints.

:param sdk_metadata: SDK Metadata object, generated at sdk initialization time.
:type sdk_metadata: splitio.client.util.SdkMetadata

:param client_key: client key.
:type client_key: str

:return: A dictionary with headers.
:rtype: dict
"""
return {

metadata = {
'SplitSDKVersion': sdk_metadata.sdk_version,
'SplitSDKMachineIP': sdk_metadata.instance_ip,
'SplitSDKMachineName': sdk_metadata.instance_name
} if sdk_metadata.instance_ip != 'NA' and sdk_metadata.instance_ip != 'unknown' else {
'SplitSDKVersion': sdk_metadata.sdk_version,
}

if client_key is not None:
metadata['SplitSDKClientKey'] = client_key

return metadata
4 changes: 1 addition & 3 deletions splitio/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import logging
import json

from future.utils import raise_from

from splitio.api import APIException, headers_from_metadata
from splitio.api.client import HttpClientException
from splitio.models.token import from_raw
Expand Down Expand Up @@ -53,4 +51,4 @@ def authenticate(self):
except HttpClientException as exc:
_LOGGER.error('Exception raised while authenticating')
_LOGGER.debug('Exception information: ', exc_info=True)
raise_from(APIException('Could not perform authentication.'), exc)
raise APIException('Could not perform authentication.') from exc
7 changes: 2 additions & 5 deletions splitio/api/client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Synchronous HTTP Client for split API."""
from __future__ import division

from collections import namedtuple

from future.utils import raise_from
import requests

HttpResponse = namedtuple('HttpResponse', ['status_code', 'body'])
Expand Down Expand Up @@ -107,7 +104,7 @@ def get(self, server, path, apikey, query=None, extra_headers=None): # pylint:
)
return HttpResponse(response.status_code, response.text)
except Exception as exc: # pylint: disable=broad-except
raise_from(HttpClientException('requests library is throwing exceptions'), exc)
raise HttpClientException('requests library is throwing exceptions') from exc

def post(self, server, path, apikey, body, query=None, extra_headers=None): # pylint: disable=too-many-arguments
"""
Expand Down Expand Up @@ -144,4 +141,4 @@ def post(self, server, path, apikey, body, query=None, extra_headers=None): # p
)
return HttpResponse(response.status_code, response.text)
except Exception as exc: # pylint: disable=broad-except
raise_from(HttpClientException('requests library is throwing exceptions'), exc)
raise HttpClientException('requests library is throwing exceptions') from exc
4 changes: 1 addition & 3 deletions splitio/api/events.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Events API module."""
import logging

from future.utils import raise_from

from splitio.api import APIException, headers_from_metadata
from splitio.api.client import HttpClientException

Expand Down Expand Up @@ -75,4 +73,4 @@ def flush_events(self, events):
except HttpClientException as exc:
_LOGGER.error('Error posting events because an exception was raised by the HTTPClient')
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Events not flushed properly.'), exc)
raise APIException('Events not flushed properly.') from exc
6 changes: 2 additions & 4 deletions splitio/api/impressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import logging
from itertools import groupby

from future.utils import raise_from

from splitio.api import APIException, headers_from_metadata
from splitio.api.client import HttpClientException
from splitio.engine.impressions import ImpressionsMode
Expand Down Expand Up @@ -107,7 +105,7 @@ def flush_impressions(self, impressions):
'Error posting impressions because an exception was raised by the HTTPClient'
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Impressions not flushed properly.'), exc)
raise APIException('Impressions not flushed properly.') from exc

def flush_counters(self, counters):
"""
Expand All @@ -133,4 +131,4 @@ def flush_counters(self, counters):
'HTTPClient'
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Impressions not flushed properly.'), exc)
raise APIException('Impressions not flushed properly.') from exc
4 changes: 1 addition & 3 deletions splitio/api/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import json
import logging

from future.utils import raise_from

from splitio.api import APIException, headers_from_metadata
from splitio.api.client import HttpClientException

Expand Down Expand Up @@ -62,4 +60,4 @@ def fetch_segment(self, segment_name, change_number):
segment_name
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Segments not fetched properly.'), exc)
raise APIException('Segments not fetched properly.') from exc
4 changes: 1 addition & 3 deletions splitio/api/splits.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import logging
import json

from future.utils import raise_from

from splitio.api import APIException, headers_from_metadata
from splitio.api.client import HttpClientException

Expand Down Expand Up @@ -55,4 +53,4 @@ def fetch_splits(self, change_number):
except HttpClientException as exc:
_LOGGER.error('Error fetching splits because an exception was raised by the HTTPClient')
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Splits not fetched correctly.'), exc)
raise APIException('Splits not fetched correctly.') from exc
15 changes: 6 additions & 9 deletions splitio/api/telemetry.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Telemetry API Module."""
import logging

import six
from future.utils import raise_from

from splitio.api import APIException, headers_from_metadata
from splitio.api.client import HttpClientException

Expand Down Expand Up @@ -39,7 +36,7 @@ def _build_latencies(latencies):
"""
return [
{'name': name, 'latencies': latencies_list}
for name, latencies_list in six.iteritems(latencies)
for name, latencies_list in latencies.items()
]

def flush_latencies(self, latencies):
Expand All @@ -65,7 +62,7 @@ def flush_latencies(self, latencies):
'Error posting latencies because an exception was raised by the HTTPClient'
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Latencies not flushed correctly.'), exc)
raise APIException('Latencies not flushed correctly.') from exc

@staticmethod
def _build_gauges(gauges):
Expand All @@ -77,7 +74,7 @@ def _build_gauges(gauges):
"""
return [
{'name': name, 'value': value}
for name, value in six.iteritems(gauges)
for name, value in gauges.items()
]

def flush_gauges(self, gauges):
Expand All @@ -103,7 +100,7 @@ def flush_gauges(self, gauges):
'Error posting gauges because an exception was raised by the HTTPClient'
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Gauges not flushed correctly.'), exc)
raise APIException('Gauges not flushed correctly.') from exc

@staticmethod
def _build_counters(counters):
Expand All @@ -115,7 +112,7 @@ def _build_counters(counters):
"""
return [
{'name': name, 'delta': value}
for name, value in six.iteritems(counters)
for name, value in counters.items()
]

def flush_counters(self, counters):
Expand All @@ -141,4 +138,4 @@ def flush_counters(self, counters):
'Error posting counters because an exception was raised by the HTTPClient'
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Counters not flushed correctly.'), exc)
raise APIException('Counters not flushed correctly.') from exc
6 changes: 1 addition & 5 deletions splitio/client/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"""A module for Split.io SDK API clients."""
from __future__ import absolute_import, division, print_function, \
unicode_literals

import logging
import time
import six
from splitio.engine.evaluator import Evaluator, CONTROL
from splitio.engine.splitters import Splitter
from splitio.models.impressions import Impression, Label
Expand Down Expand Up @@ -309,7 +305,7 @@ def get_treatments(self, key, features, attributes=None):
"""
with_config = self._make_evaluations(key, features, attributes, 'get_treatments',
self._METRIC_GET_TREATMENTS)
return {feature: result[0] for (feature, result) in six.iteritems(with_config)}
return {feature: result[0] for (feature, result) in with_config.items()}

def _build_impression( # pylint: disable=too-many-arguments
self,
Expand Down
10 changes: 1 addition & 9 deletions splitio/client/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Default settings for the Split.IO SDK Python client."""
from __future__ import absolute_import, division, print_function, unicode_literals

import os.path
import logging

Expand All @@ -13,8 +11,6 @@
DEFAULT_CONFIG = {
'operationMode': 'in-memory',
'connectionTimeout': 1500,
'splitSdkMachineName': None,
'splitSdkMachineIp': None,
'streamingEnabled': True,
'featuresRefreshRate': 30,
'segmentsRefreshRate': 30,
Expand Down Expand Up @@ -43,9 +39,8 @@
'redisUnixSocketPath': None,
'redisEncoding': 'utf-8',
'redisEncodingErrors': 'strict',
'redisCharset': None,
'redisErrors': None,
'redisDecodeResponses': False,
'redisDecodeResponses': True,
'redisRetryOnTimeout': False,
'redisSsl': False,
'redisSslKeyfile': None,
Expand Down Expand Up @@ -76,9 +71,6 @@ def _parse_operation_mode(apikey, config):
if 'redisHost' in config or 'redisSentinels' in config:
return 'redis-consumer'

if 'uwsgiClient' in config:
return 'uwsgi-consumer'

return 'inmemory-standalone'


Expand Down
Loading