fb-python-sdk 1.1.5__py3-none-any.whl → 1.1.6__py3-none-any.whl
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.5.dist-info → fb_python_sdk-1.1.6.dist-info}/METADATA +17 -16
- {fb_python_sdk-1.1.5.dist-info → fb_python_sdk-1.1.6.dist-info}/RECORD +8 -9
- {fb_python_sdk-1.1.5.dist-info → fb_python_sdk-1.1.6.dist-info}/WHEEL +1 -1
- fbclient/client.py +2 -2
- fbclient/flag_change_notification.py +15 -14
- fbclient/utils/rwlock.py +1 -1
- fbclient/version.py +0 -1
- {fb_python_sdk-1.1.5.dist-info → fb_python_sdk-1.1.6.dist-info}/LICENSE +0 -0
- {fb_python_sdk-1.1.5.dist-info → fb_python_sdk-1.1.6.dist-info}/top_level.txt +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,18 +19,19 @@ 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
25
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: certifi
|
|
26
|
-
Requires-Dist: urllib3
|
|
27
|
-
Requires-Dist: python-dateutil
|
|
28
|
-
Requires-Dist: websocket-client
|
|
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
|
|
29
30
|
Provides-Extra: dev
|
|
30
|
-
Requires-Dist: certifi
|
|
31
|
-
Requires-Dist: urllib3
|
|
32
|
-
Requires-Dist: websocket-client
|
|
33
|
-
Requires-Dist: python-dateutil
|
|
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'
|
|
34
35
|
Requires-Dist: flake8 ; extra == 'dev'
|
|
35
36
|
Requires-Dist: pytest ; extra == 'dev'
|
|
36
37
|
Requires-Dist: pytest-mock ; extra == 'dev'
|
|
@@ -70,8 +71,8 @@ Before using the SDK, you need to obtain the environment secret and SDK URLs.
|
|
|
70
71
|
|
|
71
72
|
Follow the documentation below to retrieve these values
|
|
72
73
|
|
|
73
|
-
- [How to get the environment secret](https://docs.featbit.co/
|
|
74
|
-
- [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)
|
|
75
76
|
|
|
76
77
|
### Quick Start
|
|
77
78
|
|
|
@@ -205,7 +206,7 @@ Note that a flag value change listener is bound to a specific user and flag key.
|
|
|
205
206
|
The flag value change listener will be notified whenever the SDK receives any change to any feature flag's configuration,
|
|
206
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`
|
|
207
208
|
|
|
208
|
-
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.
|
|
209
210
|
|
|
210
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.
|
|
211
212
|
|
|
@@ -215,9 +216,9 @@ If the SDK is in offline mode, then it cannot know when there is a change, becau
|
|
|
215
216
|
```python
|
|
216
217
|
if client.initialize:
|
|
217
218
|
# flag value may be changed
|
|
218
|
-
client.flag_tracker.
|
|
219
|
+
client.flag_tracker.add_flag_value_maybe_changed_listener(flag_key, user, flag_value_maybe_changed_callback_fn)
|
|
219
220
|
# flag value must be changed
|
|
220
|
-
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)
|
|
221
222
|
|
|
222
223
|
```
|
|
223
224
|
`flag_key`: the key of the feature flag to track
|
|
@@ -275,4 +276,4 @@ otherwise, the custom event may not be included into the experiment result.
|
|
|
275
276
|
feature, [submit an issue](https://github.com/featbit/featbit-python-sdk/issues/new).
|
|
276
277
|
|
|
277
278
|
## See Also
|
|
278
|
-
- [Connect To Python Sdk](https://docs.featbit.co/
|
|
279
|
+
- [Connect To Python Sdk](https://docs.featbit.co/sdk/overview#python)
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
fbclient/__init__.py,sha256=GMbobi6viAXPaNedEqyUOgIhoJsDqP2_W-PMUAFKC5A,2249
|
|
2
2
|
fbclient/category.py,sha256=DzblPnzVwsPKK_FSnLkK3HyWXStbNdPiRfdgSoEODVY,1058
|
|
3
|
-
fbclient/client.py,sha256=
|
|
3
|
+
fbclient/client.py,sha256=njobS5wNA_WtCkp3P-DTBEZbEtu9wHvUjHuHSFLAq9Y,18434
|
|
4
4
|
fbclient/common_types.py,sha256=5G4jJtG5Q1TL4NlBDSzVmNgRKh4OysYCfheigMDxgXU,11391
|
|
5
5
|
fbclient/config.py,sha256=BMWMAVcModtDVMrBmSFI3V4jZFEZX0jlKZ-ENqC0hDA,8913
|
|
6
6
|
fbclient/data_storage.py,sha256=gLYBAUTV-cR0rzoCxTCRYqAeGXhbIhQ7-_xh5OwLkqw,3342
|
|
7
7
|
fbclient/evaluator.py,sha256=OqPTmUXHl30NCb0RvD6fxBeSEpXHdZti-sWNPMIShlE,12387
|
|
8
8
|
fbclient/event_processor.py,sha256=tVnP_YLcIX4RakEqBv5VSCKBAHrMPZBJIPHDA04CtVI,9022
|
|
9
9
|
fbclient/event_types.py,sha256=0gorQ-RIjEw9OUYmV8MUoAgd4u1xlIVGayTeXkM-gAI,4597
|
|
10
|
-
fbclient/flag_change_notification.py,sha256=
|
|
10
|
+
fbclient/flag_change_notification.py,sha256=0JTd2w7nkgJtawKlnqmdB6JFQ_mcpLU2L3y_FNvdUQM,8664
|
|
11
11
|
fbclient/interfaces.py,sha256=eEB5y71uhL2Wlv47zNbG5kx43pZT8GcjBRPYA_tcod8,9861
|
|
12
12
|
fbclient/notice_broadcaster.py,sha256=fbR9QJzPu_tbmLpk-jBJB93eH2T95xVfR51OH_Wqqc0,2126
|
|
13
13
|
fbclient/status.py,sha256=f3Hif4aWCtn0bOvX_C6mtsDaynSRU5mvB3_Bp_r09qs,3794
|
|
14
14
|
fbclient/status_types.py,sha256=-xB4zf2qHPNE1GHOSkO1h3SJ_5vQZqrvOymBVvvh5ts,3160
|
|
15
15
|
fbclient/streaming.py,sha256=lyvmoE-yVohhp42OXm2rar4IDd5jdVGnv8AQjX5aV2A,12866
|
|
16
16
|
fbclient/update_processor.py,sha256=E2AChTLh38i_D2yR7Wz3p4nxO6TlaBoRmF3kj-0pCsw,629
|
|
17
|
-
fbclient/version.py,sha256=CfxjCyC2iA9sqbVbGHcy6AOiBc2pORcKqRXQbmlcmzY,18
|
|
18
17
|
fbclient/utils/__init__.py,sha256=3HjFPtGBWwU_7GQarELbNV0VuuQMuPw9TCDsR93t7u0,4339
|
|
19
18
|
fbclient/utils/exponential_backoff_jitter_strategy.py,sha256=xZk7Y0yi3__U8c3DaX3PRb55vZAsRX__Rna3b2Wj9JA,1950
|
|
20
19
|
fbclient/utils/http_client.py,sha256=LCTZWg-ukoHGTRaf9gozhNqNZW-htKHS7DnSr1RZPV4,5502
|
|
21
20
|
fbclient/utils/repeatable_task.py,sha256=R8f9BgyoP0y2CHJYaVBEOYHYpH8XDcgmFmCVe3iyTlM,1320
|
|
22
|
-
fbclient/utils/rwlock.py,sha256=
|
|
21
|
+
fbclient/utils/rwlock.py,sha256=BfgKYNwZ8y63yk-CphlFTCZ1-0Txh4XQ8Pzh2pohh5A,1159
|
|
23
22
|
fbclient/utils/variation_splitting_algorithm.py,sha256=4_qBeVANWIFPacifmV1zl_JZXywOd-wv1fQmnb8qyAE,864
|
|
24
23
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
24
|
tests/test_data_storage.py,sha256=q5tgVI3smztXLMdNpFUF1ES-rFuanwamYAKF8K1cEWc,3785
|
|
@@ -28,8 +27,8 @@ tests/test_evaluator.py,sha256=8SH9lfSzVXLCQ3NR_OKf2bwYGbZcnwkAhwMNNObprUI,4675
|
|
|
28
27
|
tests/test_event_processor.py,sha256=ceKHT5U7X_JfAwrnu_KJuwAsOTCsM8AdoXuNILMpwKI,4475
|
|
29
28
|
tests/test_fbclient.py,sha256=_hmu7PWgHEURw95FXDQI8NkIIYHeiC81Z22UZoiuQhI,11535
|
|
30
29
|
tests/test_flag_change_notification.py,sha256=pDLCxq7_x63eJiWfPwf0_AgyvelLW_YPu-rhmto-TNs,3592
|
|
31
|
-
fb_python_sdk-1.1.
|
|
32
|
-
fb_python_sdk-1.1.
|
|
33
|
-
fb_python_sdk-1.1.
|
|
34
|
-
fb_python_sdk-1.1.
|
|
35
|
-
fb_python_sdk-1.1.
|
|
30
|
+
fb_python_sdk-1.1.6.dist-info/LICENSE,sha256=Pp1Gaxzlu2F3GAFJ314grnBHifZdIK7_ZvCFV_khanM,1064
|
|
31
|
+
fb_python_sdk-1.1.6.dist-info/METADATA,sha256=Z4we-3EBvhLH_cYh8qTmA6a0PctCjuC23XIwoX1lyrI,13385
|
|
32
|
+
fb_python_sdk-1.1.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
33
|
+
fb_python_sdk-1.1.6.dist-info/top_level.txt,sha256=im9taLLXhMbB6_5DAbFwqLVV0gk1rOgAkYmsVJu5pbY,15
|
|
34
|
+
fb_python_sdk-1.1.6.dist-info/RECORD,,
|
fbclient/client.py
CHANGED
|
@@ -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
|
|
|
@@ -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
|
|
fbclient/utils/rwlock.py
CHANGED
|
@@ -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
|
fbclient/version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "1.1.5"
|
|
File without changes
|
|
File without changes
|