Skip to content

Commit e8cd454

Browse files
committed
Server update
1 parent 996952c commit e8cd454

File tree

10 files changed

+117
-7
lines changed

10 files changed

+117
-7
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pydicom>=2.0.0
22
boto3>=1.14.53
33
requests==2.26.0
44
requests-toolbelt>=0.9.1
5+
aiohttp>=3.8.1
56
tqdm==4.64.0
67
pillow>=7.2.0
78
matplotlib>=3.3.1
@@ -15,7 +16,6 @@ fire==0.4.0
1516
mixpanel==4.8.3
1617
pydantic>=1.10.2
1718
setuptools>=57.4.0
18-
aiohttp==3.8.1
1919
email-validator>=1.0.3
2020
nest-asyncio==1.5.4
2121
jsonschema==3.2.0

src/superannotate/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
import typing
44

5-
__version__ = "4.4.8"
5+
__version__ = "4.4.9dev1"
66

77
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
88

@@ -29,7 +29,7 @@
2929
SESSIONS = {}
3030

3131

32-
def create_app(apps: typing.List[str]) -> SAServer:
32+
def create_app(apps: typing.List[str] = None) -> SAServer:
3333
setup_app(apps)
3434
server = SAServer()
3535
return server

src/superannotate/lib/app/interface/cli_interface.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,8 @@ def create_server(self, name: str, path: str = None):
270270
default_files_path = Path(sa_lib.__file__).parent / "app" / "server"
271271
shutil.copy(default_files_path / "__app.py", path / "app.py")
272272
shutil.copy(default_files_path / "__wsgi.py", path / "wsgi.py")
273+
shutil.copy(default_files_path / "Dockerfile", path / "Dockerfile")
274+
shutil.copy(default_files_path / "requirements.txt", path / "requirements.txt")
275+
shutil.copy(default_files_path / "README.rst", path / "README.rst")
276+
shutil.copy(default_files_path / "run.sh", path / "run.sh")
277+
shutil.copytree(default_files_path / "deployment", path / "deployment")
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM tiangolo/uwsgi-nginx:python3.8
2+
3+
4+
# Install requirements
5+
COPY requirements.txt /tmp/requirements.txt
6+
RUN pip install --upgrade pip
7+
8+
RUN pip install --no-cache-dir -r /tmp/requirements.txt
9+
10+
# Add the app
11+
COPY . /app
12+
WORKDIR /app
13+
14+
# Make /app/* available to be imported by Python globally to better support several use cases like Alembic migrations.
15+
ENV PYTHONPATH=/app
16+
17+
# Move the base entrypoint to reuse it
18+
RUN mv /entrypoint.sh /uwsgi-nginx-entrypoint.sh
19+
20+
# Copy the entrypoint that will generate Nginx additional configs
21+
COPY deployment/entrypoint.sh /entrypoint.sh
22+
COPY deployment/uwsgi.ini /uwsgi.ini
23+
RUN chmod +x /entrypoint.sh
24+
25+
ENTRYPOINT ["/entrypoint.sh"]
26+
27+
# Run the start script provided by the parent image tiangolo/uwsgi-nginx.
28+
# It will check for an /app/prestart.sh script (e.g. for migrations)
29+
# And then will start Supervisor, which in turn will start Nginx and uWSGI
30+
CMD ["/start.sh"]

src/superannotate/lib/app/server/README.rst

Whitespace-only changes.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#! /usr/bin/env sh
2+
set -e
3+
4+
/uwsgi-nginx-entrypoint.sh
5+
6+
# Get the URL for static files from the environment variable
7+
USE_STATIC_URL=${STATIC_URL:-'/static'}
8+
# Get the absolute path of the static files from the environment variable
9+
USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
10+
# Get the listen port for Nginx, default to 80
11+
USE_LISTEN_PORT=${LISTEN_PORT:-80}
12+
13+
if [ -f /app/nginx.conf ]; then
14+
cp /app/nginx.conf /etc/nginx/nginx.conf
15+
else
16+
content_server='server {\n'
17+
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
18+
content_server=$content_server' location / {\n'
19+
content_server=$content_server' try_files $uri @app;\n'
20+
content_server=$content_server' }\n'
21+
content_server=$content_server' location @app {\n'
22+
content_server=$content_server' include uwsgi_params;\n'
23+
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
24+
content_server=$content_server' }\n'
25+
content_server=$content_server" location $USE_STATIC_URL {\n"
26+
content_server=$content_server" alias $USE_STATIC_PATH;\n"
27+
content_server=$content_server' }\n'
28+
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
29+
if [ "$STATIC_INDEX" = 1 ] ; then
30+
content_server=$content_server' location = / {\n'
31+
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
32+
content_server=$content_server' }\n'
33+
fi
34+
content_server=$content_server'}\n'
35+
# Save generated server /etc/nginx/conf.d/nginx.conf
36+
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
37+
fi
38+
39+
# For Alpine:
40+
# Explicitly add installed Python packages and uWSGI Python packages to PYTHONPATH
41+
# Otherwise uWSGI can't import Flask
42+
if [ -n "$ALPINEPYTHON" ] ; then
43+
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/$ALPINEPYTHON/site-packages:/usr/lib/$ALPINEPYTHON/site-packages
44+
fi
45+
46+
exec "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[uwsgi]
2+
psqi = wsgi
3+
callable = app
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
superannotate
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
########################################################
4+
5+
## Shell Script to Build and Run Docker Image
6+
7+
########################################################
8+
9+
10+
echo "build the docker image"
11+
sudo docker build . -t sa_server
12+
echo "built docker images and proceeding to delete existing container"
13+
result=$(docker ps -q -f name=sa_server)
14+
if [[ $? -eq 0 ]]; then
15+
echo "Container exists"
16+
sudo docker container rm -f sa_server
17+
echo "Deleted the existing docker container"
18+
else
19+
echo "No such container"
20+
fi
21+
echo "Deploying the updated container"
22+
#sudo docker run -d sa_server -p 80:80
23+
sudo docker run sa_server
24+
echo "Deploying the container"

src/superannotate/lib/app/server/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from importlib import import_module
33

44

5-
def setup_app(apps: typing.List[str]):
6-
apps.extend(["superannotate.lib.app.server.default_app"])
7-
for path in apps:
8-
import_module(path)
5+
def setup_app(apps: typing.List[str] = None):
6+
if apps:
7+
apps.extend(["superannotate.lib.app.server.default_app"])
8+
for path in apps:
9+
import_module(path)

0 commit comments

Comments
 (0)