Skip to content

Commit 50bf922

Browse files
committed
Upgrades
1 parent 52f0944 commit 50bf922

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11
1+
FROM python:3.12
22

33
COPY ./bridge-style /tmp/bridge-style
44
COPY requirements.txt /tmp/
55
RUN pip install /tmp/bridge-style && \
66
pip install --disable-pip-version-check --no-cache-dir --requirement=/tmp/requirements.txt && \
77
rm --recursive --force /tmp/*
88
COPY ./app /app
9+
10+
WORKDIR /app
11+
12+
CMD ["fastapi", "run", "main.py", "--port", "80"]

app/main.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import os
22
import io
33
import zipfile
4-
from typing import List, Optional
5-
6-
from typing import List, Optional
74

85
import traceback
96
import yaml
@@ -27,25 +24,26 @@ class Lyrx(BaseModel):
2724
type: str
2825
version: str
2926
build: int
30-
layers: Optional[List[str]]
31-
layerDefinitions: List[dict]
32-
binaryReferences: Optional[List[dict]]
33-
elevationSurfaces: Optional[List[dict]]
34-
rGBColorProfile: Optional[str]
35-
cMYKColorProfile: Optional[str]
27+
layers: list[str] | None = None
28+
layerDefinitions: list[dict]
29+
binaryReferences: list[dict] | None = None
30+
elevationSurfaces: list[dict] | None = None
31+
rGBColorProfile: str | None = None
32+
cMYKColorProfile: str | None
3633

3734

3835
app = FastAPI()
3936

4037
LOG = logging.getLogger("app")
41-
with open('config.yaml') as f:
38+
with open("config.yaml") as f:
4239
config = yaml.load(f, Loader=yaml.FullLoader)
4340
logging.config.dictConfig(config)
4441

42+
4543
@app.post("/v1/lyrx2sld/")
4644
async def lyrx_to_sld(lyrx: Lyrx, replaceesri: bool = False):
4745

48-
options = {'tolowercase': True, 'replaceesri': replaceesri}
46+
options = {"tolowercase": True, "replaceesri": replaceesri}
4947
warnings = []
5048

5149
try:
@@ -69,20 +67,14 @@ async def lyrx_to_sld(lyrx: Lyrx, replaceesri: bool = False):
6967
return Response(
7068
content=s.getvalue(),
7169
media_type="application/x-zip-compressed",
72-
headers={
73-
'Content-Disposition': 'attachment;filename=style.zip'
74-
}
75-
)
70+
headers={"Content-Disposition": "attachment;filename=style.zip"},
71+
)
7672

7773
except Exception as e:
7874
errors = traceback.format_exception(None, e, e.__traceback__)
7975
for error in errors:
8076
LOG.error(error)
8177
return JSONResponse(
8278
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
83-
content=jsonable_encoder(
84-
{
85-
'warnings': warnings,
86-
'errors': errors
87-
})
88-
)
79+
content=jsonable_encoder({"warnings": warnings, "errors": errors}),
80+
)

app/start-reload2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ else
2828
fi
2929

3030
# Start Uvicorn with live reload
31-
exec uvicorn --reload --reload-dir /usr/local/lib/python3.7/site-packages/bridgestyle --reload-dir /app --host $HOST --port $PORT --log-level $LOG_LEVEL "$APP_MODULE"
31+
exec uvicorn --reload --reload-dir /usr/local/lib/python3.12/site-packages/bridgestyle --reload-dir /app --host $HOST --port $PORT --log-level $LOG_LEVEL "$APP_MODULE"

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ services:
2222
ports:
2323
- 80:80
2424
volumes:
25-
- ./bridge-style/bridgestyle:/usr/local/lib/python3.7/site-packages/bridgestyle # For debug purpose
25+
- ./bridge-style/bridgestyle:/usr/local/lib/python3.12/site-packages/bridgestyle # For debug purpose
2626
- ./app:/app # For debug purpose

requirements.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
requests
2-
PyYAML
1+
fastapi[standard]==0.115.0
2+
pydantic==2.9.2
3+
PyYAML==6.0.2
4+
requests==2.32.3
35
# For debugging
4-
pydevd_pycharm~=213.7172.25
6+
# pydevd_pycharm~=213.7172.25

0 commit comments

Comments
 (0)