Skip to content

Commit 0cc34bd

Browse files
fix: defensive check for None parent_node and null json field
1 parent 76b3358 commit 0cc34bd

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

MaxKernel/auto_search/worker.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _prepare_inputs(
8181

8282
def _prepare_initial_state(self, parent_node: Node) -> Dict[str, Any]:
8383
initial_state = {}
84-
if parent_node.evaluation:
84+
if parent_node and parent_node.evaluation:
8585
initial_state = {
8686
"kernel_compilation_status": {
8787
"success": parent_node.evaluation.compiled,
@@ -163,17 +163,16 @@ def _process_results(
163163
elif history:
164164
best_run = history[-1]
165165

166-
comp_status = best_run.get("compilation_status", {})
166+
comp_status = best_run.get("compilation_status") or {}
167167
compiled = comp_status.get("success", False)
168168
compilation_error = None
169169
if not compiled:
170-
compilation_error = comp_status.get("message", "")
171-
if comp_status.get("final_errors"):
172-
compilation_error += "\n\nFinal Errors:\n" + comp_status.get(
173-
"final_errors"
174-
)
170+
compilation_error = comp_status.get("message") or ""
171+
final_errors = comp_status.get("final_errors")
172+
if final_errors:
173+
compilation_error += "\n\nFinal Errors:\n" + final_errors
175174

176-
test_status = best_run.get("test_status", {})
175+
test_status = best_run.get("test_status") or {}
177176
correct = test_status.get("success", False)
178177
test_error = test_status.get("output") if not correct else None
179178

0 commit comments

Comments
 (0)