Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2019-system
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
adc2019
adc2019-system
Commits
18d1659c
Commit
18d1659c
authored
Aug 27, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix UI to show failure of parts solution
parent
271b1187
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
15 deletions
+55
-15
host.py
roles/host.py
+55
-14
data.py
utils/data.py
+0
-1
No files found.
roles/host.py
View file @
18d1659c
...
@@ -93,7 +93,11 @@ class Host(object):
...
@@ -93,7 +93,11 @@ class Host(object):
def
store_solution
(
self
,
solution
):
def
store_solution
(
self
,
solution
):
if
'part_id'
in
solution
:
if
'part_id'
in
solution
:
request_id
=
solution
[
'request_id'
]
if
solution
[
'status'
]
!=
'done'
:
if
solution
[
'status'
]
!=
'done'
:
if
request_id
in
self
.
request
:
self
.
request
[
request_id
]
.
store_failed
(
solution
)
return
{
'status'
:
'ignored'
}
return
{
'status'
:
'ignored'
}
problem_key
=
solution
[
'problem'
]
problem_key
=
solution
[
'problem'
]
...
@@ -102,14 +106,14 @@ class Host(object):
...
@@ -102,14 +106,14 @@ class Host(object):
self
.
request
[
request_id
]
.
store_response
(
solution
)
self
.
request
[
request_id
]
.
store_response
(
solution
)
if
problem_key
in
self
.
problems
:
if
problem_key
in
self
.
problems
:
res
=
self
.
problems
[
problem_key
]
.
put_partial_solution
(
solution
)
parts_valid
=
self
.
problems
[
problem_key
]
.
put_partial_solution
(
solution
)
else
:
else
:
res
=
False
parts_valid
=
False
print
(
solution
[
'solution'
])
print
(
solution
[
'solution'
])
print
(
solution
[
'line_map'
],
solution
[
'block_map'
])
print
(
solution
[
'line_map'
],
solution
[
'block_map'
])
if
res
:
if
parts_valid
and
self
.
request
[
request_id
]
.
is_receive_completed
:
merge_problem
=
self
.
problems
[
problem_key
]
.
partial_merge_problem
merge_problem
=
self
.
problems
[
problem_key
]
.
partial_merge_problem
# print(merge_problem)
# print(merge_problem)
merge_problem
[
'request_id'
]
=
solution
[
'request_id'
]
merge_problem
[
'request_id'
]
=
solution
[
'request_id'
]
...
@@ -207,6 +211,9 @@ class Host(object):
...
@@ -207,6 +211,9 @@ class Host(object):
return
{}
return
{}
elif
cmd
==
'cancel'
:
elif
cmd
==
'cancel'
:
self
.
worker_manager
.
request_cancel
(
params
)
self
.
worker_manager
.
request_cancel
(
params
)
_requests
=
self
.
problem_to_request
[
params
[
'problem'
]]
for
r
in
_requests
:
self
.
request
[
r
]
.
cancel
()
return
{
'status'
:
'canceled'
}
return
{
'status'
:
'canceled'
}
elif
cmd
==
'worker/reset'
:
elif
cmd
==
'worker/reset'
:
self
.
worker_manager
.
reset_worker
(
params
[
'address'
])
self
.
worker_manager
.
reset_worker
(
params
[
'address'
])
...
@@ -364,7 +371,6 @@ class Worker(object):
...
@@ -364,7 +371,6 @@ class Worker(object):
class
Request
(
object
):
class
Request
(
object
):
def
__init__
(
self
,
worker_manager
,
data
,
worker
,
timeout
=
10000
,
merge_solvers
=
list
()):
def
__init__
(
self
,
worker_manager
,
data
,
worker
,
timeout
=
10000
,
merge_solvers
=
list
()):
# self.worker_manager = worker_manager
self
.
data
=
data
self
.
data
=
data
self
.
timeout
=
timeout
self
.
timeout
=
timeout
...
@@ -382,9 +388,11 @@ class Request(object):
...
@@ -382,9 +388,11 @@ class Request(object):
if
self
.
solver
.
partial_mode
:
if
self
.
solver
.
partial_mode
:
self
.
part_nums
=
len
(
data
[
'group_problems'
])
self
.
part_nums
=
len
(
data
[
'group_problems'
])
self
.
solved
=
[
0
for
v
in
range
(
self
.
part_nums
+
1
)]
self
.
solved
=
[
0
for
v
in
range
(
self
.
part_nums
+
1
)]
# self.received = [0 for v in range(self.part_nums)]
else
:
else
:
self
.
part_nums
=
1
self
.
part_nums
=
1
self
.
solved
=
[
0
]
self
.
solved
=
[
0
]
# self.received = []
self
.
is_processed
=
False
self
.
is_processed
=
False
...
@@ -396,6 +404,14 @@ class Request(object):
...
@@ -396,6 +404,14 @@ class Request(object):
data
[
'merge_solvers'
]
=
self
.
merge_solvers
data
[
'merge_solvers'
]
=
self
.
merge_solvers
return
data
return
data
# @property
# def is_receive_completed(self):
# return all([v>0 for v in self.received])
@
property
def
is_receive_completed
(
self
):
return
all
([
v
!=
0
for
v
in
self
.
solved
[:
-
1
]])
def
get_id
(
self
):
def
get_id
(
self
):
return
self
.
request_id
return
self
.
request_id
...
@@ -407,10 +423,25 @@ class Request(object):
...
@@ -407,10 +423,25 @@ class Request(object):
if
self
.
start_time
is
None
:
if
self
.
start_time
is
None
:
self
.
start_time
=
time
.
time
()
self
.
start_time
=
time
.
time
()
def
cancel
(
self
):
if
self
.
solved
[
-
1
]
==
0
:
self
.
solved
[
-
1
]
=
-
1
def
store_failed
(
self
,
data
):
self
.
response
.
append
(
data
)
if
'part_id'
in
data
:
idx
=
data
[
'part_id'
]
self
.
solved
[
idx
]
=
-
1
if
all
([
v
!=
0
for
v
in
self
.
solved
[:
-
1
]])
and
any
([
v
<
0
for
v
in
self
.
solved
[:
-
1
]]):
self
.
solved
[
-
1
]
=
-
1
self
.
done_time
=
time
.
time
()
else
:
self
.
solved
[
-
1
]
=
-
1
self
.
done_time
=
time
.
time
()
def
store_response
(
self
,
data
):
def
store_response
(
self
,
data
):
# worker = data['worker']
# self.response[worker].append(data)
# self.response[worker] = data
self
.
response
.
append
(
data
)
self
.
response
.
append
(
data
)
print
(
data
)
print
(
data
)
if
'part_id'
in
data
:
if
'part_id'
in
data
:
...
@@ -420,8 +451,9 @@ class Request(object):
...
@@ -420,8 +451,9 @@ class Request(object):
self
.
solved
[
idx
]
=
1
self
.
solved
[
idx
]
=
1
else
:
else
:
self
.
solved
[
idx
]
=
-
1
self
.
solved
[
idx
]
=
-
1
if
all
([
v
!=
0
for
v
in
self
.
solved
])
and
any
([
v
<
0
for
v
in
self
.
solved
]):
if
all
([
v
!=
0
for
v
in
self
.
solved
[:
-
1
]])
and
any
([
v
<
0
for
v
in
self
.
solved
[:
-
1
]
]):
self
.
solved
[
-
1
]
=
-
1
self
.
solved
[
-
1
]
=
-
1
self
.
done_time
=
time
.
time
()
else
:
else
:
if
data
[
'status'
]
==
'done'
:
if
data
[
'status'
]
==
'done'
:
self
.
solved
[
-
1
]
=
1
self
.
solved
[
-
1
]
=
1
...
@@ -443,10 +475,15 @@ class Request(object):
...
@@ -443,10 +475,15 @@ class Request(object):
elif
self
.
solved
[
-
1
]
==
-
1
:
elif
self
.
solved
[
-
1
]
==
-
1
:
if
self
.
start_time
is
None
:
if
self
.
start_time
is
None
:
self
.
start_time
=
time
.
time
()
self
.
start_time
=
time
.
time
()
counter
=
sum
([
v
!=
0
for
v
in
self
.
solved
])
fail_counter
=
sum
([
v
<
0
for
v
in
self
.
solved
])
if
self
.
done_time
is
None
:
status
=
f
'canceled ({counter}<!{fail_counter}>/{len(self.solved)} done)'
else
:
elapsed_time
=
self
.
done_time
-
self
.
start_time
elapsed_time
=
self
.
done_time
-
self
.
start_time
et_minutes
=
int
(
elapsed_time
//
60
)
et_minutes
=
int
(
elapsed_time
//
60
)
et_seconds
=
int
(
elapsed_time
%
60
)
et_seconds
=
int
(
elapsed_time
%
60
)
status
=
f
'failed
[{et_minutes}:{et_seconds:02}]'
status
=
f
'failed ({counter}<!{fail_counter}>/{len(self.solved)} done)
[{et_minutes}:{et_seconds:02}]'
else
:
else
:
if
self
.
solver
.
status
==
'Not connected'
:
if
self
.
solver
.
status
==
'Not connected'
:
status
=
'Not connected'
status
=
'Not connected'
...
@@ -455,7 +492,11 @@ class Request(object):
...
@@ -455,7 +492,11 @@ class Request(object):
if
len
(
self
.
solved
)
==
1
:
if
len
(
self
.
solved
)
==
1
:
status_mes
=
'Running'
status_mes
=
'Running'
elif
len
(
self
.
solved
)
>
1
:
elif
len
(
self
.
solved
)
>
1
:
counter
=
sum
([
v
>
0
for
v
in
self
.
solved
])
counter
=
sum
([
v
!=
0
for
v
in
self
.
solved
])
fail_counter
=
sum
([
v
<
0
for
v
in
self
.
solved
])
if
fail_counter
>
0
:
status_mes
=
f
'{counter}<!{fail_counter}>/{len(self.solved)}'
else
:
status_mes
=
f
'{counter}/{len(self.solved)}'
status_mes
=
f
'{counter}/{len(self.solved)}'
if
self
.
start_time
is
None
:
if
self
.
start_time
is
None
:
...
...
utils/data.py
View file @
18d1659c
...
@@ -387,7 +387,6 @@ class Problem(object):
...
@@ -387,7 +387,6 @@ class Problem(object):
with
open
(
outpath
,
'w'
)
as
fp
:
with
open
(
outpath
,
'w'
)
as
fp
:
json
.
dump
(
self
.
get_dict
(),
fp
,
indent
=
4
)
json
.
dump
(
self
.
get_dict
(),
fp
,
indent
=
4
)
# print([len(v)>0 for v in self.partial_solutions])
if
all
([
len
(
v
)
>
0
for
v
in
self
.
partial_solutions
]):
if
all
([
len
(
v
)
>
0
for
v
in
self
.
partial_solutions
]):
return
True
return
True
else
:
else
:
...
...
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