Refact: Refactored Forced decision#365
Refact: Refactored Forced decision#365msohailhussain merged 7 commits intompirnovar/forced_decisionsfrom
Conversation
| self.variation_variable_usage_map = {} | ||
| self.variation_id_map_by_experiment_id = {} | ||
| self.variation_key_map_by_experiment_id = {} | ||
| self.flag_variations_map = {} |
There was a problem hiding this comment.
holding this PR for now...
optimizely/project_config.py
Outdated
|
|
||
| return rollout_experiments | ||
|
|
||
| def get_rules_for_flag(self, feature_flag): |
There was a problem hiding this comment.
doesn't make sense to add this method.
optimizely/project_config.py
Outdated
| if rollout: | ||
| rollout_experiments = rollout.experiments | ||
| for exp in rollout_experiments: | ||
| rules.append(self.experiment_id_map[exp['id']]) |
There was a problem hiding this comment.
I understand experiment_id_map is for ab-tests only, not including rollout rules. Did it pass our tests?
There was a problem hiding this comment.
All unit tests and FSC is passing.
optimizely/project_config.py
Outdated
|
|
||
| self.feature_key_map = self._generate_key_map(self.feature_flags, 'key', entities.FeatureFlag) | ||
|
|
||
| self.flag_variations_map = self.generate_feature_variation_map(self.feature_flags) |
optimizely/decision_service.py
Outdated
| decision_variation = None | ||
|
|
||
| if experiment: | ||
| # variation, variation_reasons = self.get_variation_from_experiment_rule( |
There was a problem hiding this comment.
Should we remove commented out code?
optimizely/decision_service.py
Outdated
| decision_variation = None | ||
|
|
||
| if experiment: | ||
| # variation, variation_reasons = self.get_variation_from_experiment_rule( |
There was a problem hiding this comment.
Remove this commented code
There was a problem hiding this comment.
I was testing this code with travis. Will remove it on finalization.
optimizely/project_config.py
Outdated
|
|
||
| if rollout and rollout.experiments: | ||
| experiments.extend(rollout_experiments) | ||
| # Dict containing map of experiment ID to feature ID. |
There was a problem hiding this comment.
| # Dict containing map of experiment ID to feature ID. | |
| # Dictionary containing dictionary of experiment ID to feature ID. |
| # Dict containing map of experiment ID to feature ID. | ||
| # for checking that experiment is a feature experiment or not. | ||
| self.experiment_feature_map = {} | ||
| for feature in self.feature_key_map.values(): |
There was a problem hiding this comment.
Why are we running this loop again see line 127 can we reuse it?
The-inside-man
left a comment
There was a problem hiding this comment.
All lgtm, seems a few tests are failing in CI for pypy3, even after rerunning several times. I dont see this as a concern right now and can be addressed later as this seems to be a common issue with these versions of Python.
true. |
* add maps to project config * initial code * feat: add remaining implementation * WIP: addressed implementation PR comments and fixed failing unit tests * Fixed lint errors * fix failing tests in py 3.5 * fixed failing logger import for Py2 * add OptimizelyDecisionContext and OptmizelyForcedDecisions * testcases added * Update optimizely/optimizely_user_context.py Co-authored-by: ozayr-zaviar <54209343+ozayr-zaviar@users.noreply.github.com> * Update optimizely/optimizely_user_context.py Co-authored-by: ozayr-zaviar <54209343+ozayr-zaviar@users.noreply.github.com> * Update optimizely/optimizely_user_context.py Co-authored-by: ozayr-zaviar <54209343+ozayr-zaviar@users.noreply.github.com> * make rule key optional in OptimizelyDecisionContext * Mutex lock and testcases added * Update optimizely/optimizely_user_context.py Co-authored-by: ozayr-zaviar <54209343+ozayr-zaviar@users.noreply.github.com> * use get() vs [] in remove_forced_decision * add missing colon * fix displaying reasons * Update optimizely/optimizely.py Co-authored-by: Jae Kim <45045038+jaeopt@users.noreply.github.com> * address PR comments * more PR review fixes * fixed few more PR comments * added bucket reasons * FSC fixes * addressed more PR comments, fixed FSC test failuer about impressin events * address more PR comments * use is_valid check on opti client * addressed more PR comments * reasons and key name fixed * create get_default method for empty experiment object * fixed further PR comments * fix logger so we use the top logger in optimizely client * Refact: Refactored Forced decision (#365) * project config refactor * use existing loop to generate flag_variation_map * get_variation_from_experiment_rule and get_variation_from_delivery_rule removed * fsc test fix * comment addressed * commented code removed * comments from main forced decision PR resolved Co-authored-by: ozayr-zaviar <uzairzaviar@gmail.com> * coupl of corrections * remove check on config * remove redundant import * remove redundant test about invalid datafile * add reasons to return Co-authored-by: ozayr-zaviar <uzairzaviar@gmail.com> Co-authored-by: ozayr-zaviar <54209343+ozayr-zaviar@users.noreply.github.com> Co-authored-by: Jae Kim <45045038+jaeopt@users.noreply.github.com> Co-authored-by: msohailhussain <mirza.sohailhussain@gmail.com>
Summary
get_variation_from_experiment_ruleandget_variation_from_delivery_rulefrom decision service.flag_variations_maplogic improved using existing loops and removedget_all_variations_for_each_rule.Test plan
All FSC and unit tests should pass