[v0/v1 migration] Have flask is_feature_flag logic fetch request from context, add flag for v2/recognize/places#6155
Conversation
Summary of ChangesHello, 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 improves the developer experience for handling feature flags by reducing the need to manually pass request objects through deep call stacks. It also establishes a mechanism for A/B testing or gradual migration between API versions by implementing a configurable flag for the recognize places service. Highlights
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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a USE_V2_API feature flag to toggle between V1 and V2 versions of the recognize_places endpoint, updates the feature flag utility to automatically handle Flask request contexts, and adds the V1 endpoint to the service discovery list. I have no feedback to provide.
|
Closing in favor of separate PRs, one for the v*/recognize/places, the other for the update to is_feature_enabled() |
This PR:
is_feature_enabled()function in our flask server to fetch the request from context if available (and if an explicit request object is not provided).v1/recognize/placesandv2/recognize/places.use_v2_apiflag tofeature_flags.pyto implement the above bullet point.This will allow us to get
enable_feature=query parameter values from requests without needing to pipe in the request object through very deep stacks of calls. On the client side, we would just need to ensureenable_feature=is included in the request to flask APIs. For example, even if we are ondatacommons.org?enable_feature=use_v2_api, if that page makes a call toapi/route, we would need to update the client side code to make a call toapi/route?enable_feature=use_v2_api.Testing:
To verify this flow, I added logging statements to
dc.recognize_places()and verified that:Uses V1 API
http://localhost:8080/explore?enable_feature=enable_stat_var_autocomplete#q=jobs%20in%20texas
Uses V2 API
http://localhost:8080/explore?enable_feature=enable_stat_var_autocomplete&enable_feature=use_v2_api#q=jobs%20in%20texas
Note that this page does not make a separate request to the flask apis, so no extra
enable_feature=use_v2_apipiping was needed.