https://github.com/splitio/wrapped-python
https://github.com/splitio/wrapped-python
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/splitio/wrapped-python
- Owner: splitio
- Created: 2021-12-14T14:45:23.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-17T16:34:48.000Z (about 4 years ago)
- Last Synced: 2024-12-21T14:38:32.383Z (about 1 year ago)
- Language: Python
- Size: 11.7 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wrapped-python
## Compatibility
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:
Run `pip install splitio_client>=9.1.1`
```python
from splitio_wrapper import get_factory
from splitio.exceptions import TimeoutException
factory = get_factory('YOUR_SDK_TYPE_API_KEY', config=config)
try:
factory.block_until_ready(5) # wait up to 5 seconds
split = factory.client()
treatment = split.get_treatment('CUSTOMER_ID', 'SPLIT_NAME')
if treatment == "on":
# insert code here to show on treatment
elif treatment == "off":
# insert code here to show off treatment
else:
# insert your control treatment code here
except TimeoutException:
# Now the user can choose whether to abort the whole execution, or just keep going
# without a ready client, which if configured properly, should become ready at some point.
pass
```
If you want to bypass evaluations you can call the method `disable_evaluations()` and you can turn it back by calling `enabling_evaluations()`
```python
split.disable_evaluations() # After disabling, everything will return Control
split.enable_evaluations() # After enabling, all the logic will be done again to evaluate features
```
```python
from splitio_wrapper import get_factory
factory = get_factory('YOUR_SDK_TYPE_API_KEY', config=config)
split = factory.client()
split.disable_evaluations() if disable_redis else split.enable_evaluations()
```