Commit d6eb9946 authored by David Mendez's avatar David Mendez
Browse files

Set up a custom static files path and directory to serve job outputs

parent a4e9254c
......@@ -8,6 +8,7 @@ from app.config import RUN_CONFIG
from app.config import RunEnvs
from app.db import DB
from app.models import delayed_job_models
from app.blueprints.job_submission.services import job_submission_service
from app.blueprints.swagger_description.swagger_description_blueprint import SWAGGER_BLUEPRINT
from app.blueprints.job_submission.controllers.job_submissions_controller import SUBMISSION_BLUEPRINT
from app.blueprints.job_status.job_status_controller import JOB_STATUS_BLUEPRINT
......@@ -19,7 +20,8 @@ def create_app():
:return: Delayed jobs flask app
"""
flask_app = Flask(__name__)
base_path = RUN_CONFIG.get('base_path', '')
flask_app = Flask(__name__, static_url_path=f'{base_path}/outputs', static_folder=job_submission_service.JOBS_OUTPUT_DIR)
flask_app.config['SQLALCHEMY_DATABASE_URI'] = RUN_CONFIG.get('sql_alchemy').get('database_uri')
flask_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = RUN_CONFIG.get('sql_alchemy').get('track_modifications')
flask_app.config['SECRET_KEY'] = RUN_CONFIG.get('server_secret_key')
......@@ -40,9 +42,6 @@ def create_app():
if generate_default_config:
delayed_job_models.generate_default_job_configs()
base_path = RUN_CONFIG.get('base_path', '')
flask_app.register_blueprint(SWAGGER_BLUEPRINT, url_prefix=f'{base_path}/swagger')
flask_app.register_blueprint(SUBMISSION_BLUEPRINT, url_prefix=f'{base_path}/submit')
flask_app.register_blueprint(JOB_STATUS_BLUEPRINT, url_prefix=f'{base_path}/status')
......
......@@ -268,3 +268,9 @@ class TestJobStatusDaemon(unittest.TestCase):
status_got = job.status
status_must_be = delayed_job_models.JobStatuses.FINISHED
self.assertEqual(status_got, status_must_be, msg='The status of the job was not changed accordingly!')
def test_collects_the_urls_for_the_outputs_of_a_finished_job(self):
"""
Generates some mock jobs, then sends a mock output to the function to test that it interprets that it finished.
The finished job should have now the output files set
"""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment