Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit 04f3681

Browse files
authored
Merge pull request #238 from CSCfi/dev
release 1.9.0
2 parents 08ea07b + 462f575 commit 04f3681

35 files changed

+1073
-1083
lines changed

.github/workflows/docs.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313

1414
steps:
15-
- name: Spell check install
16-
run: curl -L https://git.io/misspell | bash
17-
- name: Spell check docs
18-
run: bin/misspell -error docs/*
15+
- uses: actions/checkout@master
16+
- uses: rojopolis/spellcheck-github-actions@0.20.0
17+
name: Spellcheck
1918

2019
code_docs:
2120
strategy:

.github/workflows/s2i-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818

1919
- name: Install requirements
2020
run: |
21-
wget https://github.com/openshift/source-to-image/releases/download/v1.2.0/source-to-image-v1.2.0-2a579ecd-linux-amd64.tar.gz
22-
tar -xvf source-to-image-v1.2.0-2a579ecd-linux-amd64.tar.gz
21+
wget https://github.com/openshift/source-to-image/releases/download/v1.3.1/source-to-image-v1.3.1-a5a77147-linux-amd64.tar.gz
22+
tar -xvf source-to-image-v1.3.1-a5a77147-linux-amd64.tar.gz
2323
sudo cp s2i /usr/local/bin
2424
- name: Build image
2525
run: |
26-
s2i build . centos/python-36-centos7 cscfi/beacon-python
26+
s2i build . centos/python-38-centos7 cscfi/beacon-python

.github/workflows/style.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ jobs:
2626
run: tox -e flake8
2727
- name: Do bandit static check with tox
2828
run: tox -e bandit
29+
- name: Black formatting check
30+
run: tox -e black
2931
- name: Install libcurl-devel
3032
run: |
3133
sudo apt-get update
3234
sudo apt-get install libcurl4-openssl-dev
33-
- name: Do typing check with tox
35+
- name: Type hints check
3436
run: tox -e mypy

.spellcheck.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
matrix:
2+
- name: Markdown
3+
aspell:
4+
lang: en
5+
dictionary:
6+
wordlists:
7+
- .wordlist.txt
8+
encoding: utf-8
9+
pipeline:
10+
- pyspelling.filters.markdown:
11+
- pyspelling.filters.context:
12+
context_visible_first: true
13+
escapes: '\\[\\`~]'
14+
delimiters:
15+
# Ignore text between inline back ticks as this is code or hightlight words
16+
- open: '(?P<open>`+)'
17+
close: '(?P=open)'
18+
# Ignore surrounded in <> as in RST it is link
19+
- open: '<([A-Za-z0-9-_:.]+)|(https?://[^\\s/$.?#].[^\\s]+|[A-Za-z0-9-_:.]+)'
20+
close: '>'
21+
# Ignore code in RST starting with $
22+
- open: '\$.+'
23+
close: ''
24+
sources:
25+
- 'docs/*.rst'
26+
- '**/*.md'
27+
default_encoding: utf-8

.wordlist.txt

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
AAI
2+
accessType
3+
aiohttp
4+
alleleCount
5+
alleleRequest
6+
alternateBases
7+
alternativeUrl
8+
api
9+
APIBehavior
10+
APITest
11+
apiVersion
12+
assemblyId
13+
automodule
14+
autosummary
15+
beacondb
16+
beaconId
17+
beaconpy
18+
BND
19+
BONA
20+
btree
21+
callCount
22+
cd
23+
chr
24+
CHR
25+
claimName
26+
conf
27+
config
28+
contactUrl
29+
containerPort
30+
createdAt
31+
createDateTime
32+
csc
33+
CSC
34+
cscfi
35+
CSCfi
36+
datafile
37+
datafiles
38+
dataloader
39+
dataset
40+
DATASET
41+
datasetAlleleResponses
42+
datasetHandover
43+
datasetId
44+
datasetIds
45+
datasets
46+
dedent
47+
documentationUrl
48+
ebi
49+
ega
50+
EGA
51+
endMax
52+
endMin
53+
env
54+
ENV
55+
Espoo
56+
examplebrowser
57+
exampleid
58+
externalUrl
59+
fi
60+
FIDE
61+
finland
62+
ga
63+
genomic
64+
gh
65+
GH
66+
GHBeacon
67+
github
68+
GRCh
69+
Gunicorn
70+
GunicornUVLoopWebWorker
71+
handoverType
72+
hg
73+
hostPath
74+
html
75+
http
76+
HttpLocust
77+
https
78+
ICT
79+
ietf
80+
imagePullPolicy
81+
includeDatasetResponses
82+
ini
83+
init
84+
io
85+
javascript
86+
jpg
87+
json
88+
JSON
89+
JWK
90+
jwt
91+
JWT
92+
Keilaranta
93+
literalinclude
94+
localhost
95+
logoUrl
96+
matchLabels
97+
mateID
98+
mateName
99+
mateStart
100+
mountPath
101+
namespace
102+
NodePort
103+
OAuth
104+
orgInfo
105+
persistentVolumeClaim
106+
pgtune
107+
postgres
108+
POSTGRES
109+
py
110+
readthedocs
111+
referenceBases
112+
referenceID
113+
referenceName
114+
restartPolicy
115+
rfc
116+
RGB
117+
sampleAlleleRequests
118+
sampleCount
119+
schemas
120+
secretKeyRef
121+
SNP
122+
sql
123+
startMax
124+
startMin
125+
targetPort
126+
TaskSet
127+
TCP
128+
toctree
129+
txt
130+
ua
131+
uk
132+
updatedAt
133+
updateDateTime
134+
uri
135+
url
136+
utils
137+
valueFrom
138+
variantCount
139+
varianttype
140+
variantType
141+
vcf
142+
volumeMounts
143+
welcomeUrl
144+
www

Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
FROM python:3.8-alpine3.13 as BUILD
1+
FROM python:3.8-alpine3.15 as BUILD
22

33
RUN apk add --update \
44
&& apk add --no-cache build-base curl-dev linux-headers bash git musl-dev\
5-
&& apk add --no-cache libressl-dev libffi-dev autoconf bzip2-dev xz-dev\
5+
&& apk add --no-cache openssl-dev libffi-dev autoconf bzip2-dev xz-dev\
66
&& apk add --no-cache python3-dev rust cargo \
77
&& rm -rf /var/cache/apk/*
88

99
COPY requirements.txt /root/beacon/requirements.txt
10-
COPY setup.py /root/beacon/setup.py
11-
COPY beacon_api /root/beacon/beacon_api
1210

1311
ENV CYTHONIZE=1
1412

1513
RUN pip install --upgrade pip && \
16-
pip install -r /root/beacon/requirements.txt && \
17-
pip install /root/beacon
14+
pip install Cython==0.29.26 && \
15+
pip install -r /root/beacon/requirements.txt
16+
17+
COPY setup.py /root/beacon/setup.py
18+
COPY beacon_api /root/beacon/beacon_api
19+
RUN pip install /root/beacon
1820

19-
FROM python:3.8-alpine3.13
21+
FROM python:3.8-alpine3.15
2022

2123
RUN apk add --no-cache --update bash
2224

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Documentation: https://beacon-python.readthedocs.io
1010
### Quick start
1111

1212
`beacon-python` Web Server requires:
13-
* Python 3.6+;
14-
* running DB [PostgreSQL Server](https://www.postgresql.org/) 9.6+ (recommended 11.6).
13+
* Python 3.8+;
14+
* running DB [PostgreSQL Server](https://www.postgresql.org/) 9.6+ (recommended 13).
1515

1616
```shell
1717
git clone https://github.com/CSCfi/beacon-python
@@ -30,7 +30,7 @@ docker run -e POSTGRES_USER=beacon \
3030
-e POSTGRES_PASSWORD=beacon \
3131
-v "$PWD/data":/docker-entrypoint-initdb.d \
3232
-e POSTGRES_DB=beacondb \
33-
-p 5432:5432 postgres:11.6
33+
-p 5432:5432 postgres:13
3434
```
3535

3636
#### Run beacon-python

beacon_api/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
__url__ = CONFIG_INFO.url
2525
__alturl__ = CONFIG_INFO.alturl
2626
__createtime__ = CONFIG_INFO.createtime
27-
__updatetime__ = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ') # Every restart of the application means an update to it
27+
__updatetime__ = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ") # Every restart of the application means an update to it
2828

2929
__org_id__ = CONFIG_INFO.org_id
3030
__org_name__ = CONFIG_INFO.org_name
@@ -33,12 +33,10 @@
3333
__org_welcomeUrl__ = CONFIG_INFO.org_welcomeUrl
3434
__org_contactUrl__ = CONFIG_INFO.org_contactUrl
3535
__org_logoUrl__ = CONFIG_INFO.org_logoUrl
36-
__org_info__ = {'orgInfo': CONFIG_INFO.org_info}
36+
__org_info__ = {"orgInfo": CONFIG_INFO.org_info}
3737

3838
__sample_queries__ = SAMPLE_QUERIES
3939

4040
# GA4GH Discovery
41-
__service_type__ = {'group': f'{CONFIG_INFO.service_group}',
42-
'artifact': f'{CONFIG_INFO.service_artifact}',
43-
'version': f'{__apiVersion__}'}
41+
__service_type__ = {"group": f"{CONFIG_INFO.service_group}", "artifact": f"{CONFIG_INFO.service_artifact}", "version": f"{__apiVersion__}"}
4442
__service_env__ = CONFIG_INFO.environment

beacon_api/api/exceptions.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
API specification requires custom messages upon error.
44
"""
55

6-
import json
6+
import ujson
77
from typing import Dict
88
from aiohttp import web
99
from .. import __apiVersion__
@@ -35,7 +35,17 @@ def process_exception_data(request: Dict, host: str, error_code: int, error: str
3535
# include datasetIds only if they are specified
3636
# as per specification if they don't exist all datatsets will be queried
3737
# Only one of `alternateBases` or `variantType` is required, validated by schema
38-
oneof_fields = ["alternateBases", "variantType", "start", "end", "startMin", "startMax", "endMin", "endMax", "datasetIds"]
38+
oneof_fields = [
39+
"alternateBases",
40+
"variantType",
41+
"start",
42+
"end",
43+
"startMin",
44+
"startMax",
45+
"endMin",
46+
"endMax",
47+
"datasetIds",
48+
]
3949
data["alleleRequest"].update({k: request.get(k) for k in oneof_fields if k in request})
4050

4151
return data
@@ -51,7 +61,7 @@ class BeaconBadRequest(web.HTTPBadRequest):
5161
def __init__(self, request: Dict, host: str, error: str) -> None:
5262
"""Return custom bad request exception."""
5363
data = process_exception_data(request, host, 400, error)
54-
super().__init__(text=json.dumps(data), content_type="application/json")
64+
super().__init__(text=ujson.dumps(data, escape_forward_slashes=False), content_type="application/json")
5565
LOG.error(f"401 ERROR MESSAGE: {error}")
5666

5767

@@ -65,14 +75,10 @@ class BeaconUnauthorised(web.HTTPUnauthorized):
6575
def __init__(self, request: Dict, host: str, error: str, error_message: str) -> None:
6676
"""Return custom unauthorized exception."""
6777
data = process_exception_data(request, host, 401, error)
68-
headers_401 = {
69-
"WWW-Authenticate": f'Bearer realm="{CONFIG_INFO.url}"\n\
70-
error="{error}"\n\
71-
error_description="{error_message}"'
72-
}
78+
headers_401 = {"WWW-Authenticate": f"""Bearer realm=\"{CONFIG_INFO.url}\",error=\"{error},\" error_description=\"{error_message}\""""}
7379
super().__init__(
7480
content_type="application/json",
75-
text=json.dumps(data),
81+
text=ujson.dumps(data, escape_forward_slashes=False),
7682
# we use auth scheme Bearer by default
7783
headers=headers_401,
7884
)
@@ -90,7 +96,7 @@ class BeaconForbidden(web.HTTPForbidden):
9096
def __init__(self, request: Dict, host: str, error: str) -> None:
9197
"""Return custom forbidden exception."""
9298
data = process_exception_data(request, host, 403, error)
93-
super().__init__(content_type="application/json", text=json.dumps(data))
99+
super().__init__(content_type="application/json", text=ujson.dumps(data, escape_forward_slashes=False))
94100
LOG.error(f"403 ERROR MESSAGE: {error}")
95101

96102

@@ -103,5 +109,5 @@ class BeaconServerError(web.HTTPInternalServerError):
103109
def __init__(self, error: str) -> None:
104110
"""Return custom forbidden exception."""
105111
data = {"errorCode": 500, "errorMessage": error}
106-
super().__init__(content_type="application/json", text=json.dumps(data))
112+
super().__init__(content_type="application/json", text=ujson.dumps(data, escape_forward_slashes=False))
107113
LOG.error(f"500 ERROR MESSAGE: {error}")

0 commit comments

Comments
 (0)