Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Audiences to OptimizelyConfig and expose in OptimizelyExperiment #342

Merged
merged 65 commits into from
Jul 20, 2021

Conversation

The-inside-man
Copy link
Contributor

Summary

  • Add Audiences to OptimizelyConfig
  • Expose audiences string through OptimizelyExperiment
  • Add additional tests for new additions

The “why”, or other context.

Test plan

  • compatibility tests

Issues

  • “OASIS-7812"

@The-inside-man The-inside-man added the draft Work in progress label Jul 2, 2021
@The-inside-man The-inside-man requested a review from a team as a code owner July 2, 2021 19:34
@The-inside-man The-inside-man removed the request for review from a team July 2, 2021 19:34
@coveralls
Copy link

coveralls commented Jul 2, 2021

Coverage Status

Coverage increased (+0.1%) to 95.758% when pulling 6ce98e3 on jbrown/oasis-7812 into 4935717 on master.

@The-inside-man
Copy link
Contributor Author

Looks like some CI issues pulling in python files... @msohailhussain is this part of what you were talking about with some failures?

@The-inside-man
Copy link
Contributor Author

As draft for now (Used a label) But please take a look at let me know thoughts.

@The-inside-man
Copy link
Contributor Author

Found the issue. Fixing shortly

@The-inside-man The-inside-man removed the draft Work in progress label Jul 2, 2021
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

I see some confusions about OptimizelyConfig entities and ProjectConfig entities. See my comments to clarify them.

optimizely/entities.py Outdated Show resolved Hide resolved
optimizely/optimizely_config.py Outdated Show resolved Hide resolved
optimizely/optimizely_config.py Outdated Show resolved Hide resolved
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():
Copy link
Contributor

Choose a reason for hiding this comment

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

This covers "experiment" rules. We also need to do the same to experiments in rollout ("delivery" rules) as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Delivery Rules added to OptimizelyConfig and test cases to cover

optimizely/optimizely_config.py Outdated Show resolved Hide resolved
tests/test_optimizely_config.py Outdated Show resolved Hide resolved
tests/test_optimizely_config.py Outdated Show resolved Hide resolved
tests/test_optimizely_config.py Outdated Show resolved Hide resolved
… one operand and one ID, remove unneed get for delivery_rules.
optimizely/optimizely_config.py Outdated Show resolved Hide resolved
optimizely/optimizely_config.py Outdated Show resolved Hide resolved
optimizely/optimizely_config.py Outdated Show resolved Hide resolved
optimizely/optimizely_config.py Outdated Show resolved Hide resolved
optimizely/optimizely_config.py Outdated Show resolved Hide resolved
Comment on lines 82 to 89
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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function isnt needed, I meant to remove. Thanks for spotting!

tests/base.py Outdated
Comment on lines 488 to 489
'delivery_rules': [],
'experiment_rules': [],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

tests/test_optimizely_config.py Outdated Show resolved Hide resolved
tests/test_optimizely_config.py Outdated Show resolved Hide resolved
@The-inside-man
Copy link
Contributor Author

@jaeopt All changes and concerns addressed. Please see me comments.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

All changes look good. We can discuss a couple of more issues tomorrow.

tests/test_optimizely_config.py Outdated Show resolved Hide resolved
tests/base.py Outdated
Comment on lines 488 to 489
'delivery_rules': [],
'experiment_rules': [],
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like a wrong place to add them. We can discuss.

Comment on lines 82 to 89
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

Copy link
Contributor

Choose a reason for hiding this comment

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

I also have questions about other get functions other than get_datafile().

@The-inside-man
Copy link
Contributor Author

removed experiment_rules and delivery_rules from base.py and all good now.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

All changes look good except that get functions not cleaned up yet.

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM

@keppel2
Copy link

keppel2 commented Jul 15, 2021

Changes are fine.

@The-inside-man
Copy link
Contributor Author

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

@The-inside-man
Copy link
Contributor Author

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

Copy link
Contributor

@yasirfolio3 yasirfolio3 left a comment

Choose a reason for hiding this comment

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

Functionality looks good, just some minor suggestions.

optimizely/optimizely_config.py Outdated Show resolved Hide resolved
optimizely/optimizely_config.py Show resolved Hide resolved
optimizely/optimizely_config.py Show resolved Hide resolved
…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.
Copy link
Contributor

@yasirfolio3 yasirfolio3 left a comment

Choose a reason for hiding this comment

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

LGTM, just one nit.

optimizely/optimizely_config.py Outdated Show resolved Hide resolved
@The-inside-man The-inside-man merged commit 4aad6b7 into master Jul 20, 2021
@The-inside-man The-inside-man deleted the jbrown/oasis-7812 branch July 20, 2021 14:32
The typed_audiences has higher precedence.
'''

typed_audiences = project_config.typed_audiences[:]
Copy link

Choose a reason for hiding this comment

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

@The-inside-man Minor, but we don't mutate typed_audiences and thus can do a reference copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Thanks for catching that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants