mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +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"],
|
"--skip-binarisation"],
|
||||||
"lang": new_ocr_job_form.language.data,
|
"lang": new_ocr_job_form.language.data,
|
||||||
"version": new_ocr_job_form.version.data}),
|
"version": new_ocr_job_form.version.data}),
|
||||||
status="submitted",
|
status="pending",
|
||||||
title=new_ocr_job_form.title.data)
|
title=new_ocr_job_form.title.data)
|
||||||
db.session.add(ocr_job)
|
db.session.add(ocr_job)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
@ -74,7 +74,7 @@ def nlp():
|
|||||||
service_args=json.dumps({"args": [],
|
service_args=json.dumps({"args": [],
|
||||||
"lang": new_nlp_job_form.language.data,
|
"lang": new_nlp_job_form.language.data,
|
||||||
"version": new_nlp_job_form.version.data}),
|
"version": new_nlp_job_form.version.data}),
|
||||||
status="submitted",
|
status="pending",
|
||||||
title=new_nlp_job_form.title.data)
|
title=new_nlp_job_form.title.data)
|
||||||
db.session.add(nlp_job)
|
db.session.add(nlp_job)
|
||||||
db.session.commit()
|
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.
|
' Poll the service until the job is completly executed.
|
||||||
'''
|
'''
|
||||||
session = self.Session()
|
session = self.Session()
|
||||||
while True:
|
job.status = 'running'
|
||||||
current_state = service.tasks()[0].get('Status').get('State')
|
|
||||||
if job.status != current_state:
|
|
||||||
job.status = current_state
|
|
||||||
session.add(job)
|
session.add(job)
|
||||||
session.commit()
|
session.commit()
|
||||||
if current_state == 'complete':
|
current_state = None
|
||||||
|
while True:
|
||||||
|
current_state = service.tasks()[0].get('Status').get('State')
|
||||||
|
if current_state == 'complete' or current_state == 'failed':
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
service.reload()
|
service.reload()
|
||||||
|
job.status = current_state
|
||||||
|
session.add(job)
|
||||||
|
session.commit()
|
||||||
session.close()
|
session.close()
|
||||||
# Remove the service from the swarm.
|
# Remove the service from the swarm.
|
||||||
service.remove()
|
service.remove()
|
||||||
|
@ -58,17 +58,27 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% for job in current_user.jobs.all() %}
|
{% for job in current_user.jobs.all() %}
|
||||||
<li class="collection-item avatar">
|
|
||||||
<i class="material-icons circle">
|
|
||||||
{% if job.service == 'nlp' %}
|
{% if job.service == 'nlp' %}
|
||||||
format_textdirection_l_to_r
|
{% set service_icon = 'format_textdirection_l_to_r' %}
|
||||||
{% elif job.service =='ocr' %}
|
{% elif job.service =='ocr' %}
|
||||||
find_in_page
|
{% set service_icon = 'find_in_page' %}
|
||||||
{% else %}
|
{% else %}
|
||||||
help
|
{% set service_icon = 'help' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</i>
|
|
||||||
<span class="new badge teal" data-badge-caption="">{{ job.status }}</span>
|
{% 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">{{ service_icon }}</i>
|
||||||
|
<span class="new badge {{ badge_color }}" data-badge-caption="">{{ job.status }}</span>
|
||||||
<span class="title">{{ job.title }}</span>
|
<span class="title">{{ job.title }}</span>
|
||||||
<p>{{ job.description }}</p>
|
<p>{{ job.description }}</p>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user