Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
anpl
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ziyuan Nan
anpl
Commits
bd812752
Commit
bd812752
authored
May 13, 2023
by
nzy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix trace bug
parent
9aeb08e2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
robotA.py
+3
-4
robotB.py
+2
-6
utils.py
+8
-0
No files found.
robotA.py
View file @
bd812752
from
rich.prompt
import
Confirm
,
Prompt
,
IntPrompt
from
rich.prompt
import
Confirm
,
Prompt
,
IntPrompt
from
rich.progress
import
track
from
rich.progress
import
track
from
utils
import
sys_str
,
system_info
,
code_input
,
value_input
,
print_anpl
,
print_IOExamples
,
select_task
,
set_openai_key
,
fun_select
,
print_text_IOExamples
,
Logger
from
utils
import
sys_str
,
system_info
,
code_input
,
value_input
,
print_anpl
,
print_IOExamples
,
select_task
,
set_openai_key
,
fun_select
,
print_text_IOExamples
,
Logger
,
print_error
from
copy
import
deepcopy
from
copy
import
deepcopy
import
time
import
time
...
@@ -8,7 +8,6 @@ from anpl.anpl import IOExample, ANPL
...
@@ -8,7 +8,6 @@ from anpl.anpl import IOExample, ANPL
from
anpl.parser
import
ANPLParser
from
anpl.parser
import
ANPLParser
from
anpl.synthesizer
import
fun_synthesis
,
batch_fun_synthesis
from
anpl.synthesizer
import
fun_synthesis
,
batch_fun_synthesis
from
anpl.tracer
import
anpl_check
,
anpl_trace
from
anpl.tracer
import
anpl_check
,
anpl_trace
import
traceback
set_openai_key
()
set_openai_key
()
...
@@ -93,11 +92,11 @@ while not is_correct:
...
@@ -93,11 +92,11 @@ while not is_correct:
if
ioc
.
crash
:
if
ioc
.
crash
:
logger
.
log
(
"system"
,
"trace"
,
f
"{fun_name}: crash"
)
logger
.
log
(
"system"
,
"trace"
,
f
"{fun_name}: crash"
)
system_info
(
"[red]ANPL crash in this function.[/red]"
)
system_info
(
"[red]ANPL crash in this function.[/red]"
)
traceback
.
print_exception
(
ioc
.
exception
,
limit
=-
1
)
print_error
(
ioc
.
exception
)
elif
len
(
ioc
.
ios
)
==
0
:
elif
len
(
ioc
.
ios
)
==
0
:
logger
.
log
(
"user"
,
"trace"
,
f
"{fun_name}: crash before this function"
)
logger
.
log
(
"user"
,
"trace"
,
f
"{fun_name}: crash before this function"
)
system_info
(
"[red]ANPL crash before this function.[/red]"
)
system_info
(
"[red]ANPL crash before this function.[/red]"
)
traceback
.
print_exception
(
ioc
.
exception
,
limit
=-
1
)
print_error
(
ioc
.
exception
)
else
:
else
:
logger
.
log
(
"user"
,
"trace"
,
f
"{fun_name}: show io to user"
)
logger
.
log
(
"user"
,
"trace"
,
f
"{fun_name}: show io to user"
)
system_info
(
"[green]Visual IO[/green]"
)
system_info
(
"[green]Visual IO[/green]"
)
...
...
robotB.py
View file @
bd812752
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
,
rich_dumps
,
Logger
from
utils
import
sys_str
,
system_info
,
multiline_input
,
select_task
,
set_openai_key
,
rich_dumps
,
Logger
,
print_error
from
rich.prompt
import
IntPrompt
,
Confirm
,
Prompt
from
rich.prompt
import
IntPrompt
,
Confirm
,
Prompt
import
rich
import
rich
from
anpl.sandbox
import
import_module_from_string
,
timeout
from
anpl.sandbox
import
import_module_from_string
,
timeout
import
numpy
as
np
import
numpy
as
np
import
time
import
time
import
traceback
from
copy
import
deepcopy
from
copy
import
deepcopy
history
=
[]
history
=
[]
...
@@ -77,10 +76,7 @@ while not is_correct:
...
@@ -77,10 +76,7 @@ while not is_correct:
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
log
(
"system"
,
"check"
,
f
"crash: {e}"
)
logger
.
log
(
"system"
,
"check"
,
f
"crash: {e}"
)
system_info
(
"[red]Crash[/red]"
)
system_info
(
"[red]Crash[/red]"
)
try
:
print_error
(
e
)
traceback
.
print_exception
(
e
,
limit
=-
1
)
except
Exception
:
print
(
e
)
continue
continue
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"
)
...
...
utils.py
View file @
bd812752
...
@@ -12,6 +12,8 @@ import time
...
@@ -12,6 +12,8 @@ import time
import
os
import
os
import
pickle
import
pickle
import
prompt_toolkit
import
prompt_toolkit
import
traceback
np
.
set_printoptions
(
threshold
=
np
.
inf
)
colors
=
[
"#000000"
,
"#0000FF"
,
"#FF0000"
,
"#008000"
,
"#FFFF00"
,
colors
=
[
"#000000"
,
"#0000FF"
,
"#FF0000"
,
"#008000"
,
"#FFFF00"
,
"#808080"
,
"#FFC0CB"
,
"#FFA500"
,
"#008080"
,
"#800000"
]
"#808080"
,
"#FFC0CB"
,
"#FFA500"
,
"#008080"
,
"#800000"
]
...
@@ -191,3 +193,8 @@ def select_task():
...
@@ -191,3 +193,8 @@ def select_task():
return
task_id
,
input_grid
,
output_grid
return
task_id
,
input_grid
,
output_grid
def
print_error
(
e
):
try
:
traceback
.
print_exception
(
e
,
limit
=-
1
)
except
Exception
:
print
(
e
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment