Skip to content

Commit

Permalink
specs: 'GET /runs/{run_id}' response spec-compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg committed Nov 5, 2019
1 parent a641bc7 commit 6402391
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 56 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ subprocess32==3.5.2
swagger-spec-validator==2.3.1
typed-ast==1.1.0
typing==3.6.6
typing-extensions==3.7.4
typing-extensions==3.6.5
urllib3==1.24.2
vine==1.1.4
Werkzeug==0.15.3
Expand Down
2 changes: 2 additions & 0 deletions wes_elixir/config/app_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ api:
validate_responses: True
swagger_ui: True
swagger_json: True
general_params:
time_format: "%Y-%m-%dT%H:%M:%SZ"
endpoint_params:
default_page_size: 5
timeout_cancel_run: 60
Expand Down
23 changes: 18 additions & 5 deletions wes_elixir/database/db_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utility functions for MongoDB document insertion, updates and retrieval."""

from typing import (Any, List, Mapping, Optional)
from typing import (Any, Dict, List, Mapping, Optional)

from bson.objectid import ObjectId
from pymongo.collection import ReturnDocument
Expand Down Expand Up @@ -69,21 +69,34 @@ def update_tes_task_state(
) -> Optional[Mapping[Any, Any]]:
"""Updates `state` field in TES task log and returns updated document."""
return collection.find_one_and_update(
{'task_id': task_id, 'api.task_logs': {'$elemMatch': {'id': tes_id}}},
{'$set': {'api.task_logs.$.state': state}},
{'task_id': task_id, 'internal.tes_logs': {'$elemMatch': {'id': tes_id}}},
{'$set': {'internal.tes_logs.$.state': state}},
return_document=ReturnDocument.AFTER
)


def append_to_tes_task_logs(
collection: Collection,
task_id: str,
tes_log: str
task_log: Dict,
) -> Optional[Mapping[Any, Any]]:
"""Appends task log to TES task logs and returns updated document."""
return collection.find_one_and_update(
{'task_id': task_id},
{'$push': {'api.task_logs': tes_log}},
{'$push': {'internal.tes_logs': task_log}},
return_document=ReturnDocument.AFTER
)


def append_to_wes_task_logs(
collection: Collection,
task_id: str,
task_log: Dict,
) -> Optional[Mapping[Any, Any]]:
"""Appends task log to WES task logs and returns updated document."""
return collection.find_one_and_update(
{'task_id': task_id},
{'$push': {'api.task_logs': task_log}},
return_document=ReturnDocument.AFTER
)

Expand Down
12 changes: 4 additions & 8 deletions wes_elixir/ga4gh/wes/endpoints/run_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,7 @@ def __process_workflow_attachments(data: Dict) -> Dict:
data['api']['request']['workflow_url']
)

# Extract name and extensions of workflow
workflow_name_ext = os.path.splitext(
os.path.basename(
data['internal']['cwl_path']
)
)

# Get parameter file
# Extract name and extensions of workflow
workflow_name_ext = os.path.splitext(
os.path.basename(
data['internal']['cwl_path']
Expand Down Expand Up @@ -431,6 +424,9 @@ def __process_workflow_attachments(data: Dict) -> Dict:

# Strip workflow attachments from data
del data['api']['request']['workflow_attachment']

# Add workflow base name (without extension) to document
data['api']['run_log']['name'] = str(workflow_name_ext[0])

# Return form data stripped of workflow attachments
return data
Expand Down
Loading

0 comments on commit 6402391

Please sign in to comment.