fb-python-sdk 1.2.0__tar.gz → 1.2.1__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.
Files changed (46) hide show
  1. {fb_python_sdk-1.2.0/fb_python_sdk.egg-info → fb_python_sdk-1.2.1}/PKG-INFO +1 -1
  2. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1/fb_python_sdk.egg-info}/PKG-INFO +1 -1
  3. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/common_types.py +1 -7
  4. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/evaluator.py +1 -27
  5. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/event_types.py +0 -1
  6. fb_python_sdk-1.2.1/release/package.json +3 -0
  7. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/tests/test_insights_enabled.py +10 -3
  8. fb_python_sdk-1.2.0/release/package.json +0 -3
  9. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/LICENSE +0 -0
  10. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/MANIFEST.in +0 -0
  11. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/README.md +0 -0
  12. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/dev-requirements.txt +0 -0
  13. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fb_python_sdk.egg-info/SOURCES.txt +0 -0
  14. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fb_python_sdk.egg-info/dependency_links.txt +0 -0
  15. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fb_python_sdk.egg-info/requires.txt +0 -0
  16. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fb_python_sdk.egg-info/top_level.txt +0 -0
  17. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/__init__.py +0 -0
  18. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/category.py +0 -0
  19. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/client.py +0 -0
  20. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/config.py +0 -0
  21. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/data_storage.py +0 -0
  22. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/event_processor.py +0 -0
  23. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/flag_change_notification.py +0 -0
  24. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/interfaces.py +0 -0
  25. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/notice_broadcaster.py +0 -0
  26. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/status.py +0 -0
  27. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/status_types.py +0 -0
  28. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/streaming.py +0 -0
  29. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/update_processor.py +0 -0
  30. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/utils/__init__.py +0 -0
  31. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/utils/exponential_backoff_jitter_strategy.py +0 -0
  32. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/utils/http_client.py +0 -0
  33. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/utils/repeatable_task.py +0 -0
  34. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/utils/rwlock.py +0 -0
  35. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/fbclient/utils/variation_splitting_algorithm.py +0 -0
  36. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/pyproject.toml +0 -0
  37. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/requirements.txt +0 -0
  38. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/setup.cfg +0 -0
  39. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/setup.py +0 -0
  40. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/tests/test_data_storage.py +0 -0
  41. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/tests/test_data_update_status_provider.py +0 -0
  42. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/tests/test_evaluator.py +0 -0
  43. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/tests/test_event_processor.py +0 -0
  44. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/tests/test_fbclient.py +0 -0
  45. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/tests/test_flag_change_notification.py +0 -0
  46. {fb_python_sdk-1.2.0 → fb_python_sdk-1.2.1}/tests/test_runtime_safety.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fb-python-sdk
3
- Version: 1.2.0
3
+ Version: 1.2.1
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fb-python-sdk
3
- Version: 1.2.0
3
+ Version: 1.2.1
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
@@ -285,7 +285,6 @@ class _EvalResult:
285
285
  id: str,
286
286
  value: Optional[str],
287
287
  reason: str,
288
- is_send_to_expt: bool = False,
289
288
  key_name: Optional[str] = None,
290
289
  name: Optional[str] = None,
291
290
  flag_type: Optional[str] = 'string'):
@@ -293,14 +292,13 @@ class _EvalResult:
293
292
  self.__id = id
294
293
  self.__value = value
295
294
  self.__reason = reason
296
- self.__is_send_to_expt = is_send_to_expt
297
295
  self.__key_name = key_name
298
296
  self.__name = name
299
297
  self.__flag_type = flag_type
300
298
 
301
299
  @staticmethod
302
300
  def error(default_value: Optional[str], reason: str, key_name: Optional[str] = None, flag_type: Optional[str] = 'string'):
303
- return _EvalResult(__NO_VARIATION__, default_value, reason, False, key_name if key_name else __FLAG_KEY_UNKNOWN__, __FLAG_NAME_UNKNOWN__, flag_type)
301
+ return _EvalResult(__NO_VARIATION__, default_value, reason, key_name if key_name else __FLAG_KEY_UNKNOWN__, __FLAG_NAME_UNKNOWN__, flag_type)
304
302
 
305
303
  @property
306
304
  def id(self) -> str:
@@ -314,10 +312,6 @@ class _EvalResult:
314
312
  def reason(self) -> str:
315
313
  return self.__reason
316
314
 
317
- @property
318
- def is_send_to_expt(self) -> bool:
319
- return self.__is_send_to_expt
320
-
321
315
  @property
322
316
  def key_name(self) -> Optional[str]:
323
317
  return self.__key_name
@@ -66,8 +66,6 @@ __IS_IN_SEGMENT_CLAUSE__ = 'User is in segment'
66
66
 
67
67
  __NOT_IN_SEGMENT_CLAUSE__ = 'User is not in segment'
68
68
 
69
- __EXPT_KEY_PREFIX__ = "expt"
70
-
71
69
 
72
70
  class Evaluator:
73
71
  def __init__(self,
@@ -96,7 +94,7 @@ class Evaluator:
96
94
  if er is not None:
97
95
  log.info('FB Python SDK: User %s, Feature Flag %s, Flag Value %s' % (user.get('KeyId'), er.key_name, er.value))
98
96
  # Match the server default: only an explicit boolean false
99
- # disables insights; evaluation and experiment eligibility stay unchanged.
97
+ # disables insights; evaluation stays unchanged.
100
98
  if fb_event is not None and flag.get('insightsEnabled') is not False:
101
99
  fb_event.add(FlagEventVariation(er))
102
100
 
@@ -106,7 +104,6 @@ class Evaluator:
106
104
  return _EvalResult(flag['disabledVariationId'],
107
105
  flag['variationMap'][flag['disabledVariationId']],
108
106
  REASON_FLAG_OFF,
109
- False,
110
107
  flag['key'],
111
108
  flag['name'],
112
109
  flag['variationType'])
@@ -119,7 +116,6 @@ class Evaluator:
119
116
  return _EvalResult(target['variationId'],
120
117
  flag['variationMap'][target['variationId']],
121
118
  REASON_TARGET_MATCH,
122
- flag['exptIncludeAllTargets'],
123
119
  flag['key'],
124
120
  flag['name'],
125
121
  flag['variationType'])
@@ -269,36 +265,14 @@ class Evaluator:
269
265
  key_name: str,
270
266
  name: str) -> Optional[_EvalResult]:
271
267
 
272
- def is_send_to_expt(dispatch_key: str,
273
- rollout: dict,
274
- expt_include_all_targets: bool,
275
- rule_inclued_in_expt: bool) -> bool:
276
- if expt_include_all_targets:
277
- return True
278
- if rule_inclued_in_expt:
279
- send_to_expt_percentage = rollout['exptRollout']
280
- splitting_percentage = rollout['rollout'][1] - rollout['rollout'][0]
281
-
282
- if send_to_expt_percentage == 0 or splitting_percentage == 0:
283
- return False
284
-
285
- upper_bound = send_to_expt_percentage / splitting_percentage
286
- if upper_bound > 1:
287
- upper_bound = 1
288
- new_dispatch_key = "".join((__EXPT_KEY_PREFIX__, dispatch_key))
289
- return VariationSplittingAlgorithm(new_dispatch_key, [0, upper_bound]).is_key_belongs_to_percentage()
290
- return False
291
-
292
268
  dispatch_key = rollout_variations.get('dispatchKey')
293
269
  dispatch_key = dispatch_key if dispatch_key else 'keyid'
294
270
  dispatch_key_value = "".join((flag['key'], user.get(dispatch_key, ""))) # type: ignore
295
271
  for rollout in rollout_variations['variations']:
296
272
  if VariationSplittingAlgorithm(dispatch_key_value, rollout['rollout']).is_key_belongs_to_percentage(): # type: ignore
297
- send_to_expt = is_send_to_expt(dispatch_key_value, rollout, flag['exptIncludeAllTargets'], rollout_variations['includedInExpt']) # type: ignore
298
273
  return _EvalResult(rollout['id'],
299
274
  flag['variationMap'][rollout['id']],
300
275
  reason,
301
- send_to_expt,
302
276
  key_name,
303
277
  name,
304
278
  flag['variationType'])
@@ -121,7 +121,6 @@ class FlagEvent(FBEvent):
121
121
  arr = []
122
122
  for variation in self.__variations:
123
123
  flag_json_dict = {'featureFlagKey': variation.variation.key_name,
124
- 'sendToExperiment': variation.variation.is_send_to_expt,
125
124
  'timestamp': variation.timestamp,
126
125
  'variation': {
127
126
  'id': variation.variation.id,
@@ -0,0 +1,3 @@
1
+ {
2
+ "version":"1.2.1"
3
+ }
@@ -98,7 +98,7 @@ def test_external_json_preserves_insights_setting(setting):
98
98
  ('ff-evaluation-test', {'key': 'rule-user', 'graduated': 'true'}),
99
99
  ('ff-evaluation-test', {'key': 'fallthrough-user'}),
100
100
  ])
101
- def test_insights_does_not_change_evaluation_or_experiment_eligibility(client, key, user):
101
+ def test_insights_does_not_change_evaluation(client, key, user):
102
102
  sync(client, payload(True))
103
103
  flag = client._get_flag_internal(key)
104
104
  user = FBUser.from_dict(dict(user, name='Test User'))
@@ -107,9 +107,16 @@ def test_insights_does_not_change_evaluation_or_experiment_eligibility(client, k
107
107
  flag = dict(flag, insightsEnabled=False)
108
108
  disabled_event = FlagEvent(user)
109
109
  after = client._evaluator.evaluate(flag, user, disabled_event)
110
- assert (after.id, after.value, after.reason, after.is_send_to_expt) == (
111
- before.id, before.value, before.reason, before.is_send_to_expt)
110
+ assert (after.id, after.value, after.reason) == (
111
+ before.id, before.value, before.reason)
112
112
  assert enabled_event.is_send_event
113
+ reported = enabled_event.to_json_dict()['variations'][0]
114
+ assert reported == {
115
+ 'featureFlagKey': key,
116
+ 'timestamp': reported['timestamp'],
117
+ 'variation': {'id': before.id, 'value': before.value, 'reason': before.reason},
118
+ }
119
+ assert isinstance(reported['timestamp'], int)
113
120
  assert not disabled_event.is_send_event
114
121
 
115
122
 
@@ -1,3 +0,0 @@
1
- {
2
- "version":"1.2.0"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes