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
9d989358
Commit
9d989358
authored
Aug 26, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the problem status view
parent
dda8b6a6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
58 deletions
+71
-58
main.py
main.py
+18
-1
adc2019.js
static/js/adc2019.js
+20
-27
part_problem_status.html
templates/part_problem_status.html
+3
-27
part_solution_status.html
templates/part_solution_status.html
+27
-0
data.py
utils/data.py
+3
-3
No files found.
main.py
View file @
9d989358
...
@@ -61,11 +61,28 @@ def webui_part_problem_status(name=None):
...
@@ -61,11 +61,28 @@ def webui_part_problem_status(name=None):
if
(
adc2019system
.
role
is
not
None
)
and
(
adc2019system
.
role
.
type
==
'host'
):
if
(
adc2019system
.
role
is
not
None
)
and
(
adc2019system
.
role
.
type
==
'host'
):
problem
=
adc2019system
.
role
.
get_problem
(
name
)
problem
=
adc2019system
.
role
.
get_problem
(
name
)
workers
=
adc2019system
.
role
.
get_workers
()
workers
=
adc2019system
.
role
.
get_workers
()
# solutions = reversed(sorted(problem.get_solutions().items(), key=lambda x:x[1].timestamp))
if
problem
is
None
:
return
abort
(
404
)
else
:
# return render_template('part_problem_status.html', problem=problem, workers=workers, solutions=solutions)
return
render_template
(
'part_problem_status.html'
,
problem
=
problem
,
workers
=
workers
)
else
:
return
abort
(
404
)
@
webui
.
route
(
'/part/problem_solution/<name>'
)
def
webui_part_solution_status
(
name
=
None
):
if
name
is
None
:
return
abort
(
404
)
if
(
adc2019system
.
role
is
not
None
)
and
(
adc2019system
.
role
.
type
==
'host'
):
problem
=
adc2019system
.
role
.
get_problem
(
name
)
solutions
=
reversed
(
sorted
(
problem
.
get_solutions
()
.
items
(),
key
=
lambda
x
:
x
[
1
]
.
timestamp
))
solutions
=
reversed
(
sorted
(
problem
.
get_solutions
()
.
items
(),
key
=
lambda
x
:
x
[
1
]
.
timestamp
))
if
problem
is
None
:
if
problem
is
None
:
return
abort
(
404
)
return
abort
(
404
)
else
:
else
:
return
render_template
(
'part_
problem_status.html'
,
problem
=
problem
,
workers
=
workers
,
solutions
=
solutions
)
return
render_template
(
'part_
solution_status.html'
,
problem
=
problem
,
solutions
=
solutions
)
else
:
else
:
return
abort
(
404
)
return
abort
(
404
)
...
...
static/js/adc2019.js
View file @
9d989358
...
@@ -41,13 +41,6 @@ class StatusView {
...
@@ -41,13 +41,6 @@ class StatusView {
_this
.
fire
(
'refresh'
);
_this
.
fire
(
'refresh'
);
});
});
_this
.
container
.
find
(
'.solution-detail-row.valid-solution td'
).
click
((
e
)
=>
{
var
solution_id
=
$
(
e
.
target
).
parent
(
"tr"
).
data
(
"solution-id"
);
var
problem_name
=
$
(
e
.
target
).
parent
(
"tr"
).
data
(
"problem"
);
var
viewer_url
=
"/viewer#"
+
problem_name
+
"/"
+
solution_id
;
window
.
open
(
viewer_url
,
"_blank"
);
});
_this
.
container
.
find
(
'#chk-solver-all'
).
prop
(
'checked'
,
false
);
_this
.
container
.
find
(
'#chk-solver-all'
).
prop
(
'checked'
,
false
);
_this
.
container
.
find
(
'#chk-solver-all'
).
on
(
'change'
,
(
e
)
=>
{
_this
.
container
.
find
(
'#chk-solver-all'
).
on
(
'change'
,
(
e
)
=>
{
...
@@ -64,7 +57,7 @@ class StatusView {
...
@@ -64,7 +57,7 @@ class StatusView {
}).
trigger
(
'change'
);
}).
trigger
(
'change'
);
_this
.
request_refresh_timer
=
setInterval
((
function
_t
(){
_this
.
request_refresh_timer
=
setInterval
((
function
_t
(){
_this
.
get_request_status
();
_this
.
update_status_view
();
return
_t
;
return
_t
;
}()),
1000
);
}()),
1000
);
});
});
...
@@ -97,24 +90,6 @@ class StatusView {
...
@@ -97,24 +90,6 @@ class StatusView {
contentType
:
'application/json'
contentType
:
'application/json'
}).
done
((
d
)
=>
{
}).
done
((
d
)
=>
{
console
.
log
(
d
);
console
.
log
(
d
);
// var request_id = d['request_id'];
// var timeout = d['timeout'];
// _this.container.find('#solver-processing-modal').modal({
// backdrop: 'static',
// keyboard: false,
// show: true
// });
// _this.container.find('#solver-processing-modal').on('hidden.bs.modal', function(e){
// clearInterval(_this.request_refresh_timer);
// _this.show_problem();
// _this.fire('refresh');
// })
// _this.container.find('.stop-button').click(()=>{
// _this.stop_solver();
// });
});
});
}
}
...
@@ -170,7 +145,7 @@ class StatusView {
...
@@ -170,7 +145,7 @@ class StatusView {
});
});
}
}
get_request_status
(){
update_status_view
(){
var
_this
=
this
;
var
_this
=
this
;
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
...
@@ -180,6 +155,24 @@ class StatusView {
...
@@ -180,6 +155,24 @@ class StatusView {
_this
.
container
.
find
(
'#request-table-container'
).
empty
();
_this
.
container
.
find
(
'#request-table-container'
).
empty
();
_this
.
container
.
find
(
'#request-table-container'
).
html
(
d
);
_this
.
container
.
find
(
'#request-table-container'
).
html
(
d
);
});
});
$
.
ajax
({
type
:
'GET'
,
dataType
:
'html'
,
url
:
'/part/problem_solution/'
+
_this
.
problem_key
}).
done
((
d
)
=>
{
_this
.
container
.
find
(
'#solution-table-container'
).
empty
();
_this
.
container
.
find
(
'#solution-table-container'
).
html
(
d
);
_this
.
container
.
find
(
'.solution-detail-row.valid-solution td'
).
click
((
e
)
=>
{
var
solution_id
=
$
(
e
.
target
).
parent
(
"tr"
).
data
(
"solution-id"
);
var
problem_name
=
$
(
e
.
target
).
parent
(
"tr"
).
data
(
"problem"
);
var
viewer_url
=
"/viewer#"
+
problem_name
+
"/"
+
solution_id
;
window
.
open
(
viewer_url
,
"_blank"
);
});
_this
.
fire
(
'refresh'
);
});
}
}
// システム詳細画面を表示
// システム詳細画面を表示
...
...
templates/part_problem_status.html
View file @
9d989358
...
@@ -56,33 +56,9 @@
...
@@ -56,33 +56,9 @@
<div
id=
'solution-list-container'
>
<div
id=
'solution-list-container'
>
<h4>
処理結果一覧
</h4>
<h4>
処理結果一覧
</h4>
<table
class=
"table table-bordered table-striped"
>
<div
id=
"solution-table-container"
>
<thead>
<tr>
</div>
<th>
Timestamp
</th>
<th>
Client
</th>
<th>
Score
</th>
</tr>
</thead>
<tbody>
{% for k, v in solutions %}
{% set tr_class = '' %}
{% set tr_class = tr_class + ' submit-solution' if k == problem.best_solution else '' %}
{% set tr_class = tr_class + ' valid-solution' if v.is_valid_solution() else '' %}
<tr
class=
"solution-detail-row {{tr_class}}"
data-solution-id=
"{{k}}"
data-problem=
"{{problem.name}}"
>
<td>
{{v.timestamp_str}}
</td>
<td>
{{v.worker}}
</td>
<td>
{% if v.is_valid_solution() %}
{{v.score}} ({{v.size_str}})
{% else %}
{{v.status}}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
templates/part_solution_status.html
0 → 100644
View file @
9d989358
<table
class=
"table table-bordered table-striped"
>
<thead>
<tr>
<th>
Timestamp
</th>
<th>
Client
</th>
<th>
Score
</th>
</tr>
</thead>
<tbody>
{% for k, v in solutions %}
{% set tr_class = '' %}
{% set tr_class = tr_class + ' submit-solution' if k == problem.best_solution else '' %}
{% set tr_class = tr_class + ' valid-solution' if v.is_valid_solution() else '' %}
<tr
class=
"solution-detail-row {{tr_class}}"
data-solution-id=
"{{k}}"
data-problem=
"{{problem.name}}"
>
<td>
{{v.timestamp_str}}
</td>
<td>
{{v.worker}}
</td>
<td>
{% if v.is_valid_solution() %}
{{v.score}} ({{v.size_str}})
{% else %}
{{v.status}}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
utils/data.py
View file @
9d989358
...
@@ -31,7 +31,7 @@ class Problem(object):
...
@@ -31,7 +31,7 @@ class Problem(object):
self
.
_load_problem
(
problem_path
)
self
.
_load_problem
(
problem_path
)
if
not
self
.
solution_path
is
None
:
if
not
self
.
solution_path
is
None
:
solution_files
=
glob
.
glob
(
f
'{self.solution_path}/{self.name}/*.json'
)
solution_files
=
glob
.
glob
(
f
'{self.solution_path}/{self.name}/
tmp-
*.json'
)
for
v
in
solution_files
:
for
v
in
solution_files
:
solution
=
Solution
(
solution_file
=
v
)
solution
=
Solution
(
solution_file
=
v
)
solution_id
=
solution
.
get_id
()
solution_id
=
solution
.
get_id
()
...
@@ -364,7 +364,7 @@ class Problem(object):
...
@@ -364,7 +364,7 @@ class Problem(object):
outdir
=
f
"{self.solution_path}/{self.name}"
outdir
=
f
"{self.solution_path}/{self.name}"
if
not
os
.
path
.
exists
(
outdir
):
if
not
os
.
path
.
exists
(
outdir
):
os
.
mkdir
(
outdir
)
os
.
mkdir
(
outdir
)
outpath
=
f
"{outdir}/{data['request_id']}-{data['worker']}-p{data['part_id']}.json"
.
replace
(
":"
,
"."
)
outpath
=
f
"{outdir}/
part-
{data['request_id']}-{data['worker']}-p{data['part_id']}.json"
.
replace
(
":"
,
"."
)
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
)
...
@@ -540,7 +540,7 @@ class Solution(object):
...
@@ -540,7 +540,7 @@ class Solution(object):
outdir
=
f
"{basedir}/{self.problem}"
outdir
=
f
"{basedir}/{self.problem}"
if
not
os
.
path
.
exists
(
outdir
):
if
not
os
.
path
.
exists
(
outdir
):
os
.
mkdir
(
outdir
)
os
.
mkdir
(
outdir
)
outpath
=
f
"{outdir}/{self.request_id}-{self.worker}.json"
.
replace
(
":"
,
"."
)
outpath
=
f
"{outdir}/
tmp-
{self.request_id}-{self.worker}.json"
.
replace
(
":"
,
"."
)
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
)
...
...
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