Skip to content

Conversation

@rohitkumarbhagat
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rohitkumarbhagat, 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 modernizes the Data Commons API wrapper by completely removing all legacy V1 API code paths. The utility now exclusively supports and enforces the use of the Data Commons V2 API, which simplifies the codebase by eliminating conditional logic and V1-specific implementations. This change enhances maintainability and ensures a consistent approach to interacting with the Data Commons platform.

Highlights

  • V1 API Code Path Removal: All functions, imports, and logic specifically supporting the Data Commons V1 API have been removed from dc_api_wrapper.py. This includes the datacommons library import, V1-specific API root management, and conditional V1 API calls for various data fetching and reconciliation operations.
  • Exclusive V2 API Enforcement: A new internal function, _validate_v2_config, has been introduced and integrated into all public-facing API wrapper functions. This function strictly enforces that only the Data Commons V2 API can be used, raising a ValueError if any configuration attempts to specify a non-V2 API version.
  • Codebase Simplification: The removal of V1 API support has significantly simplified the dc_api_wrapper.py file. Conditional logic for handling different API versions has been eliminated, leading to a more streamlined and maintainable codebase.
  • Updated Test Suite: The accompanying test file, dc_api_wrapper_test.py, has been updated to reflect these changes. V1-specific tests have been removed, API calls are now mocked to simulate V2 behavior, and new tests have been added to verify the V2 API enforcement mechanism.
Changelog
  • util/dc_api_wrapper.py
    • Removed datacommons library import and related V1 API functions (_dc_api_get_node_property_v1, dc_api_v1_get_node_property_values).
    • Introduced _validate_v2_config to enforce V2 API usage across all relevant functions.
    • Simplified _invoke_dc_api by removing the api_root parameter and global API root management.
    • Updated docstrings to reflect V2-only API support.
    • Replaced dc.utils._MAX_LIMIT with _DEFAULT_BATCH_SIZE for API batching.
    • Refactored dc_api_is_defined_dcid, dc_api_get_node_property, dc_api_get_node_property_values, and dc_api_resolve_placeid to exclusively use V2 API calls.
  • util/dc_api_wrapper_test.py
    • Removed datacommons library import.
    • Updated test_dc_api_wrapper and test_dc_api_batched_wrapper to use mock objects for API calls.
    • Removed test_invoke_dc_api_restores_api_root_on_exception.
    • Added test_invoke_dc_api to test the simplified API invocation helper.
    • Added test_dc_api_resolve_latlng_v1_compat_shape to ensure V1 compatibility in response shape for latlng resolution.
    • Added test_non_v2_config_rejected to verify that non-V2 configurations are correctly rejected with a ValueError.
Activity
  • The pull request was created by rohitkumarbhagat, initiating the process of removing V1 code paths and standardizing on the V2 Data Commons API.
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.

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

  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
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 does a great job of removing the V1 API code paths from dc_api_wrapper.py, which significantly simplifies the module and improves maintainability. The corresponding test file has also been updated to remove dependencies on the V1 library and use mocks, which is a great improvement for test reliability and speed. I've provided a few suggestions to further improve consistency and maintainability, including a recommendation to mock live API calls in tests to prevent flakiness.

@rohitkumarbhagat rohitkumarbhagat merged commit 09203f6 into datacommonsorg:master Feb 9, 2026
9 checks passed
@rohitkumarbhagat rohitkumarbhagat deleted the sg-migrate-dc-api-wrapper branch February 9, 2026 08:08
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.

2 participants