Skip to content

Commit 246405e

Browse files
committed
Do mega restructuring of Python source code
1 parent 7653c0c commit 246405e

25 files changed

+872
-690
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ WORKDIR /app
3434

3535
COPY --from=build-server-deps /venv /venv
3636

37-
COPY src/main.py src/main.py
37+
COPY src src
3838
COPY dump_openapi.py .
3939
ENV FASTAPI_OPENAPI_OUTPUT="/tmp/openapi.json"
4040
RUN ["mkdir", "-p", "frontend/dist"]
@@ -68,8 +68,8 @@ ENV S6_KEEP_ENV=1
6868
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2
6969
ENV S6_VERBOSITY=1
7070

71+
COPY src ./src
7172
COPY --from=build-server-deps /venv /venv
72-
COPY src/main.py ./src/main.py
7373
COPY --from=build-frontend /tmp/frontend/dist ./frontend/dist
7474
ENV PATH="/venv/bin:$PATH"
7575

alembic/env.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
from logging.config import fileConfig
33
from os import environ
44

5-
from sqlalchemy import pool
65
from sqlalchemy.engine import Connection
7-
from sqlalchemy.ext.asyncio import async_engine_from_config, create_async_engine
6+
from sqlalchemy.ext.asyncio import create_async_engine
87

98
from alembic import context
109

@@ -19,7 +18,8 @@
1918

2019
# add your model's MetaData object here
2120
# for 'autogenerate' support
22-
from src.main import Base
21+
from src.models import Base # noqa: E402
22+
2323
target_metadata = Base.metadata
2424
# target_metadata = None
2525

@@ -67,8 +67,8 @@ async def run_async_migrations() -> None:
6767
"""
6868

6969
connectable = create_async_engine(
70-
environ.get("DATABASE_URL", "sqlite:///db.sqlite")
71-
)
70+
environ.get("DATABASE_URL", "sqlite:///db.sqlite")
71+
)
7272

7373
async with connectable.connect() as connection:
7474
await connection.run_sync(do_run_migrations)

alembic/versions/930b75030da8_initial_revision.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
branch_labels: Union[str, Sequence[str], None] = None
1818
depends_on: Union[str, Sequence[str], None] = None
1919

20+
2021
def upgrade() -> None:
2122
# ### commands auto generated by Alembic - please adjust! ###
2223
op.create_table(

alembic/versions/f79ac07ca876_fix_pkey_issue.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
def upgrade() -> None:
2020
# ### commands auto generated by Alembic - please adjust! ###
2121
op.drop_constraint("batch_jobs_pkey", "batch_jobs", type_="primary")
22-
op.create_primary_key(
23-
"batch_jobs_pkey", "batch_jobs", ["id"], schema="public"
24-
)
22+
op.create_primary_key("batch_jobs_pkey", "batch_jobs", ["id"], schema="public")
2523
pass
2624
# ### end Alembic commands ###
2725

dump_openapi.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
import json
22
from os import environ
3+
import warnings
34

45
from fastapi.openapi.utils import get_openapi
56

67
from src.main import app
8+
from src.routes import load_routes
9+
10+
load_routes()
711

812
with open(environ.get("FASTAPI_OPENAPI_OUTPUT", "openapi.json"), "w") as f:
9-
json.dump(
10-
get_openapi(
11-
title=app.title,
12-
version=app.version,
13-
openapi_version=app.openapi_version,
14-
description=app.description,
15-
routes=app.routes,
16-
),
17-
f,
18-
)
13+
with warnings.catch_warnings():
14+
warnings.simplefilter("ignore", category=UserWarning)
15+
json.dump(
16+
get_openapi(
17+
title=app.title,
18+
version=app.version,
19+
openapi_version=app.openapi_version,
20+
description=app.description,
21+
routes=app.routes,
22+
),
23+
f,
24+
)

frontend/src/routes/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export default function Home() {
202202

203203
useEffect(() => {
204204
Promise.all([
205-
GET("/current_job")
205+
GET("/job/current")
206206
.catch((error) => {
207207
console.error("Error getting current job", error);
208208
return { data: { job: null } };

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ order-by-type = true
44

55
[tool.ruff.format]
66
docstring-code-format = true
7+
8+
[tool.ruff.lint]
9+
ignore = ["E711"]

src/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)