fb-python-sdk 1.1.5__py3-none-any.whl → 1.1.7__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: fb-python-sdk
3
- Version: 1.1.5
3
+ Version: 1.1.7
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,24 +19,37 @@ 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
- Requires-Python: >=3.6, <=3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.6, <3.13
23
24
  Description-Content-Type: text/markdown
24
25
  License-File: LICENSE
25
- Requires-Dist: certifi (>=2018.4.16)
26
- Requires-Dist: urllib3 (>=1.22.0)
27
- Requires-Dist: python-dateutil (>=2.8.2)
28
- Requires-Dist: websocket-client (>=1.0.0)
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 (>=2018.4.16) ; extra == 'dev'
31
- Requires-Dist: urllib3 (>=1.22.0) ; extra == 'dev'
32
- Requires-Dist: websocket-client (>=1.0.0) ; extra == 'dev'
33
- Requires-Dist: python-dateutil (>=2.8.2) ; extra == 'dev'
34
- Requires-Dist: flake8 ; extra == 'dev'
35
- Requires-Dist: pytest ; extra == 'dev'
36
- Requires-Dist: pytest-mock ; extra == 'dev'
37
- Requires-Dist: autopep8 ; extra == 'dev'
38
- Requires-Dist: build ; extra == 'dev'
39
- Requires-Dist: twine ; 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"
41
+ Dynamic: author
42
+ Dynamic: author-email
43
+ Dynamic: classifier
44
+ Dynamic: description
45
+ Dynamic: description-content-type
46
+ Dynamic: home-page
47
+ Dynamic: license-file
48
+ Dynamic: project-url
49
+ Dynamic: provides-extra
50
+ Dynamic: requires-dist
51
+ Dynamic: requires-python
52
+ Dynamic: summary
40
53
 
41
54
  # FeatBit Server-Side SDK for Python
42
55
 
@@ -70,8 +83,8 @@ Before using the SDK, you need to obtain the environment secret and SDK URLs.
70
83
 
71
84
  Follow the documentation below to retrieve these values
72
85
 
73
- - [How to get the environment secret](https://docs.featbit.co/docs/sdk/faq#how-to-get-the-environment-secret)
74
- - [How to get the SDK URLs](https://docs.featbit.co/docs/sdk/faq#how-to-get-the-sdk-urls)
86
+ - [How to get the environment secret](https://docs.featbit.co/sdk/faq#how-to-get-the-environment-secret)
87
+ - [How to get the SDK URLs](https://docs.featbit.co/sdk/faq#how-to-get-the-sdk-urls)
75
88
 
76
89
  ### Quick Start
77
90
 
@@ -205,7 +218,7 @@ Note that a flag value change listener is bound to a specific user and flag key.
205
218
  The flag value change listener will be notified whenever the SDK receives any change to any feature flag's configuration,
206
219
  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
220
 
208
- When you track a flag change using `add_flag_value_may_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.
221
+ 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
222
 
210
223
  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
224
 
@@ -215,9 +228,9 @@ If the SDK is in offline mode, then it cannot know when there is a change, becau
215
228
  ```python
216
229
  if client.initialize:
217
230
  # flag value may be changed
218
- client.flag_tracker.add_flag_value_may_changed_listener(flag_key, user, callback_fn)
231
+ client.flag_tracker.add_flag_value_maybe_changed_listener(flag_key, user, flag_value_maybe_changed_callback_fn)
219
232
  # flag value must be changed
220
- client.flag_tracker.add_flag_value_changed_listener(flag_key, user, callback_fn)
233
+ client.flag_tracker.add_flag_value_changed_listener(flag_key, user, flag_value_changed_callback_fn)
221
234
 
222
235
  ```
223
236
  `flag_key`: the key of the feature flag to track
@@ -275,4 +288,4 @@ otherwise, the custom event may not be included into the experiment result.
275
288
  feature, [submit an issue](https://github.com/featbit/featbit-python-sdk/issues/new).
276
289
 
277
290
  ## See Also
278
- - [Connect To Python Sdk](https://docs.featbit.co/docs/getting-started/4.-connect-an-sdk/server-side-sdks/python-sdk)
291
+ - [Connect To Python Sdk](https://docs.featbit.co/sdk/overview#python)
@@ -1,25 +1,25 @@
1
+ fb_python_sdk-1.1.7.dist-info/licenses/LICENSE,sha256=Pp1Gaxzlu2F3GAFJ314grnBHifZdIK7_ZvCFV_khanM,1064
1
2
  fbclient/__init__.py,sha256=GMbobi6viAXPaNedEqyUOgIhoJsDqP2_W-PMUAFKC5A,2249
2
3
  fbclient/category.py,sha256=DzblPnzVwsPKK_FSnLkK3HyWXStbNdPiRfdgSoEODVY,1058
3
- fbclient/client.py,sha256=4ol12qG2MMNRiX3RzWF-cAcggOP4x1Z66Is9NdJ8txU,18476
4
+ fbclient/client.py,sha256=njobS5wNA_WtCkp3P-DTBEZbEtu9wHvUjHuHSFLAq9Y,18434
4
5
  fbclient/common_types.py,sha256=5G4jJtG5Q1TL4NlBDSzVmNgRKh4OysYCfheigMDxgXU,11391
5
6
  fbclient/config.py,sha256=BMWMAVcModtDVMrBmSFI3V4jZFEZX0jlKZ-ENqC0hDA,8913
6
7
  fbclient/data_storage.py,sha256=gLYBAUTV-cR0rzoCxTCRYqAeGXhbIhQ7-_xh5OwLkqw,3342
7
8
  fbclient/evaluator.py,sha256=OqPTmUXHl30NCb0RvD6fxBeSEpXHdZti-sWNPMIShlE,12387
8
9
  fbclient/event_processor.py,sha256=tVnP_YLcIX4RakEqBv5VSCKBAHrMPZBJIPHDA04CtVI,9022
9
10
  fbclient/event_types.py,sha256=0gorQ-RIjEw9OUYmV8MUoAgd4u1xlIVGayTeXkM-gAI,4597
10
- fbclient/flag_change_notification.py,sha256=toUe0UumRJRdzB50HjQcX7LM5eOjrjm85Me7_CB84dc,8579
11
+ fbclient/flag_change_notification.py,sha256=0JTd2w7nkgJtawKlnqmdB6JFQ_mcpLU2L3y_FNvdUQM,8664
11
12
  fbclient/interfaces.py,sha256=eEB5y71uhL2Wlv47zNbG5kx43pZT8GcjBRPYA_tcod8,9861
12
13
  fbclient/notice_broadcaster.py,sha256=fbR9QJzPu_tbmLpk-jBJB93eH2T95xVfR51OH_Wqqc0,2126
13
14
  fbclient/status.py,sha256=f3Hif4aWCtn0bOvX_C6mtsDaynSRU5mvB3_Bp_r09qs,3794
14
15
  fbclient/status_types.py,sha256=-xB4zf2qHPNE1GHOSkO1h3SJ_5vQZqrvOymBVvvh5ts,3160
15
16
  fbclient/streaming.py,sha256=lyvmoE-yVohhp42OXm2rar4IDd5jdVGnv8AQjX5aV2A,12866
16
17
  fbclient/update_processor.py,sha256=E2AChTLh38i_D2yR7Wz3p4nxO6TlaBoRmF3kj-0pCsw,629
17
- fbclient/version.py,sha256=CfxjCyC2iA9sqbVbGHcy6AOiBc2pORcKqRXQbmlcmzY,18
18
18
  fbclient/utils/__init__.py,sha256=3HjFPtGBWwU_7GQarELbNV0VuuQMuPw9TCDsR93t7u0,4339
19
19
  fbclient/utils/exponential_backoff_jitter_strategy.py,sha256=xZk7Y0yi3__U8c3DaX3PRb55vZAsRX__Rna3b2Wj9JA,1950
20
20
  fbclient/utils/http_client.py,sha256=LCTZWg-ukoHGTRaf9gozhNqNZW-htKHS7DnSr1RZPV4,5502
21
21
  fbclient/utils/repeatable_task.py,sha256=R8f9BgyoP0y2CHJYaVBEOYHYpH8XDcgmFmCVe3iyTlM,1320
22
- fbclient/utils/rwlock.py,sha256=C5uP5UD_BiH2fivUeoCOGrSbCM-Kz0J0U9m4MZbYXMg,1158
22
+ fbclient/utils/rwlock.py,sha256=BfgKYNwZ8y63yk-CphlFTCZ1-0Txh4XQ8Pzh2pohh5A,1159
23
23
  fbclient/utils/variation_splitting_algorithm.py,sha256=4_qBeVANWIFPacifmV1zl_JZXywOd-wv1fQmnb8qyAE,864
24
24
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  tests/test_data_storage.py,sha256=q5tgVI3smztXLMdNpFUF1ES-rFuanwamYAKF8K1cEWc,3785
@@ -28,8 +28,7 @@ tests/test_evaluator.py,sha256=8SH9lfSzVXLCQ3NR_OKf2bwYGbZcnwkAhwMNNObprUI,4675
28
28
  tests/test_event_processor.py,sha256=ceKHT5U7X_JfAwrnu_KJuwAsOTCsM8AdoXuNILMpwKI,4475
29
29
  tests/test_fbclient.py,sha256=_hmu7PWgHEURw95FXDQI8NkIIYHeiC81Z22UZoiuQhI,11535
30
30
  tests/test_flag_change_notification.py,sha256=pDLCxq7_x63eJiWfPwf0_AgyvelLW_YPu-rhmto-TNs,3592
31
- fb_python_sdk-1.1.5.dist-info/LICENSE,sha256=Pp1Gaxzlu2F3GAFJ314grnBHifZdIK7_ZvCFV_khanM,1064
32
- fb_python_sdk-1.1.5.dist-info/METADATA,sha256=4i2UBD7wZg7w95oECd0namzCaQ6XrZj1WSshiA-OmxM,13359
33
- fb_python_sdk-1.1.5.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
34
- fb_python_sdk-1.1.5.dist-info/top_level.txt,sha256=im9taLLXhMbB6_5DAbFwqLVV0gk1rOgAkYmsVJu5pbY,15
35
- fb_python_sdk-1.1.5.dist-info/RECORD,,
31
+ fb_python_sdk-1.1.7.dist-info/METADATA,sha256=cjqf_A6tnhtYiW6kZ2iMxP59awWom5TwJquSXOhaNqw,13630
32
+ fb_python_sdk-1.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ fb_python_sdk-1.1.7.dist-info/top_level.txt,sha256=im9taLLXhMbB6_5DAbFwqLVV0gk1rOgAkYmsVJu5pbY,15
34
+ fb_python_sdk-1.1.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
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 or metric_value <= 0:
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 and metric_value > 0:
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 FlagValueMayChangedListener(FlagChangedListener):
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
- flag_value_changed_fn: Callable[[str, Any], None]):
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 = flag_value_changed_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 latest flag value, this value must be different from the previous value
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 add_flag_value_may_changed_listener(self,
132
- flag_key: str,
133
- user: dict,
134
- flag_value_changed_fn: Callable[[str, Any], None]) -> FlagValueMayChangedListener:
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 flag_value_changed_fn: The function to be called only if any changes to a specific flag
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(flag_value_changed_fn, Callable) or not flag_value_changed_fn:
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 = FlagValueMayChangedListener(flag_key, user, self.__evaluate_fn, flag_value_changed_fn)
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.notifyAll()
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"