Skip to content

Commit

Permalink
pushing changes from biohackathon
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg committed Feb 20, 2020
1 parent 6402391 commit 844679d
Show file tree
Hide file tree
Showing 11 changed files with 805 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
machine ftp-private.ebi.ac.uk
login tesk-1
password Z6fsH6MG
12 changes: 7 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ cffi==1.11.5
chardet==3.0.4
click==6.7
clickclick==1.2.2
connexion==1.5.2
connexion==2.4.0
cryptography==2.3.1
-e git+https://github.com/ohsu-comp-bio/cwl-tes.git@62840435c5b22ac7b3ad1724047d811f72dd372d#egg=cwl-tes
-e git+https://github.com/uniqueg/cwl-tes-temp.git@e37090e00f2573e84becec30f0ade9c5003820b3#egg=cwl_tes
cwltool==1.0.20181217162649
decorator==4.3.0
Flask==1.0.2
Flask==1.1.1
Flask-Cors==3.0.6
Flask-PyMongo==2.1.0
future==0.16.0
Expand All @@ -40,6 +40,7 @@ mccabe==0.6.1
mistune==0.8.4
mypy-extensions==0.4.1
networkx==2.2
openapi-spec-validator==0.2.8
prov==1.5.1
psutil==5.4.7
py-tes==0.3.0
Expand All @@ -50,7 +51,7 @@ pymongo==3.7.1
pyparsing==2.2.1
python-dateutil==2.6.1
pytz==2018.5
PyYAML==4.2b1
PyYAML==5.1.2
rdflib==4.2.2
rdflib-jsonld==0.4.0
requests==2.20.0
Expand All @@ -61,9 +62,10 @@ shellescape==3.4.1
six==1.11.0
subprocess32==3.5.2
swagger-spec-validator==2.3.1
swagger-ui-bundle==0.0.6
typed-ast==1.1.0
typing==3.6.6
typing-extensions==3.6.5
typing-extensions==3.7.4
urllib3==1.24.2
vine==1.1.4
Werkzeug==0.15.3
Expand Down
47 changes: 47 additions & 0 deletions wes_elixir/api/controllers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Controller for auxiliary WES-ELIXIR API endpoints."""

import logging

from celery import current_app as celery_app
from connexion import request
from flask import current_app

from wes_elixir.security.decorators import auth_token_optional

# Get logger instance
logger = logging.getLogger(__name__)


# GET /stdout/<run_id>
@auth_token_optional
def get_stdout(run_id, *args, **kwargs):
"""Returns run STDOUT as plain text."""
response = ""
log_request(request, response)
return response


# POST /stderr/<run_id>
@auth_token_optional
def get_stderr(run_id, *args, **kwargs):
"""Returns run STDERR as plain text."""
response = ""
log_request(request, response)
return response


def log_request(request, response):
"""Writes request and response to log."""
# TODO: write decorator for request logging
logger.debug(
(
"Response to request \"{method} {path} {protocol}\" from "
"{remote_addr}: {response}"
).format(
method=request.environ['REQUEST_METHOD'],
path=request.environ['PATH_INFO'],
protocol=request.environ['SERVER_PROTOCOL'],
remote_addr=request.environ['REMOTE_ADDR'],
response=response,
)
)
11 changes: 9 additions & 2 deletions wes_elixir/api/register_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ def register_openapi(
path = __add_security_definitions(in_file=path)

# Generate API endpoints from OpenAPI spec
options = {
"swagger_ui": get_conf(spec, 'swagger_ui'),
"serve_spec": get_conf(spec, 'swagger_json'),
}
base_path = get_conf(spec, 'base_path')
if not base_path:
base_path = None
try:
app.add_api(
path,
strict_validation=get_conf(spec, 'strict_validation'),
validate_responses=get_conf(spec, 'validate_responses'),
swagger_ui=get_conf(spec, 'swagger_ui'),
swagger_json=get_conf(spec, 'swagger_json'),
options=options,
base_path=base_path,
)

logger.info("API endpoints specified in '{path}' added.".format(
Expand Down
163 changes: 163 additions & 0 deletions wes_elixir/api/schema.stdout_stderr.openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
openapi: 3.0.0
info:
title: WES-ELIXIR STDOUT & STDERR OpenAPI specification
contact:
name: ELIXIR Cloud & AAI group
email: [email protected]
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0
version: 0.14.0
servers:
- url: /wes-elixir/v1
paths:
/stdout/{run_id}:
get:
summary: |-
Retrieves the content of the indicated run's STDOUT stream and returns
it as plain text.
parameters:
- in: path
name: run_id
schema:
type: string
required: true
description: Run identifier.
operationId: get_stdout
responses:
200:
description: |-
STDOUT stream of indicated run as plain text.
content:
text/plain:
schema:
type: string
example: "This is STDOUT."
400:
description: The request is malformed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
401:
description: The request is unauthorized.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
403:
description: The requester is not authorized to perform this action.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
404:
description: The requested resource was not found.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
500:
description: An unexpected error occurred.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
x-openapi-router-controller: api.controllers
/stderr/{run_id}:
get:
summary: |-
Retrieves the content of the indicated run's STDERR stream and returns
it as plain text.
operationId: get_stderr
parameters:
- in: path
name: run_id
schema:
type: string
required: true
description: Run identifier.
responses:
200:
description: |-
STDERR stream of indicated run as plain text.
content:
text/plain:
schema:
type: string
example: "This is STDERR."
400:
description: The request is malformed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
401:
description: The request is unauthorized.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
403:
description: The requester is not authorized to perform this action.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
404:
description: The requested resource was not found.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
500:
description: An unexpected error occurred.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
x-openapi-router-controller: api.controllers
components:
schemas:
Error:
required:
- message
- reason
type: object
properties:
message:
type: string
description: |-
A human readable message providing more details about the error.
example:
Required parameter 'xyz' is missing.
reason:
type: string
description: |-
Unique identifier for this error, but *not* the HTTP response code
(e.g., name of exception).
example: ValueError
description: An individual error message.
ErrorResponse:
required:
- code
- errors
- message
type: object
properties:
code:
type: integer
description: HTTP status code (e.g., 400, 404).
format: int64
example: 400
errors:
type: array
description: List of associated errors and warnings.
items:
$ref: '#/components/schemas/Error'
message:
type: string
description: |-
A human readable message providing more details about the error.
example: The request could not be interpreted.
description: A response object for detailed error messages.
11 changes: 10 additions & 1 deletion wes_elixir/config/app_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,20 @@ celery:
# OpenAPI specs
api:
specs:
- path: '20181023.c5406f1-v1-0-0.workflow_execution_service.swagger.yaml'
- name: 'WES'
path: '20181023.c5406f1-v1-0-0.workflow_execution_service.swagger.yaml'
strict_validation: True
validate_responses: True
swagger_ui: True
swagger_json: True
base_path: False
- name: 'stdout_stderr'
path: 'schema.stdout_stderr.openapi.yaml'
strict_validation: True
validate_responses: True
swagger_ui: True
swagger_json: True
base_path: '/wes-elixir/v1'
general_params:
time_format: "%Y-%m-%dT%H:%M:%SZ"
endpoint_params:
Expand Down
2 changes: 2 additions & 0 deletions wes_elixir/ga4gh/wes/endpoints/get_run_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ def get_run_log(
)
raise Forbidden

# Remove

return run_log
Loading

0 comments on commit 844679d

Please sign in to comment.