Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Lazy Initialization for AI Handlers in PR Tools #528

Merged
merged 1 commit into from
Dec 17, 2023
Merged

Conversation

mrT23
Copy link
Collaborator

@mrT23 mrT23 commented Dec 17, 2023

Type

Enhancement


Description

This PR introduces lazy initialization for AI handlers in various PR tools. The main changes include:

  • The AI handler is now initialized in the run_action method rather than in the constructor of each class. This change is reflected in all the PR tools.
  • The functools.partial function is used to delay the initialization of the AI handler until it is actually needed.
  • This change enhances the performance by avoiding unnecessary instantiation of AI handlers.

PR changes walkthrough

Relevant files                                                                                                                                 
Enhancement
9 files
pr_agent.py                                                                                                 
    pr_agent/agent/pr_agent.py

    The AI handler is now initialized in the `run_action` method
    rather than in the constructor. The `functools.partial`
    function is used to delay the initialization.
+4/-2
pr_add_docs.py                                                                                           
    pr_agent/tools/pr_add_docs.py

    The AI handler is now initialized using `functools.partial`
    function.
+3/-2
pr_code_suggestions.py                                                                           
    pr_agent/tools/pr_code_suggestions.py

    The AI handler is now initialized using `functools.partial`
    function.
+3/-2
pr_description.py                                                                                     
    pr_agent/tools/pr_description.py

    The AI handler is now initialized using `functools.partial`
    function.
+3/-2
pr_generate_labels.py                                                                             
    pr_agent/tools/pr_generate_labels.py

    The AI handler is now initialized using `functools.partial`
    function.
+3/-2
pr_information_from_user.py                                                                 
    pr_agent/tools/pr_information_from_user.py

    The AI handler is now initialized using `functools.partial`
    function.
+3/-2
pr_questions.py                                                                                         
    pr_agent/tools/pr_questions.py

    The AI handler is now initialized using `functools.partial`
    function.
+3/-2
pr_reviewer.py                                                                                           
    pr_agent/tools/pr_reviewer.py

    The AI handler is now initialized using `functools.partial`
    function.
+3/-2
pr_update_changelog.py                                                                           
    pr_agent/tools/pr_update_changelog.py

    The AI handler is now initialized using `functools.partial`
    function.
+3/-2

@mrT23 mrT23 merged commit ce35add into main Dec 17, 2023
5 checks passed
@mrT23 mrT23 deleted the tr/lazy_init branch December 17, 2023 15:01
@mrT23
Copy link
Collaborator Author

mrT23 commented Dec 17, 2023

/describe

@github-actions github-actions bot changed the title Refactor AI handler instantiation to use lazy initialization in PR tools Implement Lazy Initialization for AI Handlers in PR Tools Dec 17, 2023
@github-actions github-actions bot added the enhancement New feature or request label Dec 17, 2023
Copy link
Contributor

PR Description updated to latest commit (5fb373b)

yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
Refactor AI handler instantiation to use lazy initialization in PR tools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants