Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.9'

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.9'

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.9'

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down Expand Up @@ -201,12 +201,13 @@ jobs:
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--base_path=tests/cicd/generate_docstring \
--disable_telemetry

- name : Generate Diagram
run: |
poetry run patchwork GenerateDiagram --log debug \
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \
--folder_path=patchwork/steps \
--disable_telemetry

- name: Generate UnitTests
Expand Down
16 changes: 12 additions & 4 deletions patchwork/common/client/scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import gitlab.const
from attrs import define
from github import Auth, Consts, Github, GithubException, PullRequest
from github.GithubException import UnknownObjectException
from gitlab import Gitlab, GitlabAuthenticationError, GitlabError
from gitlab.v4.objects import ProjectMergeRequest
from giturlparse import GitUrlParsed, parse
Expand Down Expand Up @@ -333,13 +334,20 @@ def reset_comments(self) -> None:
comment.delete()

def texts(self) -> PullRequestTexts:
comments = []
for comment in chain(self._pr.get_review_comments(), self._pr.get_issue_comments()):
try:
# Copilot user throws here
user = comment.user.name
except UnknownObjectException:
user = comment.user.login

comments.append(dict(user=user, body=comment.body))

return dict(
title=self._pr.title or "",
body=self._pr.body or "",
comments=[
dict(user=comment.user.name, body=comment.body)
for comment in itertools.chain(self._pr.get_comments(), self._pr.get_issue_comments())
],
comments=comments,
# None checks for binary files
diffs={file.filename: file.patch for file in self._pr.get_files() if file.patch is not None},
)
Expand Down
15 changes: 4 additions & 11 deletions patchwork/patchflows/GenerateDiagram/GenerateDiagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,23 @@ def __init__(self, inputs):
final_inputs.update(inputs)

final_inputs["prompt_id"] = "GenerateDiagram"
if "folder_path" not in final_inputs.keys():
final_inputs["folder_path"] = Path.cwd()
else:
final_inputs["folder_path"] = Path(final_inputs["folder_path"])

print(final_inputs["folder_path"])

if "prompt_template_file" not in final_inputs:
final_inputs["prompt_template_file"] = _DEFAULT_PROMPT_JSON

final_inputs["pr_title"] = f"PatchWork System Architecture Diagram generated"
final_inputs["pr_title"] = f"PatchWork System Architecture Diagram"
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"

validate_steps_with_inputs(
set(final_inputs.keys()).union({"prompt_values","files_to_patch"}), LLM, CallCode2Prompt,ModifyCode,PR
)

self.base_path = final_inputs["base_path"]
self.inputs = final_inputs

def run(self):
outputs = CallCode2Prompt(self.inputs).run()
new_file_name = f"diagram.md"
new_file_path = Path(outputs['uri']).with_name(new_file_name)
Path(outputs['uri']).rename(new_file_path)
outputs['uri'] = str(new_file_path)
outputs['uri'] = self.base_path
self.inputs["response_partitions"] = {"patch": ["```", "\n", "```"]}
self.inputs["files_to_patch"] = self.inputs["prompt_values"] = [outputs]
outputs = LLM(self.inputs).run()
Expand Down
4 changes: 2 additions & 2 deletions patchwork/patchflows/GenerateDiagram/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# model_top_p: 0.95
# model_max_tokens: 2000

# folder_path : path/to/folder/with/class

base_path: diagram.md
folder_path: .
# CommitChanges Inputs
disable_branch: false

Expand Down
2 changes: 2 additions & 0 deletions tests/common/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_default_list_option_callback(runner):
== """\
AutoFix
DependencyUpgrade
GenerateDiagram
GenerateDocstring
GenerateREADME
GenerateUnitTests
Expand All @@ -66,6 +67,7 @@ def test_config_list_option_callback(runner, config_dir, patchflow_file):
== f"""\
AutoFix
DependencyUpgrade
GenerateDiagram
GenerateDocstring
GenerateREADME
GenerateUnitTests
Expand Down