Skip to content

Commit f352d59

Browse files
authored
Rewrite to use FastAPI instead (#13)
* Rewrite to use FastAPI instead Also prepare the ETOS API to become the main API of ETOS. * Added a new test and cleanup grapqhl client New test for testing that the redirection works. A new utilities module for the ETOS endpoint. Wait for artifactCreated instead of just sending a single request Move artifact specific code from the graphql client to utilities. * Fix a time sleep bug
1 parent ce94f76 commit f352d59

34 files changed

+1060
-552
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ RUN python3 setup.py bdist_wheel
66

77
FROM python:3.9.0-slim-buster
88

9+
910
COPY --from=build /src/dist/*.whl /tmp
1011
# hadolint ignore=DL3013
11-
RUN pip install --no-cache-dir /tmp/*.whl
12+
13+
RUN apt-get update && apt-get install -y gcc libc-dev --no-install-recommends && pip install --no-cache-dir /tmp/*.whl && apt-get purge -y --auto-remove gcc libc-dev
1214

1315
RUN groupadd -r etos && useradd -r -s /bin/false -g etos etos
1416
USER etos
@@ -18,5 +20,4 @@ LABEL org.opencontainers.image.source=https://github.com/eiffel-community/etos-a
1820
LABEL org.opencontainers.image.authors=etos-maintainers@googlegroups.com
1921
LABEL org.opencontainers.image.licenses=Apache-2.0
2022

21-
ENV GUNICORN_CMD_ARGS="--name etos_api --bind 0.0.0.0:8080 --worker-class gevent --worker-connections 1000 --workers 5"
22-
ENTRYPOINT ["gunicorn", "etos_api.webserver:FALCON_APP"]
23+
ENTRYPOINT ["uvicorn", "etos_api.main:APP", "--host=0.0.0.0", "--port=8080"]

pylintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[messages control]
2+
disable=
3+
duplicate-code

requirements.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
# numpy==1.13.3
1616
# scipy==1.0
1717
#
18-
falcon==1.4.1
19-
gunicorn==19.9.0
20-
gevent==20.9.0
21-
pyscaffold==3.2.3
22-
eiffellib==1.1.0
23-
requests==2.24.0
2418
etos_lib==1.4.0
19+
pyscaffold==3.2.3
20+
uvicorn==0.12.2
21+
fastapi==0.61.1
22+
aiohttp[speedups]==3.6.2
23+
24+
# These are not compatible with etos library
25+
gql==v3.0.0a3
26+
graphql-core<3.2,>=3.1

setup.cfg

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ package_dir =
2424
# DON'T CHANGE THE FOLLOWING LINE! IT WILL BE UPDATED BY PYSCAFFOLD!
2525
setup_requires = pyscaffold>=3.2a0,<3.3a0
2626
install_requires =
27-
falcon==1.4.1
28-
gunicorn==19.9.0
29-
gevent==20.9.0
30-
pyscaffold==3.2.3
31-
eiffellib==1.1.0
32-
requests==2.24.0
3327
etos_lib==1.4.0
28+
pyscaffold==3.2.3
29+
uvicorn==0.12.2
30+
fastapi==0.61.1
31+
aiohttp[speedups]==3.6.2
32+
gql==v3.0.0a3
33+
graphql-core<3.2,>=3.1
3434

3535
# Require a specific Python version, e.g. Python 2.7 or >= 3.4
3636
python_requires = >=3.4

src/entry.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/bin/bash
22

3-
exec gunicorn etos_api.webserver:FALCON_APP \
4-
--name etos_api \
5-
--worker-class=gevent \
6-
--bind 0.0.0.0:8080 \
7-
--worker-connections=1000 \
8-
--workers=5 \
9-
--reload
3+
exec uvicorn etos_api.main:APP \
4+
--host 0.0.0.0 \
5+
--port 8080

src/entry_debug.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/bin/bash
22

3-
gunicorn etos_api.webserver:FALCON_APP \
4-
--name etos_api \
5-
--worker-class=gevent \
6-
--bind 0.0.0.0:8004 \
7-
--worker-connections=1000 \
8-
--workers=5 \
3+
exec uvicorn etos_api.main:APP \
4+
--host 0.0.0.0 \
5+
--port 8004 \
96
--reload

src/etos_api/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,3 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
"""ETOS API module."""
17-
from pkg_resources import get_distribution, DistributionNotFound
18-
19-
# pylint:disable=invalid-name
20-
21-
try:
22-
# Change here if project is renamed and does not equal the package name
23-
dist_name = __name__
24-
__version__ = get_distribution(dist_name).version
25-
except DistributionNotFound:
26-
__version__ = "unknown"
27-
finally:
28-
del get_distribution, DistributionNotFound

src/etos_api/lib/base_tester.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

src/etos_api/lib/generic_tester.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/etos_api/lib/params.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)