From d01cfe443c122701614bff8991e205d5f9c2058b Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sat, 7 Sep 2024 11:44:24 +0300 Subject: [PATCH] avoid_full_files --- docs/docs/usage-guide/automations_and_usage.md | 6 ++++++ pr_agent/git_providers/bitbucket_provider.py | 5 ++++- pr_agent/settings/configuration.toml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index 5ec73c14..1c6e8052 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -176,6 +176,12 @@ inline_code_comments = true Each time you invoke a `/review` tool, it will use inline code comments. + +Note that among other limitations, BitBucket provides relatively low rate-limits for applications (up to 1000 requests per hour), and does not provide an API to track the actual rate-limit usage. +If you experience lack of responses from PR-Agent, you might want to set: `bitbucket_app.avoid_full_files=true` in your configuration file. +This will prevent PR-Agent from acquiring the full file content, and will only use the diff content. This will reduce the number of requests made to BitBucket, at the cost of small decrease in accuracy, as dynamic context will not be applicable. + + ### BitBucket Self-Hosted App automatic tools To control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file: diff --git a/pr_agent/git_providers/bitbucket_provider.py b/pr_agent/git_providers/bitbucket_provider.py index 28e94d67..51ba0770 100644 --- a/pr_agent/git_providers/bitbucket_provider.py +++ b/pr_agent/git_providers/bitbucket_provider.py @@ -227,7 +227,10 @@ class BitbucketProvider(GitProvider): try: counter_valid += 1 - if counter_valid < MAX_FILES_ALLOWED_FULL // 2: # factor 2 because bitbucket has limited API calls + if get_settings().get("bitbucket_app.avoid_full_files", False): + original_file_content_str = "" + new_file_content_str = "" + elif counter_valid < MAX_FILES_ALLOWED_FULL // 2: # factor 2 because bitbucket has limited API calls if diff.old.get_data("links"): original_file_content_str = self._get_pr_file_content( diff.old.get_data("links")['self']['href']) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index d7cee294..0d99e724 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -241,7 +241,7 @@ pr_commands = [ "/review --pr_reviewer.num_code_suggestions=0", "/improve --pr_code_suggestions.commitable_code_suggestions=true --pr_code_suggestions.suggestions_score_threshold=7", ] - +avoid_full_files = false [local] # LocalGitProvider settings - uncomment to use paths other than default