Skip to content

Commit

Permalink
fix grouping issues and do rpartition on last partition instead of lp…
Browse files Browse the repository at this point in the history
…artition
  • Loading branch information
CTY-git committed Apr 8, 2024
1 parent 07c93a1 commit ae05bd1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions patchwork/steps/ExtractCode/ExtractCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def run(self) -> dict:

self.extracted_code_contexts = [
{
"uri": file_path,
"uri": str(file_path),
"startLine": start,
"endLine": end,
"affectedCode": context,
Expand All @@ -208,12 +208,11 @@ def run(self) -> dict:
# Save extracted data to JSON
output_file = Path(tempfile.mktemp(".json"))
with open(output_file, "w", encoding="utf-8") as f:
json.dump(self.extracted_data, f, indent=2)
json.dump(self.extracted_code_contexts, f, indent=2)

logger.info(f"Run completed {self.__class__.__name__}")

return dict(
prompt_value_file=output_file,
code_file=output_file,
extracted_code_contexts=self.extracted_code_contexts,
prompt_values=self.extracted_code_contexts,
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def run(self) -> dict:
_, _, extracted_response = extracted_response.partition(partition)

if partitions[-1] != "":
extracted_response, _, _ = extracted_response.partition(partitions[-1])
extracted_response, _, _ = extracted_response.rpartition(partitions[-1])

if extracted_response == "":
continue
Expand Down
3 changes: 2 additions & 1 deletion patchwork/steps/ModifyCode/ModifyCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def run(self) -> dict:
code_snippets = load_json_file(self.code_snippets_path)

modified_code_files = []
for code_snippet, extracted_response in zip(code_snippets, self.extracted_responses):
sorted_list = sorted(zip(code_snippets, self.extracted_responses), key=lambda x: x[0]["startLine"], reverse=True)
for code_snippet, extracted_response in sorted_list:
uri = code_snippet["uri"]
start_line = code_snippet["startLine"]
end_line = code_snippet["endLine"]
Expand Down

0 comments on commit ae05bd1

Please sign in to comment.