Skip to content

Conversation

@chalmerlowe
Copy link
Collaborator

@chalmerlowe chalmerlowe commented Sep 16, 2025

This PR adds a _client_helpers.py.j2 template to create helper capabilities.

NOTE: This template supports an Alpha release version of a simple microgenerator. It is being merged into a development branch (autogen) for testing and review purposes, not into main.

Migrates the empty __init__.py file to the microgenerator package.
Introduces the CodeAnalyzer class and helper functions for parsing Python code using the ast module. This provides the foundation for understanding service client structures.
    Implements functions to analyze Python source files, including:
    - Filtering classes and methods based on configuration.
    - Building a schema of request classes and their arguments.
    - Processing service client files to extract relevant information.
…ke_case function in name_utils.py to correctly convert PascalCase names containing acronyms to snake_case.
…l template containing helper macros for the client generation.
@chalmerlowe chalmerlowe requested review from a team as code owners September 16, 2025 13:13
@chalmerlowe chalmerlowe requested review from PhongChuong and removed request for a team September 16, 2025 13:13
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Sep 16, 2025
@chalmerlowe chalmerlowe added this to the µgen PoC milestone Sep 16, 2025
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Sep 16, 2025
Base automatically changed from feat/adds-client-template to autogen October 1, 2025 20:50
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Oct 6, 2025
Copy link
Collaborator Author

@chalmerlowe chalmerlowe left a comment

Choose a reason for hiding this comment

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

minor updates.

@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: m Pull request size is medium. labels Oct 6, 2025
#}

# --- HELPER METHODS ---
def _parse_dataset_path(self, dataset_path: str) -> Tuple[Optional[str], str]:

Choose a reason for hiding this comment

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

Are these helper functions going to be included in every generated client or is the inclusion of each individual function done on a selective basis?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for checking.

There is only one generated client and these three helper functions will be included one time via jinja templating imports in the file that the client class is placed in.

For context: The purpose of this microgenerator is to create code that will support customer transition from using a strictly handwritten BigQuery (BQ) library to using a GAPIC generated BQ library. Specifically it will allow the customer to use a single BigQueryClient instead of using seven very disparate *ServiceClients (e.g. JobServiceClient, TableServiceClient, ModelServiceClient) AND to do so in a way that feels very similar to how they use BigQuery now.

To help facilitate this, a proxy of certain attributes associated with each *ServiceClient will be added to new a centralized BigQueryClient and provide a passthrough so that users can use the attribute they want (e.g. JobServiceClient.list_jobs(), DatasetServiceClient.get_dataset(), TableServiceClient.update_table()) in the ServiceClient they want.

Our helpers are present so that customer can provide the BigQueryClient method calls with strings that can be parsed and passed successfully to the underlying attributes.

As an example, without the centralized BigQueryClient and the helpers:

To use TableServiceClient.list_tables(), the customer would need to instantiate a ListTableRequest() object which will require the customer to pass in info such as the project_id and dataset_id.

req = ListTableRequest(project="proj_id", dataset="dataset_id")
tableClient = TableServiceClient.list_tables(request=req)

For the past ten years, customers have not needed to do that extra step.

With the new BigQueryClient, the passthrough methods, and the helpers, the customer will have a user experience much closer to what they are used to, for example:

bqClient = BigQueryClient.list_tables("proj_id.dataset_id")

Our helpers take strings similar to proj_id.dataset_id and create an appropriate *Request object that is passed invisibly on behalf of the customer.

It may seem like a little thing, but it will hopefully ease the transition to using the new GAPIC generated library.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gkevinzheng see above.

@gkevinzheng
Copy link

LGTM

@chalmerlowe chalmerlowe merged commit a309a79 into autogen Oct 6, 2025
21 checks passed
@chalmerlowe chalmerlowe deleted the feat/adds-client-helpers-template branch October 6, 2025 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants