diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee90bb0fc..baff1db72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/patchwork/common/client/scm.py b/patchwork/common/client/scm.py index 501078bfa..cf0f33381 100644 --- a/patchwork/common/client/scm.py +++ b/patchwork/common/client/scm.py @@ -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 @@ -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}, ) diff --git a/patchwork/patchflows/GenerateDiagram/GenerateDiagram.py b/patchwork/patchflows/GenerateDiagram/GenerateDiagram.py index 896e99bde..0062d5f4d 100644 --- a/patchwork/patchflows/GenerateDiagram/GenerateDiagram.py +++ b/patchwork/patchflows/GenerateDiagram/GenerateDiagram.py @@ -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() diff --git a/patchwork/patchflows/GenerateDiagram/defaults.yml b/patchwork/patchflows/GenerateDiagram/defaults.yml index 739bb6175..1d28b8fc2 100644 --- a/patchwork/patchflows/GenerateDiagram/defaults.yml +++ b/patchwork/patchflows/GenerateDiagram/defaults.yml @@ -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 diff --git a/tests/common/test_app.py b/tests/common/test_app.py index 85ca95cd3..4dee354bc 100644 --- a/tests/common/test_app.py +++ b/tests/common/test_app.py @@ -48,6 +48,7 @@ def test_default_list_option_callback(runner): == """\ AutoFix DependencyUpgrade +GenerateDiagram GenerateDocstring GenerateREADME GenerateUnitTests @@ -66,6 +67,7 @@ def test_config_list_option_callback(runner, config_dir, patchflow_file): == f"""\ AutoFix DependencyUpgrade +GenerateDiagram GenerateDocstring GenerateREADME GenerateUnitTests