From 39f9c3772cdf44d3ef1ea2bbaf4fdb0348331f64 Mon Sep 17 00:00:00 2001 From: Alex Kanitz Date: Sun, 12 Nov 2023 13:17:08 +0100 Subject: [PATCH] fix: create storage dir on startup --- docker-compose.yaml | 4 +++- pro_wes/app.py | 13 ++++++++++++- pro_wes/exceptions.py | 12 ++++-------- pro_wes/ga4gh/wes/models.py | 8 +++++--- pro_wes/version.py | 2 +- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f9fd11e..01d896f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,7 +12,7 @@ services: - rabbitmq command: bash -c "cd /app/pro_wes; celery -A celery_worker worker -E --loglevel=info" volumes: - - ${PROWES_DATA_DIR:-../data/pro_wes}:/data + - ${PROWES_DATA_DIR:-../data/pro_wes/runs}:/data prowes: image: prowes:latest @@ -25,6 +25,8 @@ services: command: bash -c "cd /app/pro_wes; gunicorn -c gunicorn.py wsgi:app" ports: - "8090:8080" + volumes: + - ${PROWES_DATA_DIR:-../data/pro_wes/runs}:/data rabbitmq: image: rabbitmq:3-management diff --git a/pro_wes/app.py b/pro_wes/app.py index cec3f54..2eca437 100644 --- a/pro_wes/app.py +++ b/pro_wes/app.py @@ -21,7 +21,19 @@ def init_app() -> App: custom_config_model="pro_wes.config_models.CustomConfig", ) app = foca.create_app() + _setup_first_start(app=app) + return app + + +def _setup_first_start(app: App) -> None: + """Set up application for first start.""" with app.app.app_context(): + # create storage directory + work_dir = Path( + current_app.config.foca.custom.post_runs.storage_path.resolve() + ) + work_dir.mkdir(parents=True, exist_ok=True) + # set service info service_info = ServiceInfo() try: service_info = service_info.get_service_info() @@ -29,7 +41,6 @@ def init_app() -> App: service_info.set_service_info( data=current_app.config.foca.custom.service_info.dict() ) - return app def run_app(app: App) -> None: diff --git a/pro_wes/exceptions.py b/pro_wes/exceptions.py index 13499e6..b7965c7 100644 --- a/pro_wes/exceptions.py +++ b/pro_wes/exceptions.py @@ -24,23 +24,19 @@ class EngineUnavailable(EngineProblem): class NoSuitableEngine(BadRequest): - """Raised when the service does not know of a suitable engine to process - the requested workflow run. - """ + """No suitable workflow engine known.""" class RunNotFound(NotFound): - """Raised when workflow run with given run identifier was not found.""" + """Workflow run with given identifier not found.""" class IdsUnavailableProblem(PyMongoError): - """Raised when no unique run identifier could be found for insertion into - the database collection. - """ + """No unique run identifier available.""" class StorageUnavailableProblem(OSError): - """Raised when storage is not available for OS operations.""" + """Storage unavailable for OS operations.""" exceptions = { diff --git a/pro_wes/ga4gh/wes/models.py b/pro_wes/ga4gh/wes/models.py index 48c40bd..8737785 100644 --- a/pro_wes/ga4gh/wes/models.py +++ b/pro_wes/ga4gh/wes/models.py @@ -182,8 +182,7 @@ def workflow_type_and_version_supported( # pylint: disable=no-self-argument The validated field values. Raises: - NoSuitableEngine: The service does not know of a suitable workflow - engine service to process this request. + NoSuitableEngine: No suitable workflow engine known to process request. """ service_info = ServiceInfoController().get_service_info(get_counts=False) type_versions = service_info["workflow_type_versions"] @@ -193,7 +192,10 @@ def workflow_type_and_version_supported( # pylint: disable=no-self-argument _type not in type_versions or version not in type_versions[_type]["workflow_type_version"] ): - raise NoSuitableEngine + raise NoSuitableEngine( + f"No suitable workflow engine known for workflow type '{_type}' and" + f" version '{version}'; supported workflow engines: {type_versions}" + ) return values diff --git a/pro_wes/version.py b/pro_wes/version.py index 7e0737b..a387881 100644 --- a/pro_wes/version.py +++ b/pro_wes/version.py @@ -1,3 +1,3 @@ """Single source of truth for package version.""" -__version__ = "0.18.0" +__version__ = "0.19.0"