Skip to content

Commit 40aee1e

Browse files
committed
Add option to specify branch prefix for all patchflows used in ci
1 parent 7eaf705 commit 40aee1e

File tree

7 files changed

+42
-22
lines changed

7 files changed

+42
-22
lines changed

patchwork/patchflows/AutoFix/AutoFix.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ def __init__(self, inputs: dict):
7272
"compatibility": ["C. Compatibility Risk:", "D. Fixed Code:"],
7373
"patch": ["D. Fixed Code:", "```", "\n", "```"],
7474
}
75-
final_inputs["pr_title"] = f"PatchWork {self.__class__.__name__}"
76-
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
75+
if "pr_title" not in final_inputs.keys():
76+
final_inputs["pr_title"] = f"PatchWork {self.__class__.__name__}"
77+
78+
if "branch_prefix" not in final_inputs.keys():
79+
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
7780

7881
validate_steps_with_inputs(
7982
set(final_inputs.keys()).union({"prompt_values"}), ScanSemgrep, ExtractCode, LLM, ModifyCode, PR

patchwork/patchflows/GenerateCodeUsageExample/GenerateCodeUsageExample.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ def __init__(self, inputs):
2929
if "prompt_template_file" not in final_inputs:
3030
final_inputs["prompt_template_file"] = _DEFAULT_PROMPT_JSON
3131

32-
final_inputs["pr_title"] = f"PatchWork Usage Example generated"
33-
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
32+
if "pr_title" not in final_inputs.keys():
33+
final_inputs["pr_title"] = "PatchWork Usage Example generated"
34+
35+
if "branch_prefix" not in final_inputs.keys():
36+
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
3437

3538
validate_steps_with_inputs(
3639
set(final_inputs.keys()).union({"prompt_values", "files_to_patch"}), LLM, CallCode2Prompt, ModifyCode, PR
@@ -50,7 +53,7 @@ def run(self):
5053
outputs = ModifyCode(self.inputs).run()
5154
self.inputs.update(outputs)
5255
number = len(self.inputs["modified_code_files"])
53-
self.inputs["pr_header"] = f"This pull request adds usage example."
56+
self.inputs["pr_header"] = "This pull request adds usage example."
5457
outputs = PR(self.inputs).run()
5558
self.inputs.update(outputs)
5659

patchwork/patchflows/GenerateDiagram/GenerateDiagram.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ def __init__(self, inputs):
2525
if "prompt_template_file" not in final_inputs:
2626
final_inputs["prompt_template_file"] = _DEFAULT_PROMPT_JSON
2727

28-
final_inputs["pr_title"] = f"PatchWork System Architecture Diagram"
29-
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
28+
if "pr_title" not in final_inputs.keys():
29+
final_inputs["pr_title"] = "PatchWork System Architecture Diagram"
30+
31+
if "branch_prefix" not in final_inputs.keys():
32+
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
3033

3134
validate_steps_with_inputs(
3235
set(final_inputs.keys()).union({"prompt_values", "files_to_patch"}), LLM, CallCode2Prompt, ModifyCode, PR
@@ -44,7 +47,7 @@ def run(self):
4447
self.inputs.update(outputs)
4548
outputs = ModifyCode(self.inputs).run()
4649
self.inputs.update(outputs)
47-
self.inputs["pr_header"] = f"This pull request from patchwork generates system architecture diagram."
50+
self.inputs["pr_header"] = "This pull request from patchwork generates system architecture diagram."
4851
outputs = PR(self.inputs).run()
4952
self.inputs.update(outputs)
5053

patchwork/patchflows/GenerateDocstring/GenerateDocstring.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ def __init__(self, inputs: dict):
4747
if "prompt_template_file" not in final_inputs.keys():
4848
final_inputs["prompt_template_file"] = _DEFAULT_PROMPT_JSON
4949

50-
final_inputs["pr_title"] = f"PatchWork {self.__class__.__name__}"
51-
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
50+
if "pr_title" not in final_inputs.keys():
51+
final_inputs["pr_title"] = f"PatchWork {self.__class__.__name__}"
52+
53+
if "branch_prefix" not in final_inputs.keys():
54+
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
55+
5256
final_inputs["context_grouping"] = "FUNCTION"
5357
final_inputs["allow_overlap_contexts"] = False
5458
final_inputs["force_code_contexts"] = final_inputs.get("rewrite_existing", False)
@@ -75,9 +79,9 @@ def run(self) -> dict:
7579
self.inputs.update(outputs)
7680

7781
# Commit changes and create PR
78-
self.inputs[
79-
"pr_header"
80-
] = f'This pull request from patchwork fixes {len(self.inputs["prompt_values"])} docstrings.'
82+
self.inputs["pr_header"] = (
83+
f"This pull request from patchwork fixes {len(self.inputs['prompt_values'])} docstrings."
84+
)
8185
outputs = PR(self.inputs).run()
8286
self.inputs.update(outputs)
8387

patchwork/patchflows/GenerateREADME/GenerateREADME.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def __init__(self, inputs: dict):
5151
else:
5252
final_inputs["folder_path"] = Path(final_inputs["folder_path"])
5353

54-
final_inputs["pr_title"] = f"PatchWork {self.__class__.__name__}"
54+
if "pr_title" not in final_inputs.keys():
55+
final_inputs["pr_title"] = f"PatchWork {self.__class__.__name__}"
5556

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

patchwork/patchflows/GenerateUnitTests/GenerateUnitTests.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ def __init__(self, inputs):
2929
if "prompt_template_file" not in final_inputs:
3030
final_inputs["prompt_template_file"] = _DEFAULT_PROMPT_JSON
3131

32-
final_inputs["pr_title"] = f"PatchWork Unit Tests generated"
33-
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
32+
if "pr_title" not in final_inputs.keys():
33+
final_inputs["pr_title"] = "PatchWork Unit Tests generated"
34+
35+
if "branch_prefix" not in final_inputs.keys():
36+
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
3437

3538
validate_steps_with_inputs(
3639
set(final_inputs.keys()).union({"prompt_values", "files_to_patch"}), LLM, CallCode2Prompt, ModifyCode, PR
@@ -50,7 +53,7 @@ def run(self):
5053
outputs = ModifyCode(self.inputs).run()
5154
self.inputs.update(outputs)
5255
number = len(self.inputs["modified_code_files"])
53-
self.inputs["pr_header"] = f"This pull request from patchwork adds tests."
56+
self.inputs["pr_header"] = "This pull request from patchwork adds tests."
5457
outputs = PR(self.inputs).run()
5558
self.inputs.update(outputs)
5659

patchwork/patchflows/ResolveIssue/ResolveIssue.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ def __init__(self, inputs: dict):
2020
final_inputs = yaml.safe_load(_DEFAULT_INPUT_FILE.read_text()) or dict()
2121
final_inputs.update(inputs)
2222

23-
final_inputs["pr_title"] = f"PatchWork {self.__class__.__name__}"
24-
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
23+
if "pr_title" not in final_inputs.keys():
24+
final_inputs["pr_title"] = f"PatchWork {self.__class__.__name__}"
25+
26+
if "branch_prefix" not in final_inputs.keys():
27+
final_inputs["branch_prefix"] = f"{self.__class__.__name__.lower()}-"
2528

2629
validate_steps_with_inputs(
2730
{"issue_description"}.union(final_inputs.keys()),
@@ -46,8 +49,8 @@ def run(self) -> dict:
4649
issue=outputs["issue_description"],
4750
),
4851
system_prompt="""\
49-
You are a senior software engineer tasked to analyze a issue.
50-
Your analysis will be used to guide the junior engineer to resolve this issue.
52+
You are a senior software engineer tasked to analyze a issue.
53+
Your analysis will be used to guide the junior engineer to resolve this issue.
5154
""",
5255
user_prompt="""\
5356
<uploaded_files>
@@ -130,7 +133,7 @@ def run(self) -> dict:
130133
1. Edit the sourcecode of the repo to resolve the issue
131134
2. Think about edge cases and make sure your fix handles them as well
132135
133-
I've already taken care of all changes to any of the test files described in the PR.
136+
I've already taken care of all changes to any of the test files described in the PR.
134137
This means you DON'T have to modify the testing logic or any of the tests in any way!
135138
""",
136139
max_llm_calls=200,

0 commit comments

Comments
 (0)