Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address comments
  • Loading branch information
oakbani committed Dec 10, 2019
commit 7709dff8c7f5fc12d73f7ab4c91bc86c9e0857ae
2 changes: 1 addition & 1 deletion optimizely/optimizely.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,4 +751,4 @@ def get_optimizely_config(self):
self.logger.error(enums.Errors.INVALID_PROJECT_CONFIG.format('get_optimizely_config'))
return None

return OptimizelyConfigService(project_config).get_optimizely_config()
return OptimizelyConfigService(project_config).get_config()
17 changes: 9 additions & 8 deletions optimizely/optimizely_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def __init__(self, id, key, feature_enabled, variables_map):


class OptimizelyVariable(object):
def __init__(self, id, key, type, value):
def __init__(self, id, key, variable_type, value):
self.id = id
self.key = key
self.type = type
self.type = variable_type
self.value = value


Expand All @@ -57,21 +57,22 @@ class OptimizelyConfigService(object):

def __init__(self, project_config):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check instance of ProjectConfig

Copy link
Contributor Author

@oakbani oakbani Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect to be used elsewhere. And in the main class, we validate project_config before using OptimizelyService. I can still validate if you so, but will have to keep a validity flag so that get_config returns nil and does not break.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my suggestion is to validate but @aliabbasrizvi will you suggest for validation here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @msohailhussain, we should validate here.

"""
Arguments:
Args:
project_config ProjectConfig
"""
self.experiments = project_config.experiments
self.feature_flags = project_config.feature_flags
self.groups = project_config.groups
self.revision = project_config.revision

def get_optimizely_config(self):
self._create_lookup_maps()

def get_config(self):
""" Returns instance of OptimizelyConfig
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gets


Returns:
Optimizely Config instance.
"""
self._create_lookup_maps()

experiments_key_map, experiments_id_map = self._get_experiments_maps()
features_map = self._get_features_map(experiments_id_map)
Expand Down Expand Up @@ -104,7 +105,7 @@ def _create_lookup_maps(self):
def _get_variables_map(self, variation, experiment):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. I personally prefer arranging this as self, experiment, variation to honor the parent child relationship between experiments and variations.

""" Gets variables map for given variation and experiment.

Arguments:
Args:
variation dict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very vague. Dict consisting of what?

experiment dict

Expand All @@ -130,7 +131,7 @@ def _get_variables_map(self, variation, experiment):
def _get_variations_map(self, experiment):
""" Gets variation map for the given experiment.

Arguments:
Args:
experiment dict

Returns:
Expand Down Expand Up @@ -188,7 +189,7 @@ def _get_experiments_maps(self):
def _get_features_map(self, experiments_id_map):
""" Gets features map for the project config.

Arguments:
Args:
experiments_id_map dict -- experiment id to OptimizelyExperiment map

Returns:
Expand Down