You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: openfeature-provider/python/README.md
+193-9Lines changed: 193 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,34 +1,121 @@
1
1
# Confidence OpenFeature Provider for Python
2
2
3
-
This is the Python OpenFeature provider for [Confidence](https://confidence.spotify.com/) feature flags. It uses a WebAssembly-based local resolver for low-latency flag evaluation.
A high-performance OpenFeature provider for [Confidence](https://confidence.spotify.com/) feature flags that evaluates flags locally for minimal latency.
6
+
7
+
## Features
8
+
9
+
-**Local Resolution**: Evaluates feature flags locally using WebAssembly (WASM)
10
+
-**Low Latency**: No network calls during flag evaluation
11
+
-**Automatic Sync**: Periodically syncs flag configurations from Confidence
12
+
-**Exposure Logging**: Fully supported exposure logging (and other resolve analytics)
13
+
-**OpenFeature Compatible**: Works with the standard OpenFeature SDK
14
+
15
+
## Requirements
16
+
17
+
- Python 3.9+
18
+
- OpenFeature SDK 0.8.0+
4
19
5
20
## Installation
6
21
7
22
```bash
8
23
pip install confidence-openfeature-provider
9
24
```
10
25
11
-
## Usage
26
+
## Getting Your Credentials
27
+
28
+
You'll need a **client secret** from Confidence to use this provider.
29
+
30
+
**📖 See the [Integration Guide: Getting Your Credentials](../INTEGRATION_GUIDE.md#getting-your-credentials)** for step-by-step instructions on:
31
+
- How to navigate the Confidence dashboard
32
+
- Creating a Backend integration
33
+
- Creating a test flag for verification
34
+
- Best practices for credential storage
35
+
36
+
## Quick Start
12
37
13
38
```python
14
39
from openfeature import api
40
+
from openfeature.evaluation_context import EvaluationContext
-`client_secret` (str, required): The Confidence client secret for authentication.
133
+
-`state_poll_interval` (float, optional): Interval in seconds between state polling updates. Defaults to 30.0.
134
+
-`log_poll_interval` (float, optional): Interval in seconds for sending evaluation logs. Defaults to 10.0.
135
+
-`use_remote_materialization_store` (bool, optional): Enable remote materialization storage. Defaults to False.
136
+
137
+
## Materializations
138
+
139
+
The provider supports **materializations** for two key use cases:
140
+
141
+
1.**Sticky Assignments**: Maintain consistent variant assignments across evaluations even when targeting attributes change.
142
+
2.**Custom Targeting via Materialized Segments**: Efficiently target precomputed sets of identifiers from datasets.
143
+
144
+
### Default Behavior
145
+
146
+
By default, materializations are not supported. If a flag requires materialization data, the evaluation will return the default value.
147
+
148
+
### Remote Materialization Store
149
+
150
+
Enable remote materialization storage to have Confidence manage materialization data server-side:
151
+
152
+
```python
153
+
provider = ConfidenceProvider(
154
+
client_secret="your-client-secret",
155
+
use_remote_materialization_store=True,
156
+
)
157
+
```
158
+
159
+
**⚠️ Important Performance Impact**: This option adds network calls during flag evaluation for materialization reads/writes.
160
+
161
+
### Custom Materialization Store
162
+
163
+
For advanced use cases, you can implement the `MaterializationStore` protocol to manage materialization data in your own infrastructure. The protocol defines two methods:
164
+
165
+
-`read(ops: List[ReadOp]) -> List[ReadResult]`: Batch read of materialization data
166
+
-`write(ops: List[VariantWriteOp]) -> None`: Batch write of variant assignments
167
+
168
+
The read operations support two types:
169
+
170
+
-**VariantReadOp**: Query for a sticky variant assignment (returns `VariantReadResult`)
171
+
-**InclusionReadOp**: Query for segment inclusion (returns `InclusionReadResult`)
172
+
173
+
```python
174
+
from confidence.materialization import (
175
+
MaterializationStore,
176
+
ReadOp,
177
+
ReadResult,
178
+
VariantReadOp,
179
+
VariantReadResult,
180
+
InclusionReadOp,
181
+
InclusionReadResult,
182
+
VariantWriteOp,
183
+
)
184
+
185
+
classMyMaterializationStore:
186
+
"""Custom materialization store implementation."""
0 commit comments