Skip to content

Commit 6754e5f

Browse files
authored
Merge pull request #7 from splitio/development
Release 1.0.0
2 parents 9f30606 + e504dfe commit 6754e5f

17 files changed

+932
-164
lines changed

.coveragerc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[run]
2+
source =
3+
splitio/
4+
5+
omit =
6+
tests/*
7+
*/__init__.py
8+
9+
branch = True
10+
11+
relative_files = True
12+
13+
[report]
14+
# Regexes for lines to exclude from consideration
15+
exclude_lines =
16+
# Have to re-enable the standard pragma
17+
pragma: no cover
18+
19+
# Don't complain about missing debug-only code:
20+
def __repr__
21+
if self\.debug
22+
23+
# Don't complain if tests don't hit defensive assertion code:
24+
raise AssertionError
25+
raise NotImplementedError
26+
27+
# Don't complain if non-runnable code isn't run:
28+
if 0:
29+
if __name__ == .__main__.:
30+
31+
precision = 2

.github/workflows/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @splitio/sdk

.github/workflows/ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- development
7+
pull_request:
8+
branches:
9+
- main
10+
- development
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test:
18+
name: Test
19+
runs-on: ubuntu-22.04
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup Python
27+
uses: actions/setup-python@v3
28+
with:
29+
python-version: '3.9.13'
30+
31+
- name: Install dependencies
32+
run: |
33+
sudo apt update
34+
sudo apt-get install -y libkrb5-dev
35+
pip install -U setuptools pip wheel
36+
pip install -e .[cpphash,redis,uwsgi]
37+
pip install pytest --quiet
38+
pip install mock
39+
pip install pytest-asyncio
40+
pip install -r requirements.txt
41+
42+
- name: Run tests
43+
run: cd tests; pytest -v
44+
45+
- name: Set VERSION env
46+
run: echo "VERSION=$(cat setup.py | grep "version=" | cut -d'"' -f2)" >> $GITHUB_ENV
47+
48+
- name: SonarQube Scan (Push)
49+
if: github.event_name == 'push'
50+
uses: SonarSource/sonarcloud-github-action@v1.9
51+
env:
52+
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
projectBaseDir: .
56+
args: >
57+
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
58+
-Dsonar.projectVersion=${{ env.VERSION }}
59+
60+
- name: SonarQube Scan (Pull Request)
61+
if: github.event_name == 'pull_request'
62+
uses: SonarSource/sonarcloud-github-action@v1.9
63+
env:
64+
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
projectBaseDir: .
68+
args: >
69+
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
70+
-Dsonar.projectVersion=${{ env.VERSION }}
71+
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
72+
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
73+
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ dmypy.json
130130

131131
# IDE
132132
.idea/
133+
134+
# Other
135+
.DS_Store

CHANGES.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
0.0.1
2-
- First release. Up to date with spec 0.5.1 and python sdk 0.0.6
1+
Changes
2+
3+
1.0.0 (Nov 5 2026)
4+
- BREAKING CHANGE: Passing the SplitClient object to Provider constructor is now only through the initialization context dictionary
5+
- BREAKING CHANGE: Provider will throw exception when ObjectDetail and ObjectValue evaluation is used, since it will attempt to parse the treatment as a JSON structure.
6+
- Upgraded Split SDK to 10.5.1
7+
- Upgraded OpenFeature SDK to 0.8.3
8+
- Added support for asyncio mode
9+
- Added ability to pass Ready Timeout and ConfigurationOptions to Provider initialization
10+
311
0.1.0
412
- Up to date with spec 0.8.0 and python sdk 0.8.1. Using split client 10.2.0
13+
14+
0.0.1
15+
- First release. Up to date with spec 0.5.1 and python sdk 0.0.6

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright © 2022 Split Software, Inc.
1+
Copyright © 2025 Split Software, Inc.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

README.md

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
This Provider is designed to allow the use of OpenFeature with Split, the platform for controlled rollouts, serving features to your users via the Split feature flag to manage your complete customer experience.
66

77
## Compatibility
8-
This SDK is compatible with Python 3 and higher.
8+
This SDK is compatible with Python 3.9 and higher.
99

1010
## Getting started
1111
### Pip Installation
@@ -18,21 +18,28 @@ Below is a simple example that describes using the Split Provider. Please see th
1818
```python
1919
from openfeature import api
2020
from split_openfeature import SplitProvider
21-
22-
api.set_provider(SplitProvider(api_key="YOUR_API_KEY"))
21+
config = {
22+
'impressionsMode': 'OPTIMIZED',
23+
'impressionsRefreshRate': 30,
24+
}
25+
provider = SplitProvider({"SdkKey": "YOUR_API_KEY", "ConfigOptions": config, "ReadyBlockTime": 5})
26+
api.set_provider(provider)
2327
```
2428

25-
If you are more familiar with Split or want access to other initialization options, you can provide a Split `client` to the constructor. See the [Split Java SDK Documentation](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK) for more information.
29+
If you are more familiar with Split or want access to other initialization options, you can provide a Split `client` to the constructor. See the [Harness Split Python SDK Documentation](https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/server-side-sdks/python-sdk/) for more information.
2630
```python
2731
from openfeature import api
2832
from split_openfeature import SplitProvider
2933
from splitio import get_factory
3034

31-
factory = get_factory("YOUR_API_KEY", config=config_file)
35+
config = {
36+
'impressionsMode': 'OPTIMIZED',
37+
'impressionsRefreshRate': 30,
38+
}
39+
factory = get_factory("YOUR_API_KEY", config=config)
3240
factory.block_until_ready(5)
33-
api.set_provider(SplitProvider(client=factory.client()))
41+
api.set_provider(SplitProvider({"SplitClient": factory.client()}))
3442
```
35-
where config_file is the Split config file you want to use
3643

3744
## Use of OpenFeature with Split
3845
After the initial setup you can use OpenFeature according to their [documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api/).
@@ -56,9 +63,76 @@ or at the OpenFeatureAPI level
5663
```python
5764
context = EvaluationContext(targeting_key="TARGETING_KEY")
5865
api.set_evaluation_context(context)
59-
````
66+
```
6067
If the context was set at the client or api level, it is not required to provide it during flag evaluation.
6168

69+
### Asyncio mode
70+
The provider supports asyncio mode as well, using the asyncio mode in Split SDK.
71+
Example below shows using the provider in asyncio
72+
73+
```python
74+
from openfeature import api
75+
from split_openfeature import SplitProviderAsync
76+
config = {
77+
'impressionsMode': 'OPTIMIZED',
78+
'impressionsRefreshRate': 30,
79+
}
80+
provider = SplitProvider({"SdkKey": "YOUR_API_KEY", "ConfigOptions": config, "ReadyBlockTime": 5})
81+
await provider.create()
82+
api.set_provider(provider)
83+
```
84+
85+
Example below show how to create the Split Client externally and pass it to Provider
86+
```python
87+
from openfeature import api
88+
from split_openfeature import SplitProviderAsync
89+
from splitio import get_factory_async
90+
91+
config = {
92+
'impressionsMode': 'OPTIMIZED',
93+
'impressionsRefreshRate': 30,
94+
}
95+
factory = get_factory_async("YOUR_API_KEY", config=config)
96+
await factory.block_until_ready(5)
97+
provider = SplitProviderAsync({"SplitClient": factory.client()})
98+
await provider.create()
99+
api.set_provider(provider)
100+
```
101+
102+
Example below fetching the treatment in asyncio mode
103+
```python
104+
from openfeature import api
105+
from openfeature.evaluation_context import EvaluationContext
106+
107+
client = api.get_client("CLIENT_NAME")
108+
109+
context = EvaluationContext(targeting_key="TARGETING_KEY")
110+
value = await client.get_boolean_value_async("FLAG_NAME", False, context)
111+
```
112+
### Logging
113+
Split Provider use `logging` library, Each module has it's own logger, the root being split_provider. Below is an example of simple usage which will set all libraries using `logging` including the provider, to use `DEBUG` mode.
114+
```python
115+
import logging
116+
117+
logging.basicConfig(level=logging.DEBUG)
118+
```
119+
120+
### Shutting down Split SDK factory
121+
Currently OpenFeature SDK does not provide override for provider shutdown, when using internal split client object, the Split SDK will not shutdown properly. We recommend using the example below before terminating the OpenFeature object
122+
123+
```python
124+
from threading import Event
125+
126+
destroy_event = Event()
127+
provider._split_client_wrapper._factory.destroy(destroy_event)
128+
destroy_event.wait()
129+
```
130+
131+
Below the example for asyncio mode
132+
```python
133+
await provider._split_client_wrapper._factory.destroy()
134+
```
135+
62136
## Submitting issues
63137

64138
The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/split-openfeature-provider-python/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
openfeature_sdk==0.8.1
2-
splitio_client==10.2.0
1+
openfeature_sdk==0.8.3
2+
splitio_client[cpphash,asyncio]==10.5.1

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
setuptools.setup(
77
name="split_openfeature",
8-
version="0.1.0",
9-
author="Robert Grassian",
10-
author_email="robert.grassian@split.io",
8+
version="1.0.0",
119
description="The official Python Split Provider for OpenFeature",
1210
long_description=long_description,
1311
long_description_content_type="text/markdown",
@@ -17,5 +15,5 @@
1715
"Programming Language :: Python :: 3",
1816
'Topic :: Software Development :: Libraries'
1917
],
20-
python_requires='>=3.5'
18+
python_requires='>=3.9'
2119
)

sonar-project.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sonar.projectName=split_openfeature
2+
sonar.projectKey=split_openfeature
3+
sonar.python.version=3.9
4+
sonar.sources=split_openfeature
5+
sonar.tests=tests
6+
sonar.text.excluded.file.suffixes=.csv
7+
sonar.python.coverage.reportPaths=coverage.xml
8+
sonar.coverage.exclusions=**/__init__.py
9+
sonar.links.ci=https://github.com/splitio/split-openfeature-provider-python
10+
sonar.links.scm=https://github.com/splitio/split-openfeature-provider-python/actions

0 commit comments

Comments
 (0)