mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Map task states to job status. Colorize status badges on dashboard.
This commit is contained in:
parent
267f86d342
commit
6f8cef26e4
@ -25,7 +25,7 @@ def ocr():
|
||||
"--skip-binarisation"],
|
||||
"lang": new_ocr_job_form.language.data,
|
||||
"version": new_ocr_job_form.version.data}),
|
||||
status="submitted",
|
||||
status="pending",
|
||||
title=new_ocr_job_form.title.data)
|
||||
db.session.add(ocr_job)
|
||||
db.session.commit()
|
||||
@ -74,7 +74,7 @@ def nlp():
|
||||
service_args=json.dumps({"args": [],
|
||||
"lang": new_nlp_job_form.language.data,
|
||||
"version": new_nlp_job_form.version.data}),
|
||||
status="submitted",
|
||||
status="pending",
|
||||
title=new_nlp_job_form.title.data)
|
||||
db.session.add(nlp_job)
|
||||
db.session.commit()
|
||||
|
13
app/swarm.py
13
app/swarm.py
@ -101,16 +101,19 @@ class Swarm:
|
||||
' Poll the service until the job is completly executed.
|
||||
'''
|
||||
session = self.Session()
|
||||
job.status = 'running'
|
||||
session.add(job)
|
||||
session.commit()
|
||||
current_state = None
|
||||
while True:
|
||||
current_state = service.tasks()[0].get('Status').get('State')
|
||||
if job.status != current_state:
|
||||
job.status = current_state
|
||||
session.add(job)
|
||||
session.commit()
|
||||
if current_state == 'complete':
|
||||
if current_state == 'complete' or current_state == 'failed':
|
||||
break
|
||||
time.sleep(1)
|
||||
service.reload()
|
||||
job.status = current_state
|
||||
session.add(job)
|
||||
session.commit()
|
||||
session.close()
|
||||
# Remove the service from the swarm.
|
||||
service.remove()
|
||||
|
@ -58,17 +58,27 @@
|
||||
</div>
|
||||
</li>
|
||||
{% for job in current_user.jobs.all() %}
|
||||
{% if job.service == 'nlp' %}
|
||||
{% set service_icon = 'format_textdirection_l_to_r' %}
|
||||
{% elif job.service =='ocr' %}
|
||||
{% set service_icon = 'find_in_page' %}
|
||||
{% else %}
|
||||
{% set service_icon = 'help' %}
|
||||
{% endif %}
|
||||
|
||||
{% if job.status == 'pending' %}
|
||||
{% set badge_color = 'amber' %}
|
||||
{% elif job.status =='running' %}
|
||||
{% set badge_color = 'indigo' %}
|
||||
{% elif job.status =='complete' %}
|
||||
{% set badge_color = 'teal' %}
|
||||
{% else %}
|
||||
{% set badge_color = 'red' %}
|
||||
{% endif %}
|
||||
|
||||
<li class="collection-item avatar">
|
||||
<i class="material-icons circle">
|
||||
{% if job.service == 'nlp' %}
|
||||
format_textdirection_l_to_r
|
||||
{% elif job.service =='ocr' %}
|
||||
find_in_page
|
||||
{% else %}
|
||||
help
|
||||
{% endif %}
|
||||
</i>
|
||||
<span class="new badge teal" data-badge-caption="">{{ job.status }}</span>
|
||||
<i class="material-icons circle">{{ service_icon }}</i>
|
||||
<span class="new badge {{ badge_color }}" data-badge-caption="">{{ job.status }}</span>
|
||||
<span class="title">{{ job.title }}</span>
|
||||
<p>{{ job.description }}</p>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user