Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
10 changes: 10 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
9.0.0 (Apr 30, 2021)
- BREAKING CHANGE: Removed splitSdkMachineIp and splitSdkMachineName configs.
- 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.

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

8.4.0 (Jan 6, 2021)
- Added RecordStats for supporting pipelined recording in redis when treatment call is made.
- Added hooks support for preforked servers.
Expand Down
2 changes: 1 addition & 1 deletion 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
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
16 changes: 6 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,43 @@
"""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,
extras_require={
'test': TESTS_REQUIRES,
'redis': ['redis>=2.10.5'],
'uwsgi': ['uwsgi>=2.0.0'],
'cpphash': ['mmh3cffi==0.2.0'],
'cpphash': ['mmh3cffi==0.2.1'],
},
setup_requires=['pytest-runner'],
classifiers=[
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__
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
11 changes: 2 additions & 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,9 @@
'redisUnixSocketPath': None,
'redisEncoding': 'utf-8',
'redisEncodingErrors': 'strict',
'redisCharset': None,
'redisCharset': 'utf-8',
'redisErrors': None,
'redisDecodeResponses': False,
'redisDecodeResponses': True,
'redisRetryOnTimeout': False,
'redisSsl': False,
'redisSslKeyfile': None,
Expand Down Expand Up @@ -76,9 +72,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