Skip to content

chore(bigframes): refactor "generate_bigframes_bigquery.py" - #17904

Open
sycai wants to merge 23 commits into
mainfrom
sycai_generator_refactor
Open

chore(bigframes): refactor "generate_bigframes_bigquery.py"#17904
sycai wants to merge 23 commits into
mainfrom
sycai_generator_refactor

Conversation

@sycai

@sycai sycai commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Changes:

  • Separated file parsing logic from code generation, and modularized the code
  • Replaced nested dictionary with data classes for better modeling of data
  • Let the old generate_bigframes_bigquery.py call the new Python module

The old code generation CLI still works.

I generated all the code files and checked the results. The only thing changed in the output are script paths in the file comment, which is intended.

@sycai
sycai requested review from a team as code owners July 27, 2026 02:08
@sycai
sycai requested review from tswast and removed request for a team July 27, 2026 02:08
@sycai sycai changed the title chore (bigframes): refactor "generate_bigframes_bigquery.py" chore(bigframes): refactor "generate_bigframes_bigquery.py" Jul 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 refactors the BigQuery code generator by modularizing the monolithic generate_bigframes_bigquery.py script into a structured package under bigquery_generator/. The feedback is highly constructive and focuses on improving the refactored code. Key recommendations include fixing the relative script path calculation to preserve descriptive headers in generated files, using relative imports for sibling modules within the new package, explicitly specifying UTF-8 encoding when opening files, adding or correcting type hints (including a type mismatch in render_accessor), and adjusting the sys.path modification to import the generator as a proper package.

Comment thread packages/bigframes/scripts/bigquery_generator/constants.py
Comment thread packages/bigframes/scripts/bigquery_generator/__main__.py Outdated
Comment thread packages/bigframes/scripts/bigquery_generator/file_generator.py Outdated
Comment thread packages/bigframes/scripts/bigquery_generator/file_generator.py Outdated
Comment thread packages/bigframes/scripts/bigquery_generator/file_generator.py Outdated
Comment thread packages/bigframes/scripts/bigquery_generator/template_renderer.py Outdated
Comment thread packages/bigframes/scripts/bigquery_generator/yaml_parser.py Outdated
Comment thread packages/bigframes/scripts/bigquery_generator/yaml_parser.py Outdated
Comment thread packages/bigframes/scripts/bigquery_generator/yaml_parser.py Outdated
Comment thread packages/bigframes/scripts/generate_bigframes_bigquery.py Outdated
sycai and others added 16 commits July 27, 2026 02:11
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…r.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…r.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…r.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@parthea

parthea commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Please could you merge main into this branch to resolve the GitHub Actions Scan failure? See the fix in #17889

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