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
Next Next commit
Structure Optimizely Config
  • Loading branch information
oakbani committed Dec 5, 2019
commit b46b95ee0f50678259ebaf4df82b31b25e30f489
14 changes: 14 additions & 0 deletions optimizely/optimizely.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .event_dispatcher import EventDispatcher as default_event_dispatcher
from .helpers import enums, validator
from .notification_center import NotificationCenter
from .optimizely_config import OptimizelyConfigBuilder


class Optimizely(object):
Expand Down Expand Up @@ -733,3 +734,16 @@ def get_forced_variation(self, experiment_key, user_id):

forced_variation = self.decision_service.get_forced_variation(project_config, experiment_key, user_id)
return forced_variation.key if forced_variation else None


def get_optimizely_config():
if not self.is_valid:
self.logger.error(enums.Errors.INVALID_OPTIMIZELY.format('get_optimizely_config'))
return None

project_config = self.config_manager.get_config()
if not project_config:
self.logger.error(enums.Errors.INVALID_PROJECT_CONFIG.format('get_optimizely_config'))
return None

return OptimizelyConfigBuilder.get_config()
63 changes: 63 additions & 0 deletions optimizely/optimizely_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2019, Optimizely
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class OptimizelyConfig(object):
def __init__(self, project_config):
self.revision = None
self.experiments_map = None
self.features_map = None

class OptimizelyConfigExperiment(object):
def __init__(self, id, key, variations_map):
self.id = id
self.key = key
self.variations_map = variations_map

class OptimizelyConfigFeature(object):
def __init__(self, id, key, experiments_map):
self.id = id
self.key = key
self.experiments_map = experiments_map

class OptimizelyConfigVariation(object):
def __init__(self, id, key, variables_map):
self.id = id
self.key = key
self.variables_map =

class OptimizelyConfigVariable(object):
def __init__(self, id, key, type, value):
Copy link
Contributor

Choose a reason for hiding this comment

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

type is a keyword and shadows a built in name. Would recommend naming this variable something else. May be variable_type

self.id = id
self.key = key
self.type = type
self.value = value

class OptimizelyConfigBuilder(object):

@staticmethod
def get_config():
pass

@staticmethod
def _get_features_map():
pass

@staticmethod
def _get_merged_variables_map():
pass

@staticmethod
def _get_experiments_map()
pass