Skip to content

Commit 844679d

Browse files
committed
pushing changes from biohackathon
1 parent 6402391 commit 844679d

11 files changed

+805
-20
lines changed

.netrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
machine ftp-private.ebi.ac.uk
2+
login tesk-1
3+
password Z6fsH6MG

requirements.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ cffi==1.11.5
1313
chardet==3.0.4
1414
click==6.7
1515
clickclick==1.2.2
16-
connexion==1.5.2
16+
connexion==2.4.0
1717
cryptography==2.3.1
18-
-e git+https://github.com/ohsu-comp-bio/cwl-tes.git@62840435c5b22ac7b3ad1724047d811f72dd372d#egg=cwl-tes
18+
-e git+https://github.com/uniqueg/cwl-tes-temp.git@e37090e00f2573e84becec30f0ade9c5003820b3#egg=cwl_tes
1919
cwltool==1.0.20181217162649
2020
decorator==4.3.0
21-
Flask==1.0.2
21+
Flask==1.1.1
2222
Flask-Cors==3.0.6
2323
Flask-PyMongo==2.1.0
2424
future==0.16.0
@@ -40,6 +40,7 @@ mccabe==0.6.1
4040
mistune==0.8.4
4141
mypy-extensions==0.4.1
4242
networkx==2.2
43+
openapi-spec-validator==0.2.8
4344
prov==1.5.1
4445
psutil==5.4.7
4546
py-tes==0.3.0
@@ -50,7 +51,7 @@ pymongo==3.7.1
5051
pyparsing==2.2.1
5152
python-dateutil==2.6.1
5253
pytz==2018.5
53-
PyYAML==4.2b1
54+
PyYAML==5.1.2
5455
rdflib==4.2.2
5556
rdflib-jsonld==0.4.0
5657
requests==2.20.0
@@ -61,9 +62,10 @@ shellescape==3.4.1
6162
six==1.11.0
6263
subprocess32==3.5.2
6364
swagger-spec-validator==2.3.1
65+
swagger-ui-bundle==0.0.6
6466
typed-ast==1.1.0
6567
typing==3.6.6
66-
typing-extensions==3.6.5
68+
typing-extensions==3.7.4
6769
urllib3==1.24.2
6870
vine==1.1.4
6971
Werkzeug==0.15.3

wes_elixir/api/controllers.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""Controller for auxiliary WES-ELIXIR API endpoints."""
2+
3+
import logging
4+
5+
from celery import current_app as celery_app
6+
from connexion import request
7+
from flask import current_app
8+
9+
from wes_elixir.security.decorators import auth_token_optional
10+
11+
# Get logger instance
12+
logger = logging.getLogger(__name__)
13+
14+
15+
# GET /stdout/<run_id>
16+
@auth_token_optional
17+
def get_stdout(run_id, *args, **kwargs):
18+
"""Returns run STDOUT as plain text."""
19+
response = ""
20+
log_request(request, response)
21+
return response
22+
23+
24+
# POST /stderr/<run_id>
25+
@auth_token_optional
26+
def get_stderr(run_id, *args, **kwargs):
27+
"""Returns run STDERR as plain text."""
28+
response = ""
29+
log_request(request, response)
30+
return response
31+
32+
33+
def log_request(request, response):
34+
"""Writes request and response to log."""
35+
# TODO: write decorator for request logging
36+
logger.debug(
37+
(
38+
"Response to request \"{method} {path} {protocol}\" from "
39+
"{remote_addr}: {response}"
40+
).format(
41+
method=request.environ['REQUEST_METHOD'],
42+
path=request.environ['PATH_INFO'],
43+
protocol=request.environ['SERVER_PROTOCOL'],
44+
remote_addr=request.environ['REMOTE_ADDR'],
45+
response=response,
46+
)
47+
)

wes_elixir/api/register_openapi.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,20 @@ def register_openapi(
3939
path = __add_security_definitions(in_file=path)
4040

4141
# Generate API endpoints from OpenAPI spec
42+
options = {
43+
"swagger_ui": get_conf(spec, 'swagger_ui'),
44+
"serve_spec": get_conf(spec, 'swagger_json'),
45+
}
46+
base_path = get_conf(spec, 'base_path')
47+
if not base_path:
48+
base_path = None
4249
try:
4350
app.add_api(
4451
path,
4552
strict_validation=get_conf(spec, 'strict_validation'),
4653
validate_responses=get_conf(spec, 'validate_responses'),
47-
swagger_ui=get_conf(spec, 'swagger_ui'),
48-
swagger_json=get_conf(spec, 'swagger_json'),
54+
options=options,
55+
base_path=base_path,
4956
)
5057

5158
logger.info("API endpoints specified in '{path}' added.".format(
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
openapi: 3.0.0
2+
info:
3+
title: WES-ELIXIR STDOUT & STDERR OpenAPI specification
4+
contact:
5+
name: ELIXIR Cloud & AAI group
6+
7+
license:
8+
name: Apache 2.0
9+
url: https://www.apache.org/licenses/LICENSE-2.0
10+
version: 0.14.0
11+
servers:
12+
- url: /wes-elixir/v1
13+
paths:
14+
/stdout/{run_id}:
15+
get:
16+
summary: |-
17+
Retrieves the content of the indicated run's STDOUT stream and returns
18+
it as plain text.
19+
parameters:
20+
- in: path
21+
name: run_id
22+
schema:
23+
type: string
24+
required: true
25+
description: Run identifier.
26+
operationId: get_stdout
27+
responses:
28+
200:
29+
description: |-
30+
STDOUT stream of indicated run as plain text.
31+
content:
32+
text/plain:
33+
schema:
34+
type: string
35+
example: "This is STDOUT."
36+
400:
37+
description: The request is malformed.
38+
content:
39+
application/json:
40+
schema:
41+
$ref: '#/components/schemas/ErrorResponse'
42+
401:
43+
description: The request is unauthorized.
44+
content:
45+
application/json:
46+
schema:
47+
$ref: '#/components/schemas/ErrorResponse'
48+
403:
49+
description: The requester is not authorized to perform this action.
50+
content:
51+
application/json:
52+
schema:
53+
$ref: '#/components/schemas/ErrorResponse'
54+
404:
55+
description: The requested resource was not found.
56+
content:
57+
application/json:
58+
schema:
59+
$ref: '#/components/schemas/ErrorResponse'
60+
500:
61+
description: An unexpected error occurred.
62+
content:
63+
application/json:
64+
schema:
65+
$ref: '#/components/schemas/ErrorResponse'
66+
x-openapi-router-controller: api.controllers
67+
/stderr/{run_id}:
68+
get:
69+
summary: |-
70+
Retrieves the content of the indicated run's STDERR stream and returns
71+
it as plain text.
72+
operationId: get_stderr
73+
parameters:
74+
- in: path
75+
name: run_id
76+
schema:
77+
type: string
78+
required: true
79+
description: Run identifier.
80+
responses:
81+
200:
82+
description: |-
83+
STDERR stream of indicated run as plain text.
84+
content:
85+
text/plain:
86+
schema:
87+
type: string
88+
example: "This is STDERR."
89+
400:
90+
description: The request is malformed.
91+
content:
92+
application/json:
93+
schema:
94+
$ref: '#/components/schemas/ErrorResponse'
95+
401:
96+
description: The request is unauthorized.
97+
content:
98+
application/json:
99+
schema:
100+
$ref: '#/components/schemas/ErrorResponse'
101+
403:
102+
description: The requester is not authorized to perform this action.
103+
content:
104+
application/json:
105+
schema:
106+
$ref: '#/components/schemas/ErrorResponse'
107+
404:
108+
description: The requested resource was not found.
109+
content:
110+
application/json:
111+
schema:
112+
$ref: '#/components/schemas/ErrorResponse'
113+
500:
114+
description: An unexpected error occurred.
115+
content:
116+
application/json:
117+
schema:
118+
$ref: '#/components/schemas/ErrorResponse'
119+
x-openapi-router-controller: api.controllers
120+
components:
121+
schemas:
122+
Error:
123+
required:
124+
- message
125+
- reason
126+
type: object
127+
properties:
128+
message:
129+
type: string
130+
description: |-
131+
A human readable message providing more details about the error.
132+
example:
133+
Required parameter 'xyz' is missing.
134+
reason:
135+
type: string
136+
description: |-
137+
Unique identifier for this error, but *not* the HTTP response code
138+
(e.g., name of exception).
139+
example: ValueError
140+
description: An individual error message.
141+
ErrorResponse:
142+
required:
143+
- code
144+
- errors
145+
- message
146+
type: object
147+
properties:
148+
code:
149+
type: integer
150+
description: HTTP status code (e.g., 400, 404).
151+
format: int64
152+
example: 400
153+
errors:
154+
type: array
155+
description: List of associated errors and warnings.
156+
items:
157+
$ref: '#/components/schemas/Error'
158+
message:
159+
type: string
160+
description: |-
161+
A human readable message providing more details about the error.
162+
example: The request could not be interpreted.
163+
description: A response object for detailed error messages.

wes_elixir/config/app_config.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,20 @@ celery:
5353
# OpenAPI specs
5454
api:
5555
specs:
56-
- path: '20181023.c5406f1-v1-0-0.workflow_execution_service.swagger.yaml'
56+
- name: 'WES'
57+
path: '20181023.c5406f1-v1-0-0.workflow_execution_service.swagger.yaml'
5758
strict_validation: True
5859
validate_responses: True
5960
swagger_ui: True
6061
swagger_json: True
62+
base_path: False
63+
- name: 'stdout_stderr'
64+
path: 'schema.stdout_stderr.openapi.yaml'
65+
strict_validation: True
66+
validate_responses: True
67+
swagger_ui: True
68+
swagger_json: True
69+
base_path: '/wes-elixir/v1'
6170
general_params:
6271
time_format: "%Y-%m-%dT%H:%M:%SZ"
6372
endpoint_params:

wes_elixir/ga4gh/wes/endpoints/get_run_log.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ def get_run_log(
5252
)
5353
raise Forbidden
5454

55+
# Remove
56+
5557
return run_log

0 commit comments

Comments
 (0)