diff --git a/Makefile b/Makefile index 08d151d..93e5a3c 100644 --- a/Makefile +++ b/Makefile @@ -51,4 +51,19 @@ dev-app da: .PHONY: dev-celery dc dev-celery dc: @echo "Starting Celery worker..." - cd pro_wes && celery -A celery_worker worker -E --loglevel=info \ No newline at end of file + cd pro_wes && celery -A celery_worker worker -E --loglevel=info + +.PHONY: lint fl +lint fl: + + @echo "1.Formatting with black..." + black --exclude .venv pro_wes/ setup.py tests/ + @echo "\n\n2.Checking style with flake8..." + black --exclude .venv pro_wes/ setup.py tests/ + @echo "\n\n3.Running pylint..." + pylint pro_wes/ setup.py + +.PHONY: type-check tc +type-check tc: + @echo "Running mypy..." + mypy pro_wes/ setup.py \ No newline at end of file diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 58e8a57..85111a9 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -11,7 +11,7 @@ services: image: mongo:3.2 restart: unless-stopped volumes: - - ${PROWES_DATA_DIR:-../data/pro_wes}/db:${PWD}/data/db + - ${PROWES_DATA_DIR:-../data/pro_wes}/db:/data/db ports: - "27017:27017" diff --git a/docker-compose.yaml b/docker-compose.yaml index 5003b87..50c7dc0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -33,7 +33,7 @@ services: links: - mongodb ports: - - "5682:5672" + - "5672:5672" mongodb: image: mongo:3.2 @@ -41,7 +41,7 @@ services: volumes: - ${PROWES_DATA_DIR:-../data/pro_wes}/db:/data/db ports: - - "27027:27017" + - "27017:27017" flower: image: mher/flower:0.9.7 @@ -50,4 +50,4 @@ services: - prowes-worker command: flower --broker=amqp://guest:guest@rabbitmq:5672// --port=5555 ports: - - "5565:5555" + - "5555:5555" diff --git a/pro_wes/app.py b/pro_wes/app.py index a6373c1..66aa05a 100644 --- a/pro_wes/app.py +++ b/pro_wes/app.py @@ -1,6 +1,5 @@ """proWES application entry point.""" -import os from pathlib import Path from connexion import App @@ -17,13 +16,8 @@ def init_app() -> App: Returns: FOCA application. """ - _parent_dir = Path(__file__).resolve().parent - if os.environ.get("ENVIRONMENT") == "DEV": - config_file = _parent_dir / "config.dev.yaml" - else: - config_file = _parent_dir / "config.yaml" foca = Foca( - config_file=config_file, + config_file=Path(__file__).resolve().parent / "config.yaml", custom_config_model="pro_wes.config_models.CustomConfig", ) app = foca.create_app() @@ -53,6 +47,5 @@ def run_app(app: App) -> None: if __name__ == "__main__": - os.environ.setdefault("ENVIRONMENT", "DEV") foca_app = init_app() run_app(app=foca_app) diff --git a/pro_wes/config.dev.yaml b/pro_wes/config.dev.yaml deleted file mode 100644 index ff2e59a..0000000 --- a/pro_wes/config.dev.yaml +++ /dev/null @@ -1,154 +0,0 @@ -# FOCA configuration -# Available in app context as attributes of `current_app.config.foca` -# Automatically validated via FOCA -# Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html - -# Server configuration -# Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.ServerConfig -server: - host: "0.0.0.0" - port: 8080 - debug: True - environment: development - testing: False - use_reloader: False - -# Security configuration -# Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.SecurityConfig -security: - auth: - add_key_to_claims: True - algorithms: - - RS256 - allow_expired: False - audience: null - validation_methods: - - userinfo - - public_key - validation_checks: any - -# Database configuration -# Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.DBConfig -db: - host: localhost - port: 27017 - dbs: - runStore: - collections: - runs: - indexes: - - keys: - run_id: 1 - task_id: 1 - options: - "unique": True - "sparse": True - service_info: - indexes: - - keys: - id: 1 - -# API configuration -# Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.APIConfig -api: - specs: - - path: - - pro_wes/api/20201124.tag_1_0_1.workflow_execution_service.openapi.yaml - - pro_wes/api/additions.openapi.yaml - add_operation_fields: - x-openapi-router-controller: pro_wes.ga4gh.wes.controllers - add_security_fields: - x-bearerInfoFunc: app.validate_token - disable_auth: True - connexion: - strict_validation: True - # workaround until cwl-WES responses are fixed - validate_responses: False - base_path: /ga4gh/wes/v1 - options: - swagger_ui: True - serve_spec: True - -# Logging configuration -# Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.LogConfig -log: - version: 1 - disable_existing_loggers: False - formatters: - standard: - class: logging.Formatter - style: "{" - format: "[{asctime}: {levelname:<8}] {message} [{name}]" - handlers: - console: - class: logging.StreamHandler - level: 20 - formatter: standard - stream: ext://sys.stderr - root: - level: 10 - handlers: [console] - -# Background job configuration -# Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.JobsConfig -jobs: - host: rabbitmq - port: 5672 - backend: "rpc://" - include: - - pro_wes.tasks.track_run_progress - -# Exception configuration -# Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.ExceptionConfig -exceptions: - required_members: [["message"], ["code"]] - status_member: ["code"] - exceptions: pro_wes.exceptions.exceptions - -# Custom configuration -# Available in app context as attributes of `current_app.config.foca` -custom: - defaults: - timeout: 2 - post_runs: - db_insert_attempts: 10 - id_charset: string.ascii_uppercase + string.digits - id_length: 6 - polling_attempts: 100 - polling_wait: 3 - storage_path: "./data" - timeout_job: null - timeout_post: null - list_runs: - default_page_size: 5 - service_info: - auth_instructions_url: "https://example.org/auth_instructions" - default_workflow_engine_parameters: [] - id: v1.wes.ga4gh.org.example - name: "proWES example deployment" - supported_filesystem_protocols: - - https - supported_wes_versions: - - 1.0.1 - tags: - key: "value" - type: - group: "org.ga4gh" - artifact: "wes" - version: "1.0.1" - workflow_engine_versions: - cwl-engine: "1.2.3" - workflow_type_versions: - CWL: - workflow_type_version: - - v1.0 - description: "WES gateway service" - organization: - name: "Example organization" - url: "https://example.org" - contactUrl: "support@example.org" - documentationUrl: "https://example.org/docs" - createdAt: "2020-01-01T00:00:00Z" - updatedAt: "2022-12-31T00:00:00Z" - environment: "test" - version: "0.18.0" diff --git a/pro_wes/config.yaml b/pro_wes/config.yaml index febfd4c..a0ff875 100644 --- a/pro_wes/config.yaml +++ b/pro_wes/config.yaml @@ -30,7 +30,7 @@ security: # Database configuration # Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.DBConfig db: - host: mongodb + host: localhost port: 27017 dbs: runStore: @@ -92,7 +92,7 @@ log: # Background job configuration # Cf. https://foca.readthedocs.io/en/latest/modules/foca.models.html#foca.models.config.JobsConfig jobs: - host: rabbitmq + host: localhost port: 5672 backend: "rpc://" include: @@ -116,7 +116,7 @@ custom: id_length: 6 polling_attempts: 100 polling_wait: 3 - storage_path: "/data" + storage_path: "./data" timeout_job: null timeout_post: null list_runs: diff --git a/pro_wes/ga4gh/wes/workflow_runs.py b/pro_wes/ga4gh/wes/workflow_runs.py index d3fd27e..74b97a8 100644 --- a/pro_wes/ga4gh/wes/workflow_runs.py +++ b/pro_wes/ga4gh/wes/workflow_runs.py @@ -482,7 +482,9 @@ def _validate_run_request( """ dict_of_lists = form_data.to_dict(flat=False) # flatten single item lists - dict_atomic = {k: v[0] if len(v) == 1 else v for k, v in dict_of_lists.items()} + dict_atomic: dict = { + k: v[0] if len(v) == 1 else v for k, v in dict_of_lists.items() + } # remove 'workflow_attachment' field dict_atomic.pop("workflow_attachment", None) model_instance = RunRequest(**dict_atomic) diff --git a/requirements.txt b/requirements.txt index 84a9ba1..14f3624 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ connexion<3 email-validator>=2.1.0,<3 -foca>=0.12.1 +foca==0.12.1 gunicorn>=20.1.0,<21 -pymongo==4.7 # Cf. https://github.com/elixir-cloud-aai/foca/issues/246