Skip to content

[v0/v1 migration] Gate v2/recognize/places behind feature flag#6156

Merged
juliawu merged 10 commits intodatacommonsorg:masterfrom
juliawu:flag-ranking-places
Apr 1, 2026
Merged

[v0/v1 migration] Gate v2/recognize/places behind feature flag#6156
juliawu merged 10 commits intodatacommonsorg:masterfrom
juliawu:flag-ranking-places

Conversation

@juliawu
Copy link
Copy Markdown
Contributor

@juliawu juliawu commented Mar 31, 2026

This PR puts the change made by Rohit in #6139 behind the use_v2_api feature flag.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 introduces a feature flag mechanism to manage the transition between v1 and v2 API endpoints for place recognition. By gating the v2 endpoint behind the use_v2_api flag, the system ensures backward compatibility and provides a controlled rollout path for the updated service.

Highlights

  • Feature Flag Implementation: Introduced the use_v2_api feature flag to control access to the v2 recognize places API.
  • Conditional API Routing: Updated the recognize_places function to dynamically route requests to either the v1 or v2 endpoint based on the feature flag status.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 feature flag to toggle between the v1 and v2 versions of the recognize places API. The review feedback identifies a missing constant definition that would cause an import error and recommends adding a request context check to prevent runtime errors when the code is executed outside of a Flask environment.

I am having trouble creating individual review comments. Click here to see my feedback.

server/services/datacommons.py (42)

high

The constant USE_V2_API is not defined in server/lib/feature_flags.py. This will cause an ImportError when the server attempts to start. Please ensure the constant is defined in the feature flags library (e.g., USE_V2_API = 'use_v2_api').

server/services/datacommons.py (731)

medium

Accessing the request object directly here can lead to a RuntimeError if recognize_places is called outside of a Flask request context. Additionally, when using the v2observation API, ensure the 'value' field is included in the 'select' list, as it is required to return any data. Please update the request logic accordingly.

  if is_feature_enabled(USE_V2_API, request=request if has_request_context() else None):
References
  1. The v2observation API requires the 'value' field to be present in the 'select' list to return any data, even if the 'value' field itself is not used.

@juliawu
Copy link
Copy Markdown
Contributor Author

juliawu commented Mar 31, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 new feature flag, USE_V2_API, to conditionally switch between V1 and V2 endpoints for the recognize_places service. Feedback identifies a potential RuntimeError if the code runs outside a Flask application context and a bug regarding query casing in the response, as V1 endpoints typically require lowercased keys while V2 does not. A code suggestion was provided to address these issues by adding context checks and version-specific key handling.

Comment thread server/services/datacommons.py Outdated
Copy link
Copy Markdown
Contributor

@rohitkumarbhagat rohitkumarbhagat left a comment

Choose a reason for hiding this comment

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

Thanks Julia!

@nick-nlb
Copy link
Copy Markdown
Contributor

nick-nlb commented Apr 1, 2026

Quick note: the failing test here is just a python lint request via run_test.sh -f

@juliawu juliawu merged commit 2d8cac8 into datacommonsorg:master Apr 1, 2026
13 checks passed
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