Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create storage dir on startup #83

Merged
merged 3 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions bla

This file was deleted.

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
11 changes: 10 additions & 1 deletion pro_wes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ 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"