codeplain 0.1.7__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codeplain-0.1.7.dist-info → codeplain-0.2.0.dist-info}/METADATA +1 -1
- {codeplain-0.1.7.dist-info → codeplain-0.2.0.dist-info}/RECORD +8 -6
- {codeplain-0.1.7.dist-info → codeplain-0.2.0.dist-info}/top_level.txt +2 -0
- diff_utils.py +32 -0
- memory_management.py +97 -0
- {codeplain-0.1.7.dist-info → codeplain-0.2.0.dist-info}/WHEEL +0 -0
- {codeplain-0.1.7.dist-info → codeplain-0.2.0.dist-info}/entry_points.txt +0 -0
- {codeplain-0.1.7.dist-info → codeplain-0.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
codeplain_REST_api.py,sha256=qfzUw9v0-NKII4ibw3vqSBrCeU2WP4RcrrEti43F3zs,18400
|
|
2
2
|
concept_utils.py,sha256=vwSY4-FmxyqaDBxhntYzqG8t9pXvAWwiULP0DYQI32o,7905
|
|
3
|
+
diff_utils.py,sha256=AjiQlqo5pRos_8hVXZo5yBurl5BzSrTMGrQv4dCtRCg,1198
|
|
3
4
|
event_bus.py,sha256=sduIR3bgIbxAbLhwKd8Gx9YN9gzaeqy9-mNupS04aKw,1759
|
|
4
5
|
file_utils.py,sha256=4BIxzsteZQOaK-efkvQcoaIfYydsQNFR6elpsxJgXLQ,11591
|
|
5
6
|
git_utils.py,sha256=gTRps6RIzJJkyy9amaDxP38FPoxYulZViBWr9V0IPQg,12414
|
|
6
7
|
hash_key.py,sha256=lMKgKpOhPeC4UpFf9e7eCNK20FEaDsXTCJ8j3eCWidE,837
|
|
8
|
+
memory_management.py,sha256=ABrM6PhOsalP_PBq2hCazQvQX9C5rpPHhgT35l68RM4,4357
|
|
7
9
|
module_renderer.py,sha256=LLjLb34phSJlF2YblwGDy5HKWVdi9mo57rr7s-Hj3RA,6261
|
|
8
10
|
plain2code.py,sha256=b0VJBnYVtpVZPx1TQZHNsnXREbhdW8V_S8TC-wWQqWw,8970
|
|
9
11
|
plain2code_arguments.py,sha256=DHbkWyB33zifROt2SQMlGUC1AZIDJXoJQHlK7Za9b7U,12024
|
|
@@ -20,7 +22,7 @@ plain_modules.py,sha256=iDqqamtix5KahMC_v-vfQ7yndugmqtBW1z6XxTB4x6w,4876
|
|
|
20
22
|
plain_spec.py,sha256=zC-VOb_UJOs8OxtEiwQJuonw7Lkmbi7YHyFvvCvUZNo,13529
|
|
21
23
|
spinner.py,sha256=Ro6Gd9Przf-whuHqPRY6HwI0T57yJjyNPbhDbigZKZE,2471
|
|
22
24
|
system_config.py,sha256=mgHLn-CRHLO9Y9vKyI_eFBreY_YhFad-ctZgBYp-rIg,1777
|
|
23
|
-
codeplain-0.
|
|
25
|
+
codeplain-0.2.0.dist-info/licenses/LICENSE,sha256=wsFi5dpbJurnRNfBj8q2RCcF3ryrmdRIfxc3lPcmc4c,1069
|
|
24
26
|
config/__init__.py,sha256=beYSsJWmBNHDP5rYmVDouqgEeP3t1lkkepbXJ-oq0F8,37
|
|
25
27
|
config/system_config.yaml,sha256=bB5Th5jxgXFyaIvceUPID1ReebMMXsyMibV4gtu9sWQ,1148
|
|
26
28
|
render_machine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -63,8 +65,8 @@ tui/plain2code_tui.py,sha256=7agVU0NnaCuF1LuOSEmjx-XfEOQ6HHr1HlWe_b1Tses,11695
|
|
|
63
65
|
tui/state_handlers.py,sha256=HbjgaV-9xGhp3E-3X114zOqPkeNcCjT-R1PbVRxVdso,12674
|
|
64
66
|
tui/styles.css,sha256=Umm2TLePmywizZGV4Nd8UezZRiK5pFyibYRbpRvGqbs,3056
|
|
65
67
|
tui/widget_helpers.py,sha256=VJorEM2PjRBzN-jIDmKJPolFgo2d8-2NmTumgC5xeNo,5229
|
|
66
|
-
codeplain-0.
|
|
67
|
-
codeplain-0.
|
|
68
|
-
codeplain-0.
|
|
69
|
-
codeplain-0.
|
|
70
|
-
codeplain-0.
|
|
68
|
+
codeplain-0.2.0.dist-info/METADATA,sha256=U3zqfTbWbKKPngFYvsjVSItzsvMhS3rM7imS2NfQcA0,4300
|
|
69
|
+
codeplain-0.2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
70
|
+
codeplain-0.2.0.dist-info/entry_points.txt,sha256=oDZkBqu9WhtZApb_K6ia8-fn9aojwmAsgnKELceX5T4,46
|
|
71
|
+
codeplain-0.2.0.dist-info/top_level.txt,sha256=gYRA2-upa9A7U9hk0tJBW2hsZeazOuU1Pi_AvJ3YD44,631
|
|
72
|
+
codeplain-0.2.0.dist-info/RECORD,,
|
|
@@ -9,6 +9,7 @@ codeplain_utils
|
|
|
9
9
|
concept_utils
|
|
10
10
|
config
|
|
11
11
|
content_extractor
|
|
12
|
+
diff_utils
|
|
12
13
|
event_bus
|
|
13
14
|
file_utils
|
|
14
15
|
git_utils
|
|
@@ -17,6 +18,7 @@ llm
|
|
|
17
18
|
llm_exceptions
|
|
18
19
|
llm_handler
|
|
19
20
|
llm_selector
|
|
21
|
+
memory_management
|
|
20
22
|
module_renderer
|
|
21
23
|
plain2code
|
|
22
24
|
plain2code_arguments
|
diff_utils.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from difflib import unified_diff
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_unified_diff(filename: str, existing_file_content: str, response_file_content: str) -> str:
|
|
5
|
+
diff = unified_diff(
|
|
6
|
+
existing_file_content.splitlines(keepends=True),
|
|
7
|
+
response_file_content.splitlines(keepends=True),
|
|
8
|
+
fromfile=filename,
|
|
9
|
+
tofile=filename,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
return "".join(diff)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_code_diff(response_files: dict[str, str], existing_files_content: dict[str, str]) -> dict[str, str]:
|
|
16
|
+
code_diff: dict[str, str] = {}
|
|
17
|
+
for file_name in response_files:
|
|
18
|
+
if file_name in existing_files_content and existing_files_content[file_name]:
|
|
19
|
+
if response_files[file_name]:
|
|
20
|
+
unified_diff_result = get_unified_diff(
|
|
21
|
+
file_name,
|
|
22
|
+
existing_files_content[file_name],
|
|
23
|
+
response_files[file_name],
|
|
24
|
+
)
|
|
25
|
+
if unified_diff_result and unified_diff_result.strip():
|
|
26
|
+
code_diff[file_name] = unified_diff_result
|
|
27
|
+
else:
|
|
28
|
+
code_diff[file_name] = f"File {file_name} was deleted."
|
|
29
|
+
else:
|
|
30
|
+
code_diff[file_name] = response_files[file_name]
|
|
31
|
+
|
|
32
|
+
return code_diff
|
memory_management.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import file_utils
|
|
4
|
+
from plain2code_console import console
|
|
5
|
+
from plain_modules import CODEPLAIN_MEMORY_SUBFOLDER
|
|
6
|
+
from render_machine.implementation_code_helpers import ImplementationCodeHelpers
|
|
7
|
+
from render_machine.render_context import RenderContext
|
|
8
|
+
|
|
9
|
+
CONFORMANCE_TESTS_SUCCESS_EXIT_CODE = 0
|
|
10
|
+
CONFORMANCE_TEST_MEMORY_SUBFOLDER = "conformance_test_memory"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MemoryManager:
|
|
14
|
+
|
|
15
|
+
@staticmethod
|
|
16
|
+
def fetch_memory_files(memory_folder: str):
|
|
17
|
+
"""Fetch memory files from memory_folder/conformance_test_memory."""
|
|
18
|
+
memory_path = os.path.join(memory_folder, CONFORMANCE_TEST_MEMORY_SUBFOLDER)
|
|
19
|
+
if not os.path.exists(memory_path):
|
|
20
|
+
return {}, {}
|
|
21
|
+
memory_files = file_utils.list_all_text_files(memory_path)
|
|
22
|
+
memory_files_content = file_utils.get_existing_files_content(memory_path, memory_files)
|
|
23
|
+
return memory_files, memory_files_content
|
|
24
|
+
|
|
25
|
+
def __init__(self, codeplain_api, module_build_folder: str):
|
|
26
|
+
self.codeplain_api = codeplain_api
|
|
27
|
+
self.memory_folder = os.path.join(module_build_folder, CODEPLAIN_MEMORY_SUBFOLDER)
|
|
28
|
+
|
|
29
|
+
def create_conformance_tests_memory(
|
|
30
|
+
self, render_context: RenderContext, exit_code: int, conformance_tests_issue: str
|
|
31
|
+
):
|
|
32
|
+
|
|
33
|
+
current_conformance_tests_issue_frid = render_context.conformance_tests_running_context.current_testing_frid
|
|
34
|
+
old_conformance_tests_issue_frid = (
|
|
35
|
+
render_context.conformance_tests_running_context.previous_conformance_tests_issue_frid
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
old_conformance_tests_issue = (
|
|
39
|
+
render_context.conformance_tests_running_context.previous_conformance_tests_issue_old
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
is_first_time_running_conformance_tests = (
|
|
43
|
+
old_conformance_tests_issue_frid is None or old_conformance_tests_issue_frid == ""
|
|
44
|
+
)
|
|
45
|
+
is_same_frid_as_previous_failing_test = current_conformance_tests_issue_frid == old_conformance_tests_issue_frid
|
|
46
|
+
is_conformance_test_failed = exit_code != CONFORMANCE_TESTS_SUCCESS_EXIT_CODE
|
|
47
|
+
|
|
48
|
+
should_create_memory = not is_first_time_running_conformance_tests and (
|
|
49
|
+
is_same_frid_as_previous_failing_test or is_conformance_test_failed
|
|
50
|
+
)
|
|
51
|
+
code_diff_files = render_context.conformance_tests_running_context.code_diff_files
|
|
52
|
+
|
|
53
|
+
if not should_create_memory or code_diff_files is None:
|
|
54
|
+
console.info(
|
|
55
|
+
"Skipping creation of conformance test memory because the conditions for creating memories are not met."
|
|
56
|
+
)
|
|
57
|
+
return
|
|
58
|
+
|
|
59
|
+
existing_files, existing_files_content = ImplementationCodeHelpers.fetch_existing_files(
|
|
60
|
+
render_context.build_folder
|
|
61
|
+
)
|
|
62
|
+
_, memory_files_content = MemoryManager.fetch_memory_files(self.memory_folder)
|
|
63
|
+
|
|
64
|
+
conformance_tests_folder_name = (
|
|
65
|
+
render_context.conformance_tests_running_context.get_current_conformance_test_folder_name()
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
(
|
|
69
|
+
_,
|
|
70
|
+
existing_conformance_test_files_content,
|
|
71
|
+
) = render_context.conformance_tests.fetch_existing_conformance_test_files(
|
|
72
|
+
render_context.module_name,
|
|
73
|
+
render_context.required_modules,
|
|
74
|
+
render_context.conformance_tests_running_context.current_testing_module_name,
|
|
75
|
+
conformance_tests_folder_name,
|
|
76
|
+
)
|
|
77
|
+
acceptance_tests = render_context.conformance_tests_running_context.get_current_acceptance_tests()
|
|
78
|
+
|
|
79
|
+
response_files = render_context.codeplain_api.create_conformance_test_memory(
|
|
80
|
+
render_context.frid_context.frid,
|
|
81
|
+
render_context.plain_source_tree,
|
|
82
|
+
render_context.frid_context.linked_resources,
|
|
83
|
+
existing_files_content,
|
|
84
|
+
memory_files_content,
|
|
85
|
+
render_context.module_name,
|
|
86
|
+
render_context.get_required_modules_functionalities(),
|
|
87
|
+
code_diff_files,
|
|
88
|
+
existing_conformance_test_files_content,
|
|
89
|
+
acceptance_tests,
|
|
90
|
+
conformance_tests_issue,
|
|
91
|
+
conformance_tests_folder_name,
|
|
92
|
+
old_conformance_tests_issue,
|
|
93
|
+
run_state=render_context.run_state,
|
|
94
|
+
)
|
|
95
|
+
if len(response_files) > 0:
|
|
96
|
+
memory_folder_path = os.path.join(self.memory_folder, CONFORMANCE_TEST_MEMORY_SUBFOLDER)
|
|
97
|
+
file_utils.store_response_files(memory_folder_path, response_files, existing_files)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|