Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions memory_management.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os

import file_utils
Expand All @@ -20,6 +21,7 @@ def fetch_memory_files(memory_folder: str):
return {}, {}
memory_files = file_utils.list_all_text_files(memory_path)
memory_files_content = file_utils.get_existing_files_content(memory_path, memory_files)
console.info(f"Loaded {len(memory_files_content)} memory files.")
return memory_files, memory_files_content

def __init__(self, codeplain_api, module_build_folder: str):
Expand Down Expand Up @@ -95,3 +97,24 @@ def create_conformance_tests_memory(
if len(response_files) > 0:
memory_folder_path = os.path.join(self.memory_folder, CONFORMANCE_TEST_MEMORY_SUBFOLDER)
file_utils.store_response_files(memory_folder_path, response_files, existing_files)

def delete_unresolved_memory_files(self):
"""Delete memory files whose resolution_status is not 'RESOLVED'."""
memory_path = os.path.join(self.memory_folder, CONFORMANCE_TEST_MEMORY_SUBFOLDER)
if not os.path.exists(memory_path):
return

memory_files = file_utils.list_all_text_files(memory_path)
for file_name in memory_files:
file_path = os.path.join(memory_path, file_name)
try:
with open(file_path, "r") as f:
content = json.load(f)
if content.get("resolution_status") == "RESOLVED":
continue
except (json.JSONDecodeError, OSError):
# Not a valid JSON file, unlikely to be a valid memory file, delete it
console.error(f"Memory file is not a valid JSON file: {file_name}. Deleting it.")
os.remove(file_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add here console.error. This should not happen.

os.remove(file_path)
console.debug(f"Deleted temporary memory file: {file_name}")
4 changes: 1 addition & 3 deletions render_machine/actions/run_conformance_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def execute(self, render_context: RenderContext, _previous_action_payload: Any |
)

if exit_code == 0:
conformance_tests_issue = "All conformance tests passed successfully!"

if exit_code == 0:
render_context.memory_manager.delete_unresolved_memory_files()
return self.SUCCESSFUL_OUTCOME, None

if exit_code in UNRECOVERABLE_ERROR_EXIT_CODES:
Expand Down