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

chore: pr summarization for releases #118

Open
wants to merge 83 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
862f524
Create _devops.py
dciborow May 11, 2023
845dc0d
"Add .deb and .venvs to .gitignore"
dciborow May 15, 2023
805d1f5
Merge branch 'main' into dciborow/devops-1
dciborow May 15, 2023
bb97e2a
Refactor DevOpsClient instantiation in update_pr method.
dciborow May 15, 2023
a99a759
Merge branch 'main' into dciborow/devops-1
dciborow May 15, 2023
5b89ec0
Add review and comment methods for DevOpsClient and refactor GitHubCl…
dciborow May 15, 2023
8f77ca2
Refactor GitHubClient import in test_review.py file.
dciborow May 15, 2023
619a5e5
Refactor: Rename _DevOpsClient to DevOpsClient and update tests
dciborow May 15, 2023
2d1ac9f
Refactor: Update function signatures and improve Azure context handling
dciborow May 16, 2023
3597b61
Refactor imports and reformat code for better readability
dciborow May 16, 2023
a3083b8
Refactor imports and improve code formatting
dciborow May 16, 2023
45b773d
Refactor DevOpsClient and add DevOpsFunction for Azure Function handling
dciborow May 16, 2023
3edee57
Fix question prompt and improve handling of changed blobs in DevOpsCl…
dciborow May 16, 2023
b013eae
Fix bug in _DevOpsClient method for creating patch list.
dciborow May 16, 2023
ffd9026
Refactor _calculate_selection method in devops.py file.
dciborow May 16, 2023
8ff8cd7
Refactor _DevOpsClient to simplify code and improve readability.
dciborow May 16, 2023
7792026
Refactor DevOpsClient get_changed_blobs method and update test.
dciborow May 16, 2023
155dcc4
Refactor imports and remove unused variables.
dciborow May 16, 2023
c865971
Refactored DevOpsFunction class and added new test cases.
dciborow May 16, 2023
e370350
Refactor test functions and add mock parameters.
dciborow May 16, 2023
177e9ac
Merge branch 'main' into dciborow/devops-1
dciborow May 16, 2023
fc66292
Fix exception handling in DevOpsFunction class.
dciborow May 16, 2023
6760978
Refactor DevOpsFunction get_patch method and add tests.
dciborow May 16, 2023
895ac84
Add CommentThreadContext typing and fix get_patch return
dciborow May 16, 2023
c8b75a8
Refactor code and add comments for readability.
dciborow May 16, 2023
b1ed6f3
"Set ADO_TOKEN environment variable in mock_ado_client fixture"
dciborow May 16, 2023
3fb7287
Refactor logging statement in _call_gpt function.
dciborow May 16, 2023
57bd479
Refactor and reorganize devops.py, update tests
dciborow May 16, 2023
a0bd278
Add support for parsing Azure DevOps URLs in devops.py.
dciborow May 16, 2023
851fb70
Merge branch 'main' into dciborow/devops-1
dciborow May 16, 2023
2b9ddf9
Refactor test_devops.py and test_gpt_cli.py files.
dciborow May 16, 2023
a096f99
Refactor test_devops.py and remove unused test_get_diff function.
dciborow May 16, 2023
60c2080
Add mock method for getting commit diffs in test_devops.py.
dciborow May 16, 2023
2ae71b1
Add __future__ import annotations and minor code formatting
dciborow May 16, 2023
c9d8382
Merge branch 'main' into dciborow/devops-1
dciborow May 16, 2023
de24fb5
Update VSCode settings, tasks, and improve Azure Functions integration
dciborow May 16, 2023
acb86df
Merge branch 'main' into dciborow/devops-1
dciborow May 16, 2023
cb8efd1
Update devcontainer, vscode config, remove future imports, and add do…
dciborow May 16, 2023
6781b40
Apply suggestions from code review
dciborow May 16, 2023
cfb610c
Apply suggestions from code review
dciborow May 16, 2023
f27d5aa
Apply suggestions from code review
dciborow May 16, 2023
cb9d5cb
Apply suggestions from code review
dciborow May 16, 2023
40a7a01
Create __init__.py
dciborow May 16, 2023
974ede5
Apply suggestions from code review
dciborow May 16, 2023
a550b9c
Merge branch 'main' into dciborow/devops-1
dciborow May 17, 2023
8e32cdc
Apply suggestions from code review
dciborow May 17, 2023
7e34fd9
Add azure-functions-core-tools-4, update methods in DevOpsClient, and…
dciborow May 17, 2023
68de50c
Add check_if_exists option and refactor patch creation in DevOpsClient
dciborow May 18, 2023
3a916c3
Add ask prompt YAML and update prompt templates, fix DevOps client me…
dciborow May 18, 2023
4b0afa9
Refactor DevOpsClient: add type hints, extract methods, and improve r…
dciborow May 19, 2023
a06e25f
Update dependencies and fix pull request diff retrieval in DevOpsClient.
dciborow May 24, 2023
31cd10e
fix last tests
dciborow May 24, 2023
6d9283d
Add default link for PR if not provided in environment variables.
dciborow May 24, 2023
9bf0975
Fix link formatting in DevOpsClient method.
dciborow May 24, 2023
b2aa3ee
Refactor DevOpsClient method to handle ADO pointers in diff PR.
dciborow May 24, 2023
3a0e9ac
Add PR diff summarization and update .gitignore, pyproject.toml
danay1999 May 24, 2023
7afc10d
Added post_summary parameter to post PR summary or return it as respo…
danay1999 May 24, 2023
3036101
Refactor pull request summarization code into functions.
danay1999 May 24, 2023
e837d0b
Merge branch 'microsoft:main' into danay1999/pr-summarization-for-rel…
danay1999 May 25, 2023
256e215
Fix handling of pull_request_event and improve URL parsing in DevOpsC…
danay1999 May 25, 2023
5d7e3ba
Update gitignore, refactor DevOpsClient, and improve summarization logic
danay1999 May 25, 2023
a2897d5
Refactor code and add timing for summarization in DevOpsClient
danay1999 May 26, 2023
792db49
Add error handling and improve summarization functions in DevOpsClient
danay1999 May 29, 2023
e25e480
Refactor DevOpsClient methods and improve summary generation
danay1999 May 30, 2023
f2626ff
Merge branch 'main' into dciborow/devops-1
dciborow May 31, 2023
88db929
Merge branch 'dciborow/devops-1' into danay1999/pr-summarization-for-…
dciborow May 31, 2023
fbbfde6
Add GitCommitRef creation, handle abandoned PRs, and empty summary cases
danay1999 May 31, 2023
24ea7e3
Merge branch 'microsoft:main' into danay1999/pr-summarization-for-rel…
danay1999 May 31, 2023
8735aa2
Refactor code, add PR summary prompt, and fix minor issues in gpt_review
danay1999 Jun 2, 2023
b30d641
Refactor code to use Azure DevOps instead of MSDATA.
danay1999 Jun 5, 2023
9e5ec76
Add support for summarizing PR diffs, batch summaries, and deployment…
danay1999 Jun 7, 2023
26f5424
Improve diff algorithm and fix patch generation in DevOpsClient
danay1999 Jun 13, 2023
e0e7cc2
Refactor diff generation and improve PR summary in DevOpsClient
danay1999 Jun 13, 2023
ce6ec7a
Refactor _get_changed_blobs method in devops.py for better readability.
danay1999 Jun 13, 2023
6900c65
moved summarizations to scripts folder
danay1999 Jun 15, 2023
9707bc4
added config file
danay1999 Jun 15, 2023
c8661ee
Delete __init__.py
danay1999 Jun 15, 2023
c6b6ed3
Delete pyproject.toml
danay1999 Jun 15, 2023
d25dde2
cleanup, and re-add removed files
danay1999 Jun 15, 2023
cf6b11d
additional cleanup
danay1999 Jun 15, 2023
930e410
additional code cleanup
danay1999 Jun 15, 2023
af2475a
final refactorings
danay1999 Jun 15, 2023
3618222
fixed create_git_pull_request_from_dict
danay1999 Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ FROM mcr.microsoft.com/devcontainers/python:3
RUN python -m pip install --upgrade pip \
&& python -m pip install 'flit>=3.8.0'

RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg \
&& mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg \
&& sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/debian/$(lsb_release -rs | cut -d'.' -f 1)/prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list' \
&& apt-get update \
&& apt-get install azure-functions-core-tools-4

ENV FLIT_ROOT_INSTALL=1

COPY pyproject.toml .
Expand Down
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,15 @@ __blobstorage__
__queuestorage__
__azurite_db*__.json
.python_packages

#summarization development
scripts/summarizations/msazure.yaml
scripts/summarizations/msdata.yaml
scripts/summarizations/msazure_pull_request_list.csv
scripts/summarizations/msdata_pull_request_list.csv
scripts/summarizations/summaries/
src/gpt_review/prompts/prompt_pr_batch_summary.yaml
src/gpt_review/prompts/prompt_nature.yaml
src/gpt_review/prompts/prompt_pr_summary.yaml


9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.diagnosticSeverityOverrides": {
"reportUndefinedVariable": "none" // Covered by Ruff F821
}
},
"azureFunctions.deploySubpath": "azure/api",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectSubpath": "azure/api"
}
29 changes: 29 additions & 0 deletions azure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
This requires < Python 3.11 to run.

Install the [Azure Function Tools](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Clinux%2Ccsharp%2Cportal%2Cbash#local-settings-file)

```sh
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

# Debian/Codespace
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/debian/$(lsb_release -rs | cut -d'.' -f 1)/prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list'

sudo apt-get update
sudo apt-get install azure-functions-core-tools-4
```

Create a new python env when testing the function.

```sh
python3.9 -m venv .venv/py39
source .venv/py39/bin/activate

python3.9 -m pip install flit
python3.9 -m flit install

cd azure/api
python 3.9
func start

```
8 changes: 8 additions & 0 deletions azure/api/.funcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git*
.vscode
__azurite_db*__.json
__blobstorage__
__queuestorage__
local.settings.json
test
.venv
1 change: 1 addition & 0 deletions azure/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import incoming_msg_handler
22 changes: 22 additions & 0 deletions azure/api/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.15.0, 4.0.0)"
},
"extensions": {
"serviceBus": {
"messageHandlerOptions": {
"autoComplete": false
}
}
}
}
24 changes: 24 additions & 0 deletions azure/api/incoming_msg_handler/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Azure DevOps API incoming message handler."""
import os

import azure.functions as func

from gpt_review.repositories.devops import DevOpsFunction

HANDLER = DevOpsFunction(
pat=os.environ["ADO_TOKEN"],
org=os.environ["ADO_ORG"],
project=os.environ["ADO_PROJECT"],
repository_id=os.environ["ADO_REPO"],
)

os.putenv("RISK_SUMMARY", "false")
os.putenv("FILE_SUMMARY_FULL", "false")
os.putenv("TEST_SUMMARY", "false")
os.putenv("BUG_SUMMARY", "false")
os.putenv("SUMMARY_SUGGEST", "false")


def main(msg: func.ServiceBusMessage) -> None:
"""Handle an incoming message."""
HANDLER.handle(msg)
12 changes: 12 additions & 0 deletions azure/api/incoming_msg_handler/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "msg",
"type": "serviceBusTrigger",
"direction": "in",
"queueName": "ado-gpt-review",
"connection": "AzureServiceBusConnectionString"
}
]
}
6 changes: 6 additions & 0 deletions azure/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# DO NOT include azure-functions-worker in this file
# The Python Worker is managed by Azure Functions platform
# Manually managing azure-functions-worker may cause unexpected issues

azure-functions
gpt-review>=0.7.0
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ dependencies = [
'azure-devops',
'azure-functions; python_version <= "3.10"',
'azure-identity',
'azure-keyvault',
'azure-keyvault-secrets',
'llama-index>=0.6.0,<=0.6.14',
'llama-index>=0.6.0,<=0.6.9',
'httpx',
'GitPython',
'knack',
Expand Down Expand Up @@ -146,7 +147,7 @@ executionEnvironments = [
]

[tool.pytest.ini_options]
addopts = "--cov-report xml:coverage.xml --cov src --cov-fail-under 0 --cov-append -n auto"
addopts = "--cov-report xml:coverage.xml --cov src --cov-fail-under 0 --cov-append"
pythonpath = [
"src"
]
Expand Down Expand Up @@ -398,4 +399,4 @@ target-version = "py311"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
max-complexity = 10
Loading