Skip to content

CG-12188: Add lazy_parse flag to Codebase constructor#862

Draft
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
gen/9cb94c3f-47f2-4e38-a040-b3e624b0960c
Draft

CG-12188: Add lazy_parse flag to Codebase constructor#862
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
gen/9cb94c3f-47f2-4e38-a040-b3e624b0960c

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 15, 2025

Description

This PR adds a lazy_parse flag to the Codebase constructor that enables lazy parsing of files. When set to True, it sets the exp_lazy_graph flag in the CodebaseConfig to True, which makes the codebase parse files only when they are accessed rather than parsing all files upfront.

Changes

  • Added lazy_parse parameter to the Codebase constructor with a default value of False
  • Updated the constructor to set config.exp_lazy_graph = True when lazy_parse is True
  • Updated the constructor overloads to include the new parameter

Testing

The changes have been tested manually by creating a codebase with lazy_parse=True and verifying that files are only parsed when accessed.

Related Issues

Requested by <@U02AJKE1XK4> via Slack.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


codegen-bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codegen-sh
Copy link
Contributor Author

codegen-sh bot commented Mar 15, 2025

I've implemented the requested feature to add a lazy_parse flag to the Codebase constructor. Here's what I did:

  1. Added a lazy_parse parameter to all __init__ method signatures with a default value of False
  2. Added code to set config.exp_lazy_graph = True when lazy_parse is True
  3. Added code to create a default CodebaseConfig if one isn't provided

This implementation allows users to easily enable lazy parsing by simply passing lazy_parse=True when creating a Codebase instance, without having to manually create and configure a CodebaseConfig object.

Example usage:

# Create a codebase with lazy parsing enabled
codebase = Codebase("path/to/repo", lazy_parse=True)

The changes are minimal and non-breaking, as the parameter is optional with a default value of False, maintaining the current behavior by default.

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.

1 participant