Add Audiences to OptimizelyConfig and expose in OptimizelyExperiment#342
Add Audiences to OptimizelyConfig and expose in OptimizelyExperiment#342The-inside-man merged 65 commits intomasterfrom
Conversation
- assertRaisesRegexp -> assertRaisesRegex
- assertEquals -> assertEqual
- isAlive() -> is_alive()
- Check added to base.py to confirm attribute assertRaisesRegex for backwards compatibility to Python2.7
…key and environment_key. Move decide tests to test_user_context from test_optimizely.
|
Looks like some CI issues pulling in python files... @msohailhussain is this part of what you were talking about with some failures? |
|
As draft for now (Used a label) But please take a look at let me know thoughts. |
|
Found the issue. Fixing shortly |
jaeopt
left a comment
There was a problem hiding this comment.
I see some confusions about OptimizelyConfig entities and ProjectConfig entities. See my comments to clarify them.
optimizely/optimizely_config.py
Outdated
| audiences_map[audience.get('id')] = audience.get('name') | ||
|
|
||
| # Updating each OptimizelyExperiment based on the ID from entities.Experiment found in the experiment_key_map | ||
| for ent_exp in project_config.experiment_key_map.values(): |
There was a problem hiding this comment.
This covers "experiment" rules. We also need to do the same to experiments in rollout ("delivery" rules) as well.
There was a problem hiding this comment.
Delivery Rules added to OptimizelyConfig and test cases to cover
…utes list and events list.
… one operand and one ID, remove unneed get for delivery_rules.
optimizely/optimizely_config.py
Outdated
| def get_delivery_rules(self): | ||
| """ Get the delivery rules list associated with OptimizelyConfig | ||
|
|
||
| Returns: | ||
| List of OptimizelyExperiments as DeliveryRules from Rollouts. | ||
| """ | ||
| return self.delivery_rules | ||
|
|
There was a problem hiding this comment.
This function isnt needed, I meant to remove. Thanks for spotting!
tests/base.py
Outdated
| 'delivery_rules': [], | ||
| 'experiment_rules': [], |
There was a problem hiding this comment.
The testing in Python will fail if these are not there because it compares the expected_config which is a dict of the OptimizelyConfig with the actual_config, a dict of the actual OptimizelyConfig. Base.py homes other scenarios to create OptimizelyConfig which it compares those dicts directly with. If that makes sense. We can chat more if you like.
|
@jaeopt All changes and concerns addressed. Please see me comments. |
jaeopt
left a comment
There was a problem hiding this comment.
All changes look good. We can discuss a couple of more issues tomorrow.
tests/base.py
Outdated
| 'delivery_rules': [], | ||
| 'experiment_rules': [], |
There was a problem hiding this comment.
It looks like a wrong place to add them. We can discuss.
optimizely/optimizely_config.py
Outdated
| def get_delivery_rules(self): | ||
| """ Get the delivery rules list associated with OptimizelyConfig | ||
|
|
||
| Returns: | ||
| List of OptimizelyExperiments as DeliveryRules from Rollouts. | ||
| """ | ||
| return self.delivery_rules | ||
|
|
There was a problem hiding this comment.
I also have questions about other get functions other than get_datafile().
|
removed experiment_rules and delivery_rules from base.py and all good now. |
jaeopt
left a comment
There was a problem hiding this comment.
All changes look good except that get functions not cleaned up yet.
|
Changes are fine. |
|
Prod Suite with updated test app not using getter for sdk_key and environment_key: https://travis-ci.com/github/optimizely/fullstack-prod-suite/builds/232876085 |
|
FSC Suite - Using updated Test App not using getts for sdk_key or environment_key: https://travis-ci.com/github/optimizely/fullstack-sdk-compatibility-suite/builds/232876040 |
…y for another edge case ['and'], changed method to combine typed_audiences and audiences from project_config to use lookup map rather than build a list and check length. Reduces time complexity.
| The typed_audiences has higher precedence. | ||
| ''' | ||
|
|
||
| typed_audiences = project_config.typed_audiences[:] |
There was a problem hiding this comment.
@The-inside-man Minor, but we don't mutate typed_audiences and thus can do a reference copy.
There was a problem hiding this comment.
Good point! Thanks for catching that!
Summary
The “why”, or other context.
Test plan
Issues