mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Remove ugly workaround for scheduler function. Now the current app_context is used, instead of creating a new app instance.
This commit is contained in:
parent
5ff2ef9301
commit
6975076fc3
@ -40,13 +40,3 @@ def create_app(config_name):
|
||||
app.register_blueprint(admin_blueprint, url_prefix='/admin')
|
||||
|
||||
return app
|
||||
|
||||
|
||||
def create_minimal_app(config_name):
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config[config_name])
|
||||
|
||||
config[config_name].init_app(app)
|
||||
db.init_app(app)
|
||||
|
||||
return app
|
||||
|
@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from . import create_minimal_app, db
|
||||
from . import db, scheduler
|
||||
from .models import Job
|
||||
import docker
|
||||
import json
|
||||
@ -7,8 +7,7 @@ import os
|
||||
|
||||
|
||||
def checkout_jobs():
|
||||
app = create_minimal_app(os.getenv('FLASK_CONFIG') or 'default')
|
||||
app.app_context().push()
|
||||
with scheduler.app.app_context():
|
||||
client = docker.from_env()
|
||||
jobs = db.session.query(Job)
|
||||
submitted_jobs = jobs.filter_by(status='submitted').all()
|
||||
@ -39,8 +38,8 @@ def checkout_jobs():
|
||||
'
|
||||
' While the cpu_reservation value has to be in nanos, the
|
||||
' mem_reservation value must be presented in an unscaled form
|
||||
' (intuitive right?). Bacause the job object provides the memory value
|
||||
' in megabytes, it is also necessary to convert the value.
|
||||
' (intuitive right?). Bacause the job object provides the memory
|
||||
' value in megabytes, it is also necessary to convert the value.
|
||||
'''
|
||||
_resources = docker.types.Resources(
|
||||
cpu_reservation=job.n_cores * (10 ** 9),
|
||||
@ -50,10 +49,10 @@ def checkout_jobs():
|
||||
'''
|
||||
' Create the service with the prepared values.
|
||||
'
|
||||
' Note: A service reserves hardware ressources. In case no worker node
|
||||
' has the required ressources available (not reserved), the
|
||||
' service gets queued by the Docker engine until a node is able
|
||||
' to meet the requirements.
|
||||
' Note: A service reserves hardware ressources. In case no worker
|
||||
' node has the required ressources available (not reserved),
|
||||
' the service gets queued by the Docker engine until a node
|
||||
' is able to meet the requirements.
|
||||
'''
|
||||
service = client.services.create(
|
||||
_image,
|
||||
|
Loading…
Reference in New Issue
Block a user