codeplain 0.1.7__py3-none-any.whl → 0.1.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codeplain
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: Transform plain language specifications into working code
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -4,6 +4,7 @@ event_bus.py,sha256=sduIR3bgIbxAbLhwKd8Gx9YN9gzaeqy9-mNupS04aKw,1759
4
4
  file_utils.py,sha256=4BIxzsteZQOaK-efkvQcoaIfYydsQNFR6elpsxJgXLQ,11591
5
5
  git_utils.py,sha256=gTRps6RIzJJkyy9amaDxP38FPoxYulZViBWr9V0IPQg,12414
6
6
  hash_key.py,sha256=lMKgKpOhPeC4UpFf9e7eCNK20FEaDsXTCJ8j3eCWidE,837
7
+ memory_management.py,sha256=ABrM6PhOsalP_PBq2hCazQvQX9C5rpPHhgT35l68RM4,4357
7
8
  module_renderer.py,sha256=LLjLb34phSJlF2YblwGDy5HKWVdi9mo57rr7s-Hj3RA,6261
8
9
  plain2code.py,sha256=b0VJBnYVtpVZPx1TQZHNsnXREbhdW8V_S8TC-wWQqWw,8970
9
10
  plain2code_arguments.py,sha256=DHbkWyB33zifROt2SQMlGUC1AZIDJXoJQHlK7Za9b7U,12024
@@ -20,7 +21,7 @@ plain_modules.py,sha256=iDqqamtix5KahMC_v-vfQ7yndugmqtBW1z6XxTB4x6w,4876
20
21
  plain_spec.py,sha256=zC-VOb_UJOs8OxtEiwQJuonw7Lkmbi7YHyFvvCvUZNo,13529
21
22
  spinner.py,sha256=Ro6Gd9Przf-whuHqPRY6HwI0T57yJjyNPbhDbigZKZE,2471
22
23
  system_config.py,sha256=mgHLn-CRHLO9Y9vKyI_eFBreY_YhFad-ctZgBYp-rIg,1777
23
- codeplain-0.1.7.dist-info/licenses/LICENSE,sha256=wsFi5dpbJurnRNfBj8q2RCcF3ryrmdRIfxc3lPcmc4c,1069
24
+ codeplain-0.1.8.dist-info/licenses/LICENSE,sha256=wsFi5dpbJurnRNfBj8q2RCcF3ryrmdRIfxc3lPcmc4c,1069
24
25
  config/__init__.py,sha256=beYSsJWmBNHDP5rYmVDouqgEeP3t1lkkepbXJ-oq0F8,37
25
26
  config/system_config.yaml,sha256=bB5Th5jxgXFyaIvceUPID1ReebMMXsyMibV4gtu9sWQ,1148
26
27
  render_machine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -63,8 +64,8 @@ tui/plain2code_tui.py,sha256=7agVU0NnaCuF1LuOSEmjx-XfEOQ6HHr1HlWe_b1Tses,11695
63
64
  tui/state_handlers.py,sha256=HbjgaV-9xGhp3E-3X114zOqPkeNcCjT-R1PbVRxVdso,12674
64
65
  tui/styles.css,sha256=Umm2TLePmywizZGV4Nd8UezZRiK5pFyibYRbpRvGqbs,3056
65
66
  tui/widget_helpers.py,sha256=VJorEM2PjRBzN-jIDmKJPolFgo2d8-2NmTumgC5xeNo,5229
66
- codeplain-0.1.7.dist-info/METADATA,sha256=er9997odKgrndshtXlsIMcpQfvRh4A9eFRSdLgHemNk,4300
67
- codeplain-0.1.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
68
- codeplain-0.1.7.dist-info/entry_points.txt,sha256=oDZkBqu9WhtZApb_K6ia8-fn9aojwmAsgnKELceX5T4,46
69
- codeplain-0.1.7.dist-info/top_level.txt,sha256=mj1YZAk6MowQ7wZZkVOAcdUJrJKeWQ7IRZnUHHjaFTM,602
70
- codeplain-0.1.7.dist-info/RECORD,,
67
+ codeplain-0.1.8.dist-info/METADATA,sha256=6cCO9MBjIFzFB4xwk0DzkYOsG9teb9irU43B_oW9kic,4300
68
+ codeplain-0.1.8.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
69
+ codeplain-0.1.8.dist-info/entry_points.txt,sha256=oDZkBqu9WhtZApb_K6ia8-fn9aojwmAsgnKELceX5T4,46
70
+ codeplain-0.1.8.dist-info/top_level.txt,sha256=L9DFaIGhmYbauBxKOmNEl7cc-eYfRAw5XWYaM7B1bcw,620
71
+ codeplain-0.1.8.dist-info/RECORD,,
@@ -17,6 +17,7 @@ llm
17
17
  llm_exceptions
18
18
  llm_handler
19
19
  llm_selector
20
+ memory_management
20
21
  module_renderer
21
22
  plain2code
22
23
  plain2code_arguments
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)