Skip to content

Commit

Permalink
fix: create storage dir on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg committed Nov 12, 2023
1 parent f7e8879 commit 39f9c37
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
4 changes: 3 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion pro_wes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,26 @@ 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()
except NotFound:
service_info.set_service_info(
data=current_app.config.foca.custom.service_info.dict()
)
return app


def run_app(app: App) -> None:
Expand Down
12 changes: 4 additions & 8 deletions pro_wes/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
8 changes: 5 additions & 3 deletions pro_wes/ga4gh/wes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion pro_wes/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Single source of truth for package version."""

__version__ = "0.18.0"
__version__ = "0.19.0"

0 comments on commit 39f9c37

Please sign in to comment.