Skip to content

Commit 6402391

Browse files
committed
specs: 'GET /runs/{run_id}' response spec-compliant
1 parent a641bc7 commit 6402391

File tree

6 files changed

+146
-56
lines changed

6 files changed

+146
-56
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ subprocess32==3.5.2
6363
swagger-spec-validator==2.3.1
6464
typed-ast==1.1.0
6565
typing==3.6.6
66-
typing-extensions==3.7.4
66+
typing-extensions==3.6.5
6767
urllib3==1.24.2
6868
vine==1.1.4
6969
Werkzeug==0.15.3

wes_elixir/config/app_config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ api:
5858
validate_responses: True
5959
swagger_ui: True
6060
swagger_json: True
61+
general_params:
62+
time_format: "%Y-%m-%dT%H:%M:%SZ"
6163
endpoint_params:
6264
default_page_size: 5
6365
timeout_cancel_run: 60

wes_elixir/database/db_utils.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Utility functions for MongoDB document insertion, updates and retrieval."""
22

3-
from typing import (Any, List, Mapping, Optional)
3+
from typing import (Any, Dict, List, Mapping, Optional)
44

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

7777

7878
def append_to_tes_task_logs(
7979
collection: Collection,
8080
task_id: str,
81-
tes_log: str
81+
task_log: Dict,
8282
) -> Optional[Mapping[Any, Any]]:
8383
"""Appends task log to TES task logs and returns updated document."""
8484
return collection.find_one_and_update(
8585
{'task_id': task_id},
86-
{'$push': {'api.task_logs': tes_log}},
86+
{'$push': {'internal.tes_logs': task_log}},
87+
return_document=ReturnDocument.AFTER
88+
)
89+
90+
91+
def append_to_wes_task_logs(
92+
collection: Collection,
93+
task_id: str,
94+
task_log: Dict,
95+
) -> Optional[Mapping[Any, Any]]:
96+
"""Appends task log to WES task logs and returns updated document."""
97+
return collection.find_one_and_update(
98+
{'task_id': task_id},
99+
{'$push': {'api.task_logs': task_log}},
87100
return_document=ReturnDocument.AFTER
88101
)
89102

wes_elixir/ga4gh/wes/endpoints/run_workflow.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,7 @@ def __process_workflow_attachments(data: Dict) -> Dict:
363363
data['api']['request']['workflow_url']
364364
)
365365

366-
# Extract name and extensions of workflow
367-
workflow_name_ext = os.path.splitext(
368-
os.path.basename(
369-
data['internal']['cwl_path']
370-
)
371-
)
372-
373-
# Get parameter file
366+
# Extract name and extensions of workflow
374367
workflow_name_ext = os.path.splitext(
375368
os.path.basename(
376369
data['internal']['cwl_path']
@@ -431,6 +424,9 @@ def __process_workflow_attachments(data: Dict) -> Dict:
431424

432425
# Strip workflow attachments from data
433426
del data['api']['request']['workflow_attachment']
427+
428+
# Add workflow base name (without extension) to document
429+
data['api']['run_log']['name'] = str(workflow_name_ext[0])
434430

435431
# Return form data stripped of workflow attachments
436432
return data

0 commit comments

Comments
 (0)