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
aa7af10d
Commit
aa7af10d
authored
Aug 23, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the problem status view
parent
52f168a6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
41 deletions
+85
-41
main.py
main.py
+6
-3
host.py
roles/host.py
+13
-4
adc2019.js
static/js/adc2019.js
+45
-24
part_problem_status.html
templates/part_problem_status.html
+7
-0
part_request_status.html
templates/part_request_status.html
+14
-10
No files found.
main.py
View file @
aa7af10d
...
@@ -44,10 +44,13 @@ def webui_part_solver_status():
...
@@ -44,10 +44,13 @@ def webui_part_solver_status():
else
:
else
:
return
abort
(
404
)
return
abort
(
404
)
@
webui
.
route
(
'/part/request/<request_id>'
)
# @webui.route('/part/request/<request_id>')
def
webui_part_request_status
(
request_id
=
None
):
@
webui
.
route
(
'/part/request/<problem_name>'
)
# def webui_part_request_status(request_id=None):
def
webui_part_request_status
(
problem_name
=
None
):
if
(
adc2019system
.
role
is
not
None
)
and
(
adc2019system
.
role
.
type
==
'host'
):
if
(
adc2019system
.
role
is
not
None
)
and
(
adc2019system
.
role
.
type
==
'host'
):
request_status
=
adc2019system
.
role
.
get_request_status
(
float
(
request_id
))
# request_status = adc2019system.role.get_request_status(float(request_id))
request_status
=
adc2019system
.
role
.
get_request_by_problem
(
problem_name
)
return
render_template
(
'part_request_status.html'
,
status
=
request_status
)
return
render_template
(
'part_request_status.html'
,
status
=
request_status
)
else
:
else
:
return
abort
(
404
)
return
abort
(
404
)
...
...
roles/host.py
View file @
aa7af10d
...
@@ -17,7 +17,7 @@ class Host(object):
...
@@ -17,7 +17,7 @@ class Host(object):
self
.
problems
=
dict
()
self
.
problems
=
dict
()
self
.
worker_manager
=
None
self
.
worker_manager
=
None
self
.
request
=
dict
()
self
.
request
=
dict
()
self
.
pro
cessing_request
=
None
self
.
pro
blem_to_request
=
dict
()
self
.
_load_problems
(
config
[
'problem_path'
])
self
.
_load_problems
(
config
[
'problem_path'
])
self
.
_setup_workers
()
self
.
_setup_workers
()
...
@@ -37,6 +37,7 @@ class Host(object):
...
@@ -37,6 +37,7 @@ class Host(object):
_key
=
problem
.
name
_key
=
problem
.
name
self
.
problems
[
_key
]
=
problem
self
.
problems
[
_key
]
=
problem
self
.
problem_to_request
[
_key
]
=
list
()
def
_setup_workers
(
self
):
def
_setup_workers
(
self
):
...
@@ -56,6 +57,7 @@ class Host(object):
...
@@ -56,6 +57,7 @@ class Host(object):
request
=
Request
(
self
.
worker_manager
,
problem
.
get_dict
(),
solvers
=
solvers
)
request
=
Request
(
self
.
worker_manager
,
problem
.
get_dict
(),
solvers
=
solvers
)
request_id
=
request
.
get_id
()
request_id
=
request
.
get_id
()
self
.
request
[
request_id
]
=
request
self
.
request
[
request_id
]
=
request
self
.
problem_to_request
[
problem_key
]
.
append
(
request_id
)
request
.
broadcast
()
request
.
broadcast
()
return
{
return
{
...
@@ -130,6 +132,16 @@ class Host(object):
...
@@ -130,6 +132,16 @@ class Host(object):
else
:
else
:
return
{
'status'
:
'unknown request'
}
return
{
'status'
:
'unknown request'
}
def
get_request_by_problem
(
self
,
problem_key
):
if
problem_key
in
self
.
problem_to_request
:
request_statuses
=
list
()
for
rid
in
self
.
problem_to_request
[
problem_key
]:
r
=
self
.
request
[
rid
]
request_statuses
.
append
(
r
.
get_status
())
return
reversed
(
request_statuses
)
else
:
return
None
def
get_viewer_data
(
self
,
problem_key
,
solution_id
):
def
get_viewer_data
(
self
,
problem_key
,
solution_id
):
problem
=
self
.
get_problem
(
problem_key
)
problem
=
self
.
get_problem
(
problem_key
)
if
problem
is
None
:
if
problem
is
None
:
...
@@ -361,10 +373,8 @@ class Request(object):
...
@@ -361,10 +373,8 @@ class Request(object):
self
.
response
[
worker
]
=
data
self
.
response
[
worker
]
=
data
def
get_status
(
self
):
def
get_status
(
self
):
# all_workers = self.worker_manager.get_workers().keys()
worker_count
=
0
worker_count
=
0
response_count
=
0
response_count
=
0
# for v in all_workers:
for
v
in
self
.
solvers
:
for
v
in
self
.
solvers
:
worker_count
+=
1
worker_count
+=
1
if
v
in
self
.
response
:
if
v
in
self
.
response
:
...
@@ -390,7 +400,6 @@ class Request(object):
...
@@ -390,7 +400,6 @@ class Request(object):
progress
=
min
(
100
,
max
(
progress_problem
,
progress_time
))
progress
=
min
(
100
,
max
(
progress_problem
,
progress_time
))
worker_status
=
dict
()
worker_status
=
dict
()
# for v in all_workers:
for
v
in
self
.
solvers
:
for
v
in
self
.
solvers
:
if
v
in
self
.
response
:
if
v
in
self
.
response
:
worker_status
[
v
]
=
self
.
response
[
v
][
'status'
]
worker_status
[
v
]
=
self
.
response
[
v
][
'status'
]
...
...
static/js/adc2019.js
View file @
aa7af10d
...
@@ -26,6 +26,8 @@ class StatusView {
...
@@ -26,6 +26,8 @@ class StatusView {
_this
.
container
.
empty
();
_this
.
container
.
empty
();
_this
.
container
.
html
(
d
);
_this
.
container
.
html
(
d
);
clearInterval
(
_this
.
request_refresh_timer
);
_this
.
container
.
find
(
'.start-button'
).
click
(()
=>
{
_this
.
container
.
find
(
'.start-button'
).
click
(()
=>
{
_this
.
start_solver
();
_this
.
start_solver
();
});
});
...
@@ -95,25 +97,26 @@ class StatusView {
...
@@ -95,25 +97,26 @@ class StatusView {
contentType
:
'application/json'
contentType
:
'application/json'
}).
done
((
d
)
=>
{
}).
done
((
d
)
=>
{
var
request_id
=
d
[
'request_id'
];
var
request_id
=
d
[
'request_id'
];
var
timeout
=
d
[
'timeout'
];
//
var timeout = d['timeout'];
_this
.
container
.
find
(
'#solver-processing-modal'
).
modal
({
//
_this.container.find('#solver-processing-modal').modal({
backdrop
:
'static'
,
//
backdrop: 'static',
keyboard
:
false
,
//
keyboard: false,
show
:
true
//
show: true
});
//
});
_this
.
container
.
find
(
'#solver-processing-modal'
).
on
(
'hidden.bs.modal'
,
function
(
e
){
//
_this.container.find('#solver-processing-modal').on('hidden.bs.modal', function(e){
clearInterval
(
_this
.
request_refresh_timer
);
//
clearInterval(_this.request_refresh_timer);
_this
.
show_problem
();
//
_this.show_problem();
_this
.
fire
(
'refresh'
);
//
_this.fire('refresh');
})
//
})
_this
.
container
.
find
(
'.stop-button'
).
click
(()
=>
{
//
_this.container.find('.stop-button').click(()=>{
_this
.
stop_solver
();
//
_this.stop_solver();
});
//
});
_this
.
request_refresh_timer
=
setInterval
((
function
_t
(){
_this
.
request_refresh_timer
=
setInterval
((
function
_t
(){
_this
.
get_request_status
(
request_id
);
// _this.get_request_status(request_id);
_this
.
get_request_status
();
return
_t
;
return
_t
;
}()),
1000
);
}()),
1000
);
});
});
...
@@ -171,20 +174,38 @@ class StatusView {
...
@@ -171,20 +174,38 @@ class StatusView {
});
});
}
}
get_request_status
(
request_id
){
// get_request_status(request_id){
// var _this = this;
// $.ajax({
// type: 'GET',
// dataType: 'html',
// url: '/part/request/' + request_id
// }).done((d) => {
// _this.container.find('#request-status-container').empty();
// _this.container.find('#request-status-container').html(d);
// status = $(d).find('#request-status-value').text();
// if(status == 'done'){
// clearInterval(_this.request_refresh_timer);
// }
// });
// }
get_request_status
(){
var
_this
=
this
;
var
_this
=
this
;
$
.
ajax
({
$
.
ajax
({
type
:
'GET'
,
type
:
'GET'
,
dataType
:
'html'
,
dataType
:
'html'
,
url
:
'/part/request/'
+
request_id
url
:
'/part/request/'
+
_this
.
problem_key
}).
done
((
d
)
=>
{
}).
done
((
d
)
=>
{
_this
.
container
.
find
(
'#request-
status
-container'
).
empty
();
_this
.
container
.
find
(
'#request-
table
-container'
).
empty
();
_this
.
container
.
find
(
'#request-
status
-container'
).
html
(
d
);
_this
.
container
.
find
(
'#request-
table
-container'
).
html
(
d
);
status
=
$
(
d
).
find
(
'#request-status-value'
).
text
();
// status = $(d).find('#request-status-value').text();
if
(
status
==
'done'
){
// if(status == 'done'){
clearInterval
(
_this
.
request_refresh_timer
);
// clearInterval(_this.request_refresh_timer);
}
// }
// _this.fire('refresh');
});
});
}
}
...
...
templates/part_problem_status.html
View file @
aa7af10d
...
@@ -47,6 +47,13 @@
...
@@ -47,6 +47,13 @@
</div>
</div>
</div>
</div>
<div
id=
"request-list-container"
>
<h4>
リクエスト一覧
</h4>
<div
id=
"request-table-container"
>
</div>
</div>
<div
id=
'solution-list-container'
>
<div
id=
'solution-list-container'
>
<h4>
処理結果一覧
</h4>
<h4>
処理結果一覧
</h4>
<table
class=
"table table-bordered table-striped"
>
<table
class=
"table table-bordered table-striped"
>
...
...
templates/part_request_status.html
View file @
aa7af10d
<div>
<div>
<p>
処理結果:
<span
id=
'request-status-value'
>
{{status.status}}
</span></p>
{% for r in status %}
<table
class=
"table table-bordered"
>
<p>
処理結果:
<span
id=
'request-status-value'
>
{{r.status}}
</span></p>
<tr>
<table
class=
"table table-bordered table-sm"
>
<!-- <tr>
<th>Worker (Solver)</th>
<th>Worker (Solver)</th>
<th>Status</th>
<th>Status</th>
</tr>
</tr> -->
{% for k, v in status['worker_status'].items() %}
<tbody>
{% for k, v in r['worker_status'].items() %}
<tr>
<tr>
<td>
{{k}}
</td>
<td>
{{k}}
</td>
<td>
{{v}}
</td>
<td>
{{v}}
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</table>
{% endfor %}
</div>
</div>
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