The Optimizely Python SDK enables developers to integrate Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts into their Python applications. It allows for server-side A/B testing, feature flagging, and personalization. The library is actively maintained with regular releases, currently at version 5.4.0.
pip install optimizely-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Optimizely client, check the status of a feature flag, make a decision on an experiment flag, and track a conversion event. It's crucial to provide a valid `datafile_json` and manage the client's lifecycle, including calling `close()` when it's no longer needed.
Review the Optimizely documentation on Advanced Audience Targeting and ODP integration. Ensure your `OptimizelyUserContext` attributes and audience definitions align with the new capabilities and requirements. Test existing experiments thoroughly.
If your application or its other dependencies require `pyOpenSSL` or `cryptography`, ensure they are explicitly installed in your environment.
Implement a robust datafile management strategy. This typically involves using a `DatafileManager` (or custom logic) to fetch the datafile from the Optimizely CDN, cache it locally, and refresh it periodically. Ensure your application handles network failures gracefully when fetching the datafile.
After upgrading, review your experiment data and user assignment reports to confirm the new, correct behavior aligns with your expectations for data integrity and experiment outcomes.