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

feat: add odp integration w client and user context #408

Merged

Conversation

Mat001
Copy link
Contributor

@Mat001 Mat001 commented Oct 12, 2022

Summary

In optimizely user context:

  • fetchQualifiedSegments()
  • qualifiedSegments { get/set }
  • is_qualified()

Optimizely client provides the following new public API: send_odp_event()

Optimizely client provides configurability of ODP services:

  • disable ODP services
  • ODP segments-cache size
  • ODP segments-cache timeout
  • update odp_config when datafile is updated
  • close(): flushes ODP event queue
  • added sdk settings and odp setup to optimizely initializer
  • added validation of sdk settings

Test plan

Unit tests in :

  • test_optimizely.py
  • test_user_context.py

Issues

@andrewleap-optimizely andrewleap-optimizely marked this pull request as draft October 12, 2022 19:02
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 changes suggested.

README.md Outdated
@@ -24,6 +24,10 @@ documentation](https://docs.developers.optimizely.com/rollouts/docs).

## Getting Started

### Requirements

Python 3.7+, PyPy 3.7+
Copy link
Contributor

Choose a reason for hiding this comment

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

4.0+: python 3.7
3.0+: python 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andrewleap-optimizely yeah, since this note is in README (applicable to all SDK versions ), maybe we add we support Py 2.7 for SDK versions < 4.0

Comment on lines 1374 to 1384
if not self.odp_manager.enabled:
self.logger.error(enums.Errors.ODP_NOT_ENABLED)
return

if self.odp_manager.odp_config.odp_state() == OdpConfigState.NOT_INTEGRATED:
self.logger.error(enums.Errors.ODP_NOT_INTEGRATED)
return

if not are_odp_data_types_valid(data):
self.logger.error(enums.Errors.ODP_INVALID_DATA)
return
Copy link
Contributor

@jaeopt jaeopt Oct 20, 2022

Choose a reason for hiding this comment

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

These error handling are all ODP specific. It looks like these can be wrapped in there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I follow, are you suggesting we move these into odp_manager.send_event?

def fetch_qualified_segments(self, user_id: str, options: Optional[list[str]] = None) -> Optional[list[str]]:
return self.odp_manager.fetch_qualified_segments(user_id, options or [])

def send_odp_event(self, type: str, action: str, identifiers: dict[str, str], data: dict[str, Any]) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we support default type (type = "fullstack")?

@@ -3,7 +3,7 @@
# 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
# http://www.apache.org/licenses/LICENSE-2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andrewleap-optimizely I can't approve the PR i created lol.
Looks good to me, nothing major stood out, I think well covered (we also went through it a few times).
(Jae may have ats specific requests.)

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 193d3c9 into master Oct 26, 2022
@andrewleap-optimizely andrewleap-optimizely deleted the mpirnovar/odp_integration_client_and_user_context branch October 26, 2022 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants