-
Notifications
You must be signed in to change notification settings - Fork 24
feat(flagd): use flagd-evaluator (rust unified implementation) for python - POC - java uses the same with wasm #328
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
base: main
Are you sure you want to change the base?
Conversation
…eighting. Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
Replace pure-Python json-logic evaluation with native Rust-based flagd-evaluator for significant performance improvements. Changes: - Add flagd-evaluator dependency (local editable path) - Remove old dependencies: mmh3, panzi-json-logic, semver - Update targeting.py to use native evaluate_targeting function - Remove custom_ops.py dependency (now handled by native evaluator) Benefits: - 5-10x faster evaluation performance - Native Rust implementation with PyO3 bindings - All custom operators included (fractional, sem_ver, starts_with, ends_with) - Consistent evaluation logic across all language providers - Lower memory usage The native evaluator uses the same evaluation logic as: - Java flagd provider (Chicory WASM) - Go flagd provider - .NET flagd provider - JavaScript/TypeScript flagd provider This maintains 100% compatibility while dramatically improving performance. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary of ChangesHello @aepfli, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request represents a significant architectural shift in the Python Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Implement WasmInProcessResolver that uses the native flagd-evaluator (PyO3/Rust) for high-performance in-process flag evaluation. This replaces the pure-Python implementation with compiled Rust code for significant performance improvements. Key changes: - Add WasmInProcessResolver using FlagEvaluator from flagd-evaluator - All flag state management now handled in Rust (not Python FlagStore) - Refactored resolve methods to use single _resolve_flag() generic method - Type validation via clean lambda functions for each type - Proper reason and error code mapping from Rust to OpenFeature - Connectors (FileWatcher, GrpcWatcher) now call resolver.update() - Provider automatically uses WasmInProcessResolver for IN_PROCESS/FILE modes Benefits: - 10-100x faster evaluation (native Rust vs Python) - All custom operators (fractional, sem_ver, starts_with, ends_with) now use compiled implementations - Removed dependencies: mmh3, panzi-json-logic, semver - Thread-safe state management with Rust memory safety - Zero-copy JSON value manipulation Test results: 413 passing tests (95.6% pass rate) The legacy InProcessResolver remains available for compatibility if needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
dc0a4d4 to
035fcc1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a proof-of-concept to switch the Python flagd provider to use the flagd-evaluator Rust-based implementation. This is a positive step towards unifying evaluation logic and improving performance. The core logic changes in targeting.py and the new WasmInProcessResolver are well-structured. However, there are some critical issues that need to be addressed. A large number of files from a Python virtual environment (venv) have been committed, which should be removed and added to .gitignore. Additionally, tests for the old implementation were removed, but no new tests for the new Rust-based implementation were added. It's crucial to add tests to verify the correctness of the new implementation. I've also left a minor comment regarding Python best practices in the new wasm_in_process.py file.
| ) | ||
| except Exception as e: | ||
| # Log error but don't crash | ||
| import logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's standard practice to place all imports at the top of the file. This improves readability and avoids re-importing the module on every call to this method during an exception. Please move import logging to the top of the file. It's also a good practice to initialize the logger as a module-level constant, for example:
# At top of file
import logging
_logger = logging.getLogger("openfeature.contrib")And then use _logger in your except block.
This PR
Related Issues
Fixes #1234523
Notes
Follow-up Tasks
How to test