Commit fb4e2a88 by nzy

Remove namedtuple; Save robotB's code and show Output for user

parent 6ba580bf
...@@ -96,7 +96,6 @@ class ANPL: ...@@ -96,7 +96,6 @@ class ANPL:
ENV = ast.parse(''' ENV = ast.parse('''
import numpy as np import numpy as np
from collections import namedtuple
from typing import * from typing import *
black, blue, red, green, yellow, grey, pink, orange, teal, maroon = range(10) black, blue, red, green, yellow, grey, pink, orange, teal, maroon = range(10)
''') ''')
......
from anpl.synthesizer import raw_query, msg from anpl.synthesizer import raw_query, msg
from utils import sys_str, system_info, multiline_input, select_task, set_openai_key from utils import sys_str, system_info, multiline_input, select_task, set_openai_key, rich_dumps
from rich.prompt import IntPrompt, Confirm, Prompt from rich.prompt import IntPrompt, Confirm, Prompt
from rich import print from rich import print
from anpl.sandbox import import_module_from_string from anpl.sandbox import import_module_from_string
...@@ -78,10 +78,15 @@ while not is_correct: ...@@ -78,10 +78,15 @@ while not is_correct:
if np.array_equal(out, real_out): if np.array_equal(out, real_out):
logger.log("system", "check", f"correct") logger.log("system", "check", f"correct")
system_info("[green] Code CORRECT [/green]") system_info("[green] Code CORRECT [/green]")
time_str = time.strftime("%Y%m%d_%H%M%S")
with open(f"./log/btask{task_id}_{time_str}.py", "w") as f:
f.write(code)
is_correct = True is_correct = True
else: else:
logger.log("system", "check", f"wrong") logger.log("system", "check", f"wrong")
system_info("[red] Code WRONG [/red]") system_info("[red] Code WRONG [/red]")
print("The output is")
print(rich_dumps(out))
else: else:
quit_time = time.time() quit_time = time.time()
if quit_time - logger.start_time < 30 * 60: if quit_time - logger.start_time < 30 * 60:
...@@ -91,4 +96,4 @@ while not is_correct: ...@@ -91,4 +96,4 @@ while not is_correct:
else: else:
break break
logger.log("system", "exit", str(is_correct)) logger.log("system", "exit", str(is_correct))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment