fb-python-sdk 1.1.4__tar.gz → 1.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fb_python_sdk-1.1.6/MANIFEST.in +4 -0
- {fb-python-sdk-1.1.4/fb_python_sdk.egg-info → fb_python_sdk-1.1.6}/PKG-INFO +33 -11
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/README.md +15 -8
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6/fb_python_sdk.egg-info}/PKG-INFO +33 -11
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fb_python_sdk.egg-info/SOURCES.txt +1 -5
- fb_python_sdk-1.1.6/fb_python_sdk.egg-info/top_level.txt +2 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/client.py +2 -2
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/common_types.py +18 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/flag_change_notification.py +15 -14
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/utils/rwlock.py +1 -1
- fb_python_sdk-1.1.6/release/package.json +3 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/setup.py +6 -6
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/tests/test_fbclient.py +15 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/tests/test_flag_change_notification.py +5 -0
- fb-python-sdk-1.1.4/MANIFEST.in +0 -3
- fb-python-sdk-1.1.4/fb_python_sdk.egg-info/top_level.txt +0 -3
- fb-python-sdk-1.1.4/fbclient/version.py +0 -1
- fb-python-sdk-1.1.4/intergration_tests/readme.py +0 -25
- fb-python-sdk-1.1.4/intergration_tests/run_in_start_no_wait.py +0 -36
- fb-python-sdk-1.1.4/intergration_tests/run_in_start_wait.py +0 -50
- fb-python-sdk-1.1.4/tests/__init__.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/LICENSE +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/dev-requirements.txt +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fb_python_sdk.egg-info/dependency_links.txt +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fb_python_sdk.egg-info/requires.txt +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/__init__.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/category.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/config.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/data_storage.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/evaluator.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/event_processor.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/event_types.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/interfaces.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/notice_broadcaster.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/status.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/status_types.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/streaming.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/update_processor.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/utils/__init__.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/utils/exponential_backoff_jitter_strategy.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/utils/http_client.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/utils/repeatable_task.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/utils/variation_splitting_algorithm.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/pyproject.toml +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/requirements.txt +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/setup.cfg +0 -0
- {fb-python-sdk-1.1.4/intergration_tests → fb_python_sdk-1.1.6/tests}/__init__.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/tests/test_data_storage.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/tests/test_data_update_status_provider.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/tests/test_evaluator.py +0 -0
- {fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/tests/test_event_processor.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fb-python-sdk
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.6
|
|
4
4
|
Summary: A Python SDK for FeatBit plateform
|
|
5
5
|
Home-page: https://github.com/featbit/featbit-python-sdk
|
|
6
6
|
Author: Dian SUN
|
|
@@ -19,10 +19,25 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Requires-Python: >=3.6, <=3.12
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
24
|
-
Provides-Extra: dev
|
|
25
25
|
License-File: LICENSE
|
|
26
|
+
Requires-Dist: certifi>=2018.4.16
|
|
27
|
+
Requires-Dist: urllib3>=1.22.0
|
|
28
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
29
|
+
Requires-Dist: websocket-client>=1.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: certifi>=2018.4.16; extra == "dev"
|
|
32
|
+
Requires-Dist: urllib3>=1.22.0; extra == "dev"
|
|
33
|
+
Requires-Dist: websocket-client>=1.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: python-dateutil>=2.8.2; extra == "dev"
|
|
35
|
+
Requires-Dist: flake8; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
38
|
+
Requires-Dist: autopep8; extra == "dev"
|
|
39
|
+
Requires-Dist: build; extra == "dev"
|
|
40
|
+
Requires-Dist: twine; extra == "dev"
|
|
26
41
|
|
|
27
42
|
# FeatBit Server-Side SDK for Python
|
|
28
43
|
|
|
@@ -56,8 +71,8 @@ Before using the SDK, you need to obtain the environment secret and SDK URLs.
|
|
|
56
71
|
|
|
57
72
|
Follow the documentation below to retrieve these values
|
|
58
73
|
|
|
59
|
-
- [How to get the environment secret](https://docs.featbit.co/
|
|
60
|
-
- [How to get the SDK URLs](https://docs.featbit.co/
|
|
74
|
+
- [How to get the environment secret](https://docs.featbit.co/sdk/faq#how-to-get-the-environment-secret)
|
|
75
|
+
- [How to get the SDK URLs](https://docs.featbit.co/sdk/faq#how-to-get-the-sdk-urls)
|
|
61
76
|
|
|
62
77
|
### Quick Start
|
|
63
78
|
|
|
@@ -170,10 +185,17 @@ If you would like to get variations of all feature flags in a special environmen
|
|
|
170
185
|
if client.initialize:
|
|
171
186
|
user = {'key': user_key, 'name': user_name}
|
|
172
187
|
all_flag_values = client.get_all_latest_flag_variations(user)
|
|
173
|
-
|
|
188
|
+
# get all feature flag keys
|
|
189
|
+
keys = all_flag_values.keys()
|
|
190
|
+
for flag_key in keys:
|
|
191
|
+
# get viariation detail
|
|
192
|
+
detail = all_flag_values.get(flag_key, default=None)
|
|
193
|
+
# get viariation
|
|
194
|
+
value = all_flag_values.get_variation(flag_key, default=None)
|
|
174
195
|
```
|
|
175
196
|
|
|
176
|
-
> Note
|
|
197
|
+
> **Note**
|
|
198
|
+
> If evaluation happened before the client is initialized, or you provide the wrong flag key/user for evaluation, the `variation` calls will return the default value. The `fbclient.common_types.EvalDetail` will explain the details of the latest evaluation including error reason.
|
|
177
199
|
|
|
178
200
|
### Flag Tracking
|
|
179
201
|
|
|
@@ -184,7 +206,7 @@ Note that a flag value change listener is bound to a specific user and flag key.
|
|
|
184
206
|
The flag value change listener will be notified whenever the SDK receives any change to any feature flag's configuration,
|
|
185
207
|
or to a user segment that is referenced by a feature flag. To register a flag value change listener, use `add_flag_value_may_changed_listener` or `add_flag_value_changed_listener`
|
|
186
208
|
|
|
187
|
-
When you track a flag change using `
|
|
209
|
+
When you track a flag change using `add_flag_value_maybe_changed_listener`, this does not necessarily mean the flag's value has changed for any particular flag, only that some part of the flag configuration was changed so that it *_MAY_* return a different value than it previously returned for some user.
|
|
188
210
|
|
|
189
211
|
If you want to track a flag whose value *_MUST_* be changed, `add_flag_value_changed_listener` will register a listener that will be notified if and only if the flag value changes.
|
|
190
212
|
|
|
@@ -194,9 +216,9 @@ If the SDK is in offline mode, then it cannot know when there is a change, becau
|
|
|
194
216
|
```python
|
|
195
217
|
if client.initialize:
|
|
196
218
|
# flag value may be changed
|
|
197
|
-
client.flag_tracker.
|
|
219
|
+
client.flag_tracker.add_flag_value_maybe_changed_listener(flag_key, user, flag_value_maybe_changed_callback_fn)
|
|
198
220
|
# flag value must be changed
|
|
199
|
-
client.flag_tracker.add_flag_value_changed_listener(flag_key, user,
|
|
221
|
+
client.flag_tracker.add_flag_value_changed_listener(flag_key, user, flag_value_changed_callback_fn)
|
|
200
222
|
|
|
201
223
|
```
|
|
202
224
|
`flag_key`: the key of the feature flag to track
|
|
@@ -254,4 +276,4 @@ otherwise, the custom event may not be included into the experiment result.
|
|
|
254
276
|
feature, [submit an issue](https://github.com/featbit/featbit-python-sdk/issues/new).
|
|
255
277
|
|
|
256
278
|
## See Also
|
|
257
|
-
- [Connect To Python Sdk](https://docs.featbit.co/
|
|
279
|
+
- [Connect To Python Sdk](https://docs.featbit.co/sdk/overview#python)
|
|
@@ -30,8 +30,8 @@ Before using the SDK, you need to obtain the environment secret and SDK URLs.
|
|
|
30
30
|
|
|
31
31
|
Follow the documentation below to retrieve these values
|
|
32
32
|
|
|
33
|
-
- [How to get the environment secret](https://docs.featbit.co/
|
|
34
|
-
- [How to get the SDK URLs](https://docs.featbit.co/
|
|
33
|
+
- [How to get the environment secret](https://docs.featbit.co/sdk/faq#how-to-get-the-environment-secret)
|
|
34
|
+
- [How to get the SDK URLs](https://docs.featbit.co/sdk/faq#how-to-get-the-sdk-urls)
|
|
35
35
|
|
|
36
36
|
### Quick Start
|
|
37
37
|
|
|
@@ -144,10 +144,17 @@ If you would like to get variations of all feature flags in a special environmen
|
|
|
144
144
|
if client.initialize:
|
|
145
145
|
user = {'key': user_key, 'name': user_name}
|
|
146
146
|
all_flag_values = client.get_all_latest_flag_variations(user)
|
|
147
|
-
|
|
147
|
+
# get all feature flag keys
|
|
148
|
+
keys = all_flag_values.keys()
|
|
149
|
+
for flag_key in keys:
|
|
150
|
+
# get viariation detail
|
|
151
|
+
detail = all_flag_values.get(flag_key, default=None)
|
|
152
|
+
# get viariation
|
|
153
|
+
value = all_flag_values.get_variation(flag_key, default=None)
|
|
148
154
|
```
|
|
149
155
|
|
|
150
|
-
> Note
|
|
156
|
+
> **Note**
|
|
157
|
+
> If evaluation happened before the client is initialized, or you provide the wrong flag key/user for evaluation, the `variation` calls will return the default value. The `fbclient.common_types.EvalDetail` will explain the details of the latest evaluation including error reason.
|
|
151
158
|
|
|
152
159
|
### Flag Tracking
|
|
153
160
|
|
|
@@ -158,7 +165,7 @@ Note that a flag value change listener is bound to a specific user and flag key.
|
|
|
158
165
|
The flag value change listener will be notified whenever the SDK receives any change to any feature flag's configuration,
|
|
159
166
|
or to a user segment that is referenced by a feature flag. To register a flag value change listener, use `add_flag_value_may_changed_listener` or `add_flag_value_changed_listener`
|
|
160
167
|
|
|
161
|
-
When you track a flag change using `
|
|
168
|
+
When you track a flag change using `add_flag_value_maybe_changed_listener`, this does not necessarily mean the flag's value has changed for any particular flag, only that some part of the flag configuration was changed so that it *_MAY_* return a different value than it previously returned for some user.
|
|
162
169
|
|
|
163
170
|
If you want to track a flag whose value *_MUST_* be changed, `add_flag_value_changed_listener` will register a listener that will be notified if and only if the flag value changes.
|
|
164
171
|
|
|
@@ -168,9 +175,9 @@ If the SDK is in offline mode, then it cannot know when there is a change, becau
|
|
|
168
175
|
```python
|
|
169
176
|
if client.initialize:
|
|
170
177
|
# flag value may be changed
|
|
171
|
-
client.flag_tracker.
|
|
178
|
+
client.flag_tracker.add_flag_value_maybe_changed_listener(flag_key, user, flag_value_maybe_changed_callback_fn)
|
|
172
179
|
# flag value must be changed
|
|
173
|
-
client.flag_tracker.add_flag_value_changed_listener(flag_key, user,
|
|
180
|
+
client.flag_tracker.add_flag_value_changed_listener(flag_key, user, flag_value_changed_callback_fn)
|
|
174
181
|
|
|
175
182
|
```
|
|
176
183
|
`flag_key`: the key of the feature flag to track
|
|
@@ -228,4 +235,4 @@ otherwise, the custom event may not be included into the experiment result.
|
|
|
228
235
|
feature, [submit an issue](https://github.com/featbit/featbit-python-sdk/issues/new).
|
|
229
236
|
|
|
230
237
|
## See Also
|
|
231
|
-
- [Connect To Python Sdk](https://docs.featbit.co/
|
|
238
|
+
- [Connect To Python Sdk](https://docs.featbit.co/sdk/overview#python)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fb-python-sdk
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.6
|
|
4
4
|
Summary: A Python SDK for FeatBit plateform
|
|
5
5
|
Home-page: https://github.com/featbit/featbit-python-sdk
|
|
6
6
|
Author: Dian SUN
|
|
@@ -19,10 +19,25 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Requires-Python: >=3.6, <=3.12
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
24
|
-
Provides-Extra: dev
|
|
25
25
|
License-File: LICENSE
|
|
26
|
+
Requires-Dist: certifi>=2018.4.16
|
|
27
|
+
Requires-Dist: urllib3>=1.22.0
|
|
28
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
29
|
+
Requires-Dist: websocket-client>=1.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: certifi>=2018.4.16; extra == "dev"
|
|
32
|
+
Requires-Dist: urllib3>=1.22.0; extra == "dev"
|
|
33
|
+
Requires-Dist: websocket-client>=1.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: python-dateutil>=2.8.2; extra == "dev"
|
|
35
|
+
Requires-Dist: flake8; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
38
|
+
Requires-Dist: autopep8; extra == "dev"
|
|
39
|
+
Requires-Dist: build; extra == "dev"
|
|
40
|
+
Requires-Dist: twine; extra == "dev"
|
|
26
41
|
|
|
27
42
|
# FeatBit Server-Side SDK for Python
|
|
28
43
|
|
|
@@ -56,8 +71,8 @@ Before using the SDK, you need to obtain the environment secret and SDK URLs.
|
|
|
56
71
|
|
|
57
72
|
Follow the documentation below to retrieve these values
|
|
58
73
|
|
|
59
|
-
- [How to get the environment secret](https://docs.featbit.co/
|
|
60
|
-
- [How to get the SDK URLs](https://docs.featbit.co/
|
|
74
|
+
- [How to get the environment secret](https://docs.featbit.co/sdk/faq#how-to-get-the-environment-secret)
|
|
75
|
+
- [How to get the SDK URLs](https://docs.featbit.co/sdk/faq#how-to-get-the-sdk-urls)
|
|
61
76
|
|
|
62
77
|
### Quick Start
|
|
63
78
|
|
|
@@ -170,10 +185,17 @@ If you would like to get variations of all feature flags in a special environmen
|
|
|
170
185
|
if client.initialize:
|
|
171
186
|
user = {'key': user_key, 'name': user_name}
|
|
172
187
|
all_flag_values = client.get_all_latest_flag_variations(user)
|
|
173
|
-
|
|
188
|
+
# get all feature flag keys
|
|
189
|
+
keys = all_flag_values.keys()
|
|
190
|
+
for flag_key in keys:
|
|
191
|
+
# get viariation detail
|
|
192
|
+
detail = all_flag_values.get(flag_key, default=None)
|
|
193
|
+
# get viariation
|
|
194
|
+
value = all_flag_values.get_variation(flag_key, default=None)
|
|
174
195
|
```
|
|
175
196
|
|
|
176
|
-
> Note
|
|
197
|
+
> **Note**
|
|
198
|
+
> If evaluation happened before the client is initialized, or you provide the wrong flag key/user for evaluation, the `variation` calls will return the default value. The `fbclient.common_types.EvalDetail` will explain the details of the latest evaluation including error reason.
|
|
177
199
|
|
|
178
200
|
### Flag Tracking
|
|
179
201
|
|
|
@@ -184,7 +206,7 @@ Note that a flag value change listener is bound to a specific user and flag key.
|
|
|
184
206
|
The flag value change listener will be notified whenever the SDK receives any change to any feature flag's configuration,
|
|
185
207
|
or to a user segment that is referenced by a feature flag. To register a flag value change listener, use `add_flag_value_may_changed_listener` or `add_flag_value_changed_listener`
|
|
186
208
|
|
|
187
|
-
When you track a flag change using `
|
|
209
|
+
When you track a flag change using `add_flag_value_maybe_changed_listener`, this does not necessarily mean the flag's value has changed for any particular flag, only that some part of the flag configuration was changed so that it *_MAY_* return a different value than it previously returned for some user.
|
|
188
210
|
|
|
189
211
|
If you want to track a flag whose value *_MUST_* be changed, `add_flag_value_changed_listener` will register a listener that will be notified if and only if the flag value changes.
|
|
190
212
|
|
|
@@ -194,9 +216,9 @@ If the SDK is in offline mode, then it cannot know when there is a change, becau
|
|
|
194
216
|
```python
|
|
195
217
|
if client.initialize:
|
|
196
218
|
# flag value may be changed
|
|
197
|
-
client.flag_tracker.
|
|
219
|
+
client.flag_tracker.add_flag_value_maybe_changed_listener(flag_key, user, flag_value_maybe_changed_callback_fn)
|
|
198
220
|
# flag value must be changed
|
|
199
|
-
client.flag_tracker.add_flag_value_changed_listener(flag_key, user,
|
|
221
|
+
client.flag_tracker.add_flag_value_changed_listener(flag_key, user, flag_value_changed_callback_fn)
|
|
200
222
|
|
|
201
223
|
```
|
|
202
224
|
`flag_key`: the key of the feature flag to track
|
|
@@ -254,4 +276,4 @@ otherwise, the custom event may not be included into the experiment result.
|
|
|
254
276
|
feature, [submit an issue](https://github.com/featbit/featbit-python-sdk/issues/new).
|
|
255
277
|
|
|
256
278
|
## See Also
|
|
257
|
-
- [Connect To Python Sdk](https://docs.featbit.co/
|
|
279
|
+
- [Connect To Python Sdk](https://docs.featbit.co/sdk/overview#python)
|
|
@@ -26,17 +26,13 @@ fbclient/status.py
|
|
|
26
26
|
fbclient/status_types.py
|
|
27
27
|
fbclient/streaming.py
|
|
28
28
|
fbclient/update_processor.py
|
|
29
|
-
fbclient/version.py
|
|
30
29
|
fbclient/utils/__init__.py
|
|
31
30
|
fbclient/utils/exponential_backoff_jitter_strategy.py
|
|
32
31
|
fbclient/utils/http_client.py
|
|
33
32
|
fbclient/utils/repeatable_task.py
|
|
34
33
|
fbclient/utils/rwlock.py
|
|
35
34
|
fbclient/utils/variation_splitting_algorithm.py
|
|
36
|
-
|
|
37
|
-
intergration_tests/readme.py
|
|
38
|
-
intergration_tests/run_in_start_no_wait.py
|
|
39
|
-
intergration_tests/run_in_start_wait.py
|
|
35
|
+
release/package.json
|
|
40
36
|
tests/__init__.py
|
|
41
37
|
tests/test_data_storage.py
|
|
42
38
|
tests/test_data_update_status_provider.py
|
|
@@ -343,7 +343,7 @@ class FBClient:
|
|
|
343
343
|
:param event_name: the name of the event, which may correspond to a goal in A/B tests
|
|
344
344
|
:param metric_value: a numeric value used by the experiment, default value is 1.0
|
|
345
345
|
"""
|
|
346
|
-
if not event_name
|
|
346
|
+
if not event_name:
|
|
347
347
|
log.warning('FB Python SDK: event/metric invalid')
|
|
348
348
|
return
|
|
349
349
|
try:
|
|
@@ -375,7 +375,7 @@ class FBClient:
|
|
|
375
375
|
|
|
376
376
|
metric_event = MetricEvent(fb_user)
|
|
377
377
|
for event_name, metric_value in metrics.items():
|
|
378
|
-
if event_name
|
|
378
|
+
if event_name:
|
|
379
379
|
metric_event.add(Metric(event_name, metric_value))
|
|
380
380
|
self._event_handler(metric_event)
|
|
381
381
|
|
|
@@ -215,6 +215,24 @@ class AllFlagStates(BasicFlagState, Jsonfy):
|
|
|
215
215
|
self._data = dict((ed.key_name, (ed, fb_event)) for ed, fb_event in data.items()) if data else {}
|
|
216
216
|
self._event_handler = event_handler
|
|
217
217
|
|
|
218
|
+
def keys(self):
|
|
219
|
+
"""
|
|
220
|
+
return all feature flag keys
|
|
221
|
+
"""
|
|
222
|
+
return self._data.keys()
|
|
223
|
+
|
|
224
|
+
def get_variation(self, key_name: str, default: Any = None) -> Any:
|
|
225
|
+
"""Return the variation of a given feature flag key
|
|
226
|
+
|
|
227
|
+
This method will send event to back to feature flag center immediately
|
|
228
|
+
|
|
229
|
+
The default value should be a string, boolean, numeric, or json type.
|
|
230
|
+
|
|
231
|
+
:param key_name: key name of the flag
|
|
232
|
+
:return: the variation of the flag in any type of string, boolean, numeric, or json type
|
|
233
|
+
"""
|
|
234
|
+
return self.get(key_name, default).variation
|
|
235
|
+
|
|
218
236
|
def get(self, key_name: str, default: Any = None) -> EvalDetail:
|
|
219
237
|
"""Return the flag evaluation details of a given feature flag key
|
|
220
238
|
|
|
@@ -38,7 +38,7 @@ class FlagValueChangedListener(FlagChangedListener):
|
|
|
38
38
|
flag_key: str,
|
|
39
39
|
user: dict,
|
|
40
40
|
evaluate_fn: Callable[[str, dict, Any], Any],
|
|
41
|
-
flag_value_changed_fn: Callable[[str, Any], None]):
|
|
41
|
+
flag_value_changed_fn: Callable[[str, Any, Any], None]):
|
|
42
42
|
self.__flag_key = flag_key
|
|
43
43
|
self.__user = user
|
|
44
44
|
self.__evaluate_fn = evaluate_fn
|
|
@@ -51,20 +51,20 @@ class FlagValueChangedListener(FlagChangedListener):
|
|
|
51
51
|
prev_flag_value = self.__prvious_flag_value
|
|
52
52
|
curr_flag_value = self.__evaluate_fn(self.__flag_key, self.__user, None)
|
|
53
53
|
if prev_flag_value != curr_flag_value:
|
|
54
|
-
self.__fn(self.__flag_key, curr_flag_value)
|
|
54
|
+
self.__fn(self.__flag_key, prev_flag_value, curr_flag_value)
|
|
55
55
|
self.__prvious_flag_value = curr_flag_value
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
class
|
|
58
|
+
class FlagValueMaybeChangedListener(FlagChangedListener):
|
|
59
59
|
def __init__(self,
|
|
60
60
|
flag_key: str,
|
|
61
61
|
user: dict,
|
|
62
62
|
evaluate_fn: Callable[[str, dict, Any], Any],
|
|
63
|
-
|
|
63
|
+
flag_value_maybe_changed_fn: Callable[[str, Any], None]):
|
|
64
64
|
self.__flag_key = flag_key
|
|
65
65
|
self.__user = user
|
|
66
66
|
self.__evaluate_fn = evaluate_fn
|
|
67
|
-
self.__fn =
|
|
67
|
+
self.__fn = flag_value_maybe_changed_fn
|
|
68
68
|
|
|
69
69
|
def on_flag_change(self, notice: FlagChangedNotice):
|
|
70
70
|
if notice.flag_key == self.__flag_key:
|
|
@@ -95,7 +95,7 @@ class FlagTracker:
|
|
|
95
95
|
def add_flag_value_changed_listener(self,
|
|
96
96
|
flag_key: str,
|
|
97
97
|
user: dict,
|
|
98
|
-
flag_value_changed_fn: Callable[[str, Any], None]) -> FlagValueChangedListener:
|
|
98
|
+
flag_value_changed_fn: Callable[[str, Any, Any], None]) -> FlagValueChangedListener:
|
|
99
99
|
"""
|
|
100
100
|
Registers a listener to be notified of a change in a specific feature flag's value for a specific FeatBit user.
|
|
101
101
|
|
|
@@ -110,7 +110,8 @@ class FlagTracker:
|
|
|
110
110
|
:param user: The user to evaluate the flag value
|
|
111
111
|
:param flag_value_changed_fn: The function to be called only when this flag value changes
|
|
112
112
|
* the first argument is the flag key
|
|
113
|
-
* the second argument is the
|
|
113
|
+
* the second argument is the previous flag value
|
|
114
|
+
* the third argument is the current flag value
|
|
114
115
|
|
|
115
116
|
:return: A listener object that can be used to remove it later on.
|
|
116
117
|
"""
|
|
@@ -128,10 +129,10 @@ class FlagTracker:
|
|
|
128
129
|
self.add_flag_changed_listener(listener)
|
|
129
130
|
return listener
|
|
130
131
|
|
|
131
|
-
def
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
def add_flag_value_maybe_changed_listener(self,
|
|
133
|
+
flag_key: str,
|
|
134
|
+
user: dict,
|
|
135
|
+
flag_value_maybe_changed_fn: Callable[[str, Any], None]) -> FlagValueMaybeChangedListener:
|
|
135
136
|
"""
|
|
136
137
|
Registers a listener to be notified of a change in a specific feature flag's value for a specific FeatBit user.
|
|
137
138
|
|
|
@@ -145,7 +146,7 @@ class FlagTracker:
|
|
|
145
146
|
|
|
146
147
|
:param flag_key: The key of the feature flag to track
|
|
147
148
|
:param user: The user to evaluate the flag value
|
|
148
|
-
:param
|
|
149
|
+
:param flag_value_maybe_changed_fn: The function to be called if any changes to a specific flag
|
|
149
150
|
* the first argument is the flag key
|
|
150
151
|
* the second argument is the latest flag value, this value may be same as the previous value
|
|
151
152
|
|
|
@@ -159,10 +160,10 @@ class FlagTracker:
|
|
|
159
160
|
# check user
|
|
160
161
|
FBUser.from_dict(user)
|
|
161
162
|
# check flag_value_changed_fn
|
|
162
|
-
if not isinstance(
|
|
163
|
+
if not isinstance(flag_value_maybe_changed_fn, Callable) or not flag_value_maybe_changed_fn:
|
|
163
164
|
raise ValueError('flag_value_changed_fn must be a callable function')
|
|
164
165
|
|
|
165
|
-
listener =
|
|
166
|
+
listener = FlagValueMaybeChangedListener(flag_key, user, self.__evaluate_fn, flag_value_maybe_changed_fn)
|
|
166
167
|
self.add_flag_changed_listener(listener)
|
|
167
168
|
return listener
|
|
168
169
|
|
|
@@ -25,7 +25,7 @@ class ReadWriteLock:
|
|
|
25
25
|
with self._read_ready:
|
|
26
26
|
self._readers = self._readers - 1 if self._readers > 0 else 0
|
|
27
27
|
if self._readers == 0:
|
|
28
|
-
self._read_ready.
|
|
28
|
+
self._read_ready.notify_all()
|
|
29
29
|
|
|
30
30
|
def write_lock(self):
|
|
31
31
|
""" Acquire a write lock. Blocks until there are no
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from setuptools import setup, find_packages
|
|
2
3
|
|
|
3
|
-
version = {}
|
|
4
|
-
|
|
5
4
|
|
|
6
5
|
def last_version():
|
|
7
|
-
with open("./
|
|
8
|
-
|
|
9
|
-
return version['
|
|
6
|
+
with open("./release/package.json") as fp:
|
|
7
|
+
version = json.load(fp)
|
|
8
|
+
return version['version']
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
fb_version = last_version()
|
|
@@ -51,10 +50,11 @@ setup(
|
|
|
51
50
|
'Programming Language :: Python :: 3.9',
|
|
52
51
|
'Programming Language :: Python :: 3.10',
|
|
53
52
|
'Programming Language :: Python :: 3.11',
|
|
53
|
+
'Programming Language :: Python :: 3.12',
|
|
54
54
|
],
|
|
55
55
|
extras_require={
|
|
56
56
|
"dev": dev_reqs
|
|
57
57
|
},
|
|
58
58
|
tests_require=dev_reqs,
|
|
59
|
-
python_requires='>=3.6, <=3.
|
|
59
|
+
python_requires='>=3.6, <=3.12'
|
|
60
60
|
)
|
|
@@ -206,15 +206,30 @@ def test_get_all_latest_flag_variations():
|
|
|
206
206
|
assert client.initialize
|
|
207
207
|
all_states = client.get_all_latest_flag_variations(USER_1)
|
|
208
208
|
ed = all_states.get("ff-test-bool", False)
|
|
209
|
+
value = all_states.get_variation("ff-test-bool", False)
|
|
209
210
|
assert ed is not None and ed.variation is True
|
|
211
|
+
assert value is True
|
|
212
|
+
assert "ff-test-bool" in all_states.keys()
|
|
210
213
|
ed = all_states.get("ff-test-number", -1)
|
|
214
|
+
value = all_states.get_variation("ff-test-number", -1)
|
|
211
215
|
assert ed is not None and ed.variation == 1
|
|
216
|
+
assert value == 1
|
|
217
|
+
assert "ff-test-number" in all_states.keys()
|
|
212
218
|
ed = all_states.get("ff-test-string", 'error')
|
|
219
|
+
value = all_states.get_variation("ff-test-string", 'error')
|
|
213
220
|
assert ed is not None and ed.variation == "others"
|
|
221
|
+
assert value == "others"
|
|
222
|
+
assert "ff-test-string" in all_states.keys()
|
|
214
223
|
ed = all_states.get("ff-test-seg", 'error')
|
|
224
|
+
value = all_states.get_variation("ff-test-seg", 'error')
|
|
215
225
|
assert ed is not None and ed.variation == "teamA"
|
|
226
|
+
assert value == "teamA"
|
|
227
|
+
assert "ff-test-seg" in all_states.keys()
|
|
216
228
|
ed = all_states.get("ff-test-json", {})
|
|
229
|
+
value = all_states.get_variation("ff-test-json", {})
|
|
217
230
|
assert ed is not None and ed.variation["code"] == 200
|
|
231
|
+
assert value["code"] == 200
|
|
232
|
+
assert "ff-test-json" in all_states.keys()
|
|
218
233
|
|
|
219
234
|
|
|
220
235
|
def test_variation_argument_error():
|
|
@@ -13,6 +13,9 @@ TEST_NOTICE_TYPE = 'test_notice_type'
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class TestNotice(Notice):
|
|
16
|
+
# https://stackoverflow.com/questions/62460557/cannot-collect-test-class-testmain-because-it-has-a-init-constructor-from
|
|
17
|
+
__test__ = False
|
|
18
|
+
|
|
16
19
|
def __init__(self, notice_type: str, content: str):
|
|
17
20
|
self.__notice_type = notice_type
|
|
18
21
|
self.__content = content
|
|
@@ -27,6 +30,8 @@ class TestNotice(Notice):
|
|
|
27
30
|
|
|
28
31
|
|
|
29
32
|
class FakeFlagChangedListener(FlagChangedListener):
|
|
33
|
+
__test__ = False
|
|
34
|
+
|
|
30
35
|
def __init__(self, queue: Queue):
|
|
31
36
|
self.__queue = queue
|
|
32
37
|
|
fb-python-sdk-1.1.4/MANIFEST.in
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "1.1.4"
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from fbclient import get, set_config
|
|
3
|
-
from fbclient.config import Config
|
|
4
|
-
|
|
5
|
-
logging.basicConfig(level=logging.DEBUG,
|
|
6
|
-
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
|
|
7
|
-
datefmt='%m-%d %H:%M')
|
|
8
|
-
|
|
9
|
-
env_secret = 'fXWjg00OTEa-M_iBCyYiBwFPfdBisjAkiY3ycIMOWw1Q'
|
|
10
|
-
event_url = 'http://localhost:5100'
|
|
11
|
-
streaming_url = 'ws://localhost:5100'
|
|
12
|
-
|
|
13
|
-
set_config(Config(env_secret, event_url, streaming_url))
|
|
14
|
-
client = get()
|
|
15
|
-
|
|
16
|
-
if client.initialize:
|
|
17
|
-
flag_key = 'ff-test-bool'
|
|
18
|
-
user_key = 'user-test-1'
|
|
19
|
-
user_name = 'user-test-1'
|
|
20
|
-
user = {'key': user_key, 'name': user_name}
|
|
21
|
-
detail = client.variation_detail(flag_key, user, default=None)
|
|
22
|
-
print(f'flag {flag_key} returns {detail.variation} for user {user_key}, reason: {detail.reason}')
|
|
23
|
-
|
|
24
|
-
# ensure that the SDK shuts down cleanly and has a chance to deliver events to FeatBit before the program exits
|
|
25
|
-
client.stop()
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from time import time
|
|
3
|
-
|
|
4
|
-
from fbclient.client import FBClient
|
|
5
|
-
from fbclient.common_types import FBUser
|
|
6
|
-
from fbclient.config import Config
|
|
7
|
-
from fbclient.utils import log
|
|
8
|
-
|
|
9
|
-
logging.basicConfig(level=logging.DEBUG,
|
|
10
|
-
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
|
|
11
|
-
datefmt='%m-%d %H:%M')
|
|
12
|
-
|
|
13
|
-
env_secret = 'fXWjg00OTEa-M_iBCyYiBwFPfdBisjAkiY3ycIMOWw1Q'
|
|
14
|
-
|
|
15
|
-
config = Config(env_secret, event_url='http://localhost:5100', streaming_url='ws://localhost:5100')
|
|
16
|
-
client = FBClient(config, start_wait=0)
|
|
17
|
-
|
|
18
|
-
if client.update_status_provider.wait_for_OKState(timeout=15.):
|
|
19
|
-
while True:
|
|
20
|
-
line = input('input user key and flag key seperated by / \n')
|
|
21
|
-
if 'exit' == line.strip():
|
|
22
|
-
break
|
|
23
|
-
try:
|
|
24
|
-
user_key, flag_key, *_ = tuple(line.split('/'))
|
|
25
|
-
user = {'key': user_key, 'name': user_key, 'country': 'cn'}
|
|
26
|
-
fb_user = FBUser.from_dict(user)
|
|
27
|
-
log.info('FB Python SDK Test: user= %s' % fb_user.to_json_str())
|
|
28
|
-
t1 = time()
|
|
29
|
-
log.info('FB Python SDK Test: variation= %s' % client.variation_detail(flag_key, user).to_json_str())
|
|
30
|
-
t2 = time()
|
|
31
|
-
log.info('FB Python SDK Test: execution time= %f' % (t2 - t1))
|
|
32
|
-
except:
|
|
33
|
-
log.exception('FB Python SDK Test: unexpected error')
|
|
34
|
-
break
|
|
35
|
-
|
|
36
|
-
client.stop()
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from time import time
|
|
3
|
-
|
|
4
|
-
from fbclient import get, set_config
|
|
5
|
-
from fbclient.common_types import FBUser
|
|
6
|
-
from fbclient.config import Config
|
|
7
|
-
from fbclient.utils import log
|
|
8
|
-
|
|
9
|
-
logging.basicConfig(level=logging.DEBUG,
|
|
10
|
-
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
|
|
11
|
-
datefmt='%m-%d %H:%M')
|
|
12
|
-
|
|
13
|
-
env_secret = '9T0GABTXokagxhUZ81hUnws9_E2uOpIEyTjScBRr6JKA'
|
|
14
|
-
|
|
15
|
-
config = Config(env_secret, event_url='http://localhost:5100', streaming_url='ws://localhost:5100')
|
|
16
|
-
|
|
17
|
-
set_config(config)
|
|
18
|
-
|
|
19
|
-
client = get()
|
|
20
|
-
|
|
21
|
-
previous_flag_changed_keys = []
|
|
22
|
-
|
|
23
|
-
if client.initialize:
|
|
24
|
-
# client.identify({'key': 'test-python-sdk-user', 'name': 'test-python-sdk-user'})
|
|
25
|
-
def fn(flag_key, new_flag_value):
|
|
26
|
-
return log.info("%s value is %s" % (flag_key, new_flag_value))
|
|
27
|
-
while True:
|
|
28
|
-
line = input('input user key and flag key seperated by / \n')
|
|
29
|
-
if 'exit' == line.strip():
|
|
30
|
-
break
|
|
31
|
-
try:
|
|
32
|
-
user_key, flag_key, *_ = tuple(line.split('/'))
|
|
33
|
-
user = {'key': user_key, 'name': user_key, 'country': 'cn'}
|
|
34
|
-
flag_changed_key = f'{user_key}_{flag_key}'
|
|
35
|
-
if flag_changed_key not in previous_flag_changed_keys:
|
|
36
|
-
client \
|
|
37
|
-
.flag_tracker \
|
|
38
|
-
.add_flag_value_changed_listener(flag_key, user, fn)
|
|
39
|
-
previous_flag_changed_keys.append(flag_key)
|
|
40
|
-
fb_user = FBUser.from_dict(user)
|
|
41
|
-
log.info('FB Python SDK Test: user= %s' % fb_user.to_json_str())
|
|
42
|
-
t1 = time()
|
|
43
|
-
log.info('FB Python SDK Test: variation= %s' % client.variation_detail(flag_key, user).to_json_str())
|
|
44
|
-
t2 = time()
|
|
45
|
-
log.info('FB Python SDK Test: execution time= %f' % (t2 - t1))
|
|
46
|
-
except:
|
|
47
|
-
log.exception('FB Python SDK Test: unexpected error')
|
|
48
|
-
break
|
|
49
|
-
|
|
50
|
-
client.stop()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fb-python-sdk-1.1.4 → fb_python_sdk-1.1.6}/fbclient/utils/exponential_backoff_jitter_strategy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|