mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
use job id for swarm run instead of job object
This commit is contained in:
parent
a302d08405
commit
ad8a8a4696
@ -48,8 +48,7 @@ def nlp():
|
||||
' NOTE: Using self created threads is just for testing purpose as
|
||||
' there is no scheduler available.
|
||||
'''
|
||||
db.session.expunge(nlp_job)
|
||||
thread = Thread(target=swarm.run, args=(nlp_job,))
|
||||
thread = Thread(target=swarm.run, args=(nlp_job.id,))
|
||||
thread.start()
|
||||
flash('Job created!')
|
||||
return redirect(url_for('services.nlp'))
|
||||
@ -101,8 +100,7 @@ def ocr():
|
||||
' NOTE: Using self created threads is just for testing purpose as
|
||||
' there is no scheduler available.
|
||||
'''
|
||||
db.session.expunge(ocr_job)
|
||||
thread = Thread(target=swarm.run, args=(ocr_job,))
|
||||
thread = Thread(target=swarm.run, args=(ocr_job.id,))
|
||||
thread.start()
|
||||
flash('Job created!')
|
||||
return redirect(url_for('services.ocr'))
|
||||
|
@ -30,10 +30,13 @@ class Swarm:
|
||||
' ¹ https://blog.alexellis.io/containers-on-swarm/
|
||||
'''
|
||||
|
||||
def run(self, job):
|
||||
def run(self, job_id):
|
||||
'''
|
||||
Input is a job object. From this the _command is built.
|
||||
Input is a job id.
|
||||
'''
|
||||
from .models import Job
|
||||
session = self.Session()
|
||||
job = session.query(Job).filter_by(id=job_id).first()
|
||||
# Prepare argument values needed for the service creation.
|
||||
service_args = json.loads(job.service_args)
|
||||
_command = (job.service
|
||||
@ -98,9 +101,9 @@ class Swarm:
|
||||
time.sleep(1)
|
||||
service.reload()
|
||||
'''
|
||||
' The following is scheduler work.
|
||||
' Poll the service until the job is completly executed.
|
||||
'''
|
||||
session = self.Session()
|
||||
session.add(job)
|
||||
job.status = 'running'
|
||||
session.commit()
|
||||
|
Loading…
Reference in New Issue
Block a user