Skip to content

feat: odp datafile parsing and audience evaluation #393

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

Merged
merged 16 commits into from
Jul 20, 2022

Conversation

andrewleap-optimizely
Copy link
Contributor

Summary

  • A new field integrations and new audience type odp.audiences will be added to the datafile schema for ODP integration.

  • parse the odp values (publicKey and host)

  • accept datafile with and without the integrations section or empty section as well.

  • support a new audience with the odp.audiences and qualified match.

  • support any (allowed) combination of audiences, including ODP and other existing audiences.

Test plan

Added/extended tests in:

  • test_optimizely_config.py
  • test_validator.py
  • test_audience.py
  • test_condition.py
  • test_user_context.py

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.

Looks great! A few small changes suggested.
More tests for datafile "integrations" processing including invalid format, missing, and empty will be good.
https://github.com/optimizely/swift-sdk/blob/jae/ats/Tests/OptimizelyTests-DataModel/IntegrationTests.swift

@@ -54,6 +54,7 @@ def __init__(
self.client = optimizely_client
self.logger = logger
self.user_id = user_id
self.qualified_segments: list[str] = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make this "qualified_segments" publicly get and set under lock-protected.
You can add this support in the other PR (OptimizelyUserContext) later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added leading underscore to indicate a private variable

Copy link
Contributor

@Mat001 Mat001 left a comment

Choose a reason for hiding this comment

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

lgtm

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.

Most changes look good. I suggested a few more changes.
Not sure about the plan for atomic (public) getter/setter in optimizely_user_context. We can chat.

evaluator = condition_helper.CustomAttributeConditionEvaluator(
qualified_condition_list, self.user_context, self.mock_client_logger,
)

self.assertStrictTrue(evaluator.evaluate(0))

def test_qualified__returns_false__when_user_is_not_qualified(self, ):
self.user_context.qualified_segments = ['odp-segment-1']
self.user_context._qualified_segments = ['odp-segment-1']
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need support for atomic getter for "qualified_segments"? like "get_user_attributes()"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, I thought we were going to implement those during a subsequent PR. I've added a getter and setter for qualified segments.

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

@andrewleap-optimizely andrewleap-optimizely merged commit d9c7905 into master Jul 20, 2022
@andrewleap-optimizely andrewleap-optimizely deleted the aleap/odp_datafile_parsing branch July 20, 2022 14:06
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.

3 participants