🎨 Reorganize back-end code
This commit is contained in:
@@ -9,7 +9,7 @@ ENV POETRY_NO_INTERACTION=1 \
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY ./pyproject.toml /app
|
COPY pyproject.toml /app
|
||||||
|
|
||||||
RUN poetry install --only=main --no-root && \
|
RUN poetry install --only=main --no-root && \
|
||||||
rm -rf ${POETRY_CACHE_DIR}
|
rm -rf ${POETRY_CACHE_DIR}
|
||||||
@@ -29,10 +29,6 @@ env VIRTUAL_ENV=/app/.venv \
|
|||||||
|
|
||||||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
||||||
|
|
||||||
COPY backend /app/backend
|
COPY api /app/api
|
||||||
COPY dependencies.py /app
|
|
||||||
COPY config.sample.yaml /app
|
|
||||||
COPY routers/ /app/routers
|
|
||||||
COPY main.py /app
|
|
||||||
|
|
||||||
CMD ["python", "./main.py"]
|
CMD ["python", "./api/main.py"]
|
||||||
|
@@ -34,10 +34,7 @@ env VIRTUAL_ENV=/app/.venv \
|
|||||||
|
|
||||||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
|
||||||
|
|
||||||
COPY backend /app/backend
|
COPY api /app/api
|
||||||
COPY dependencies.py /app
|
|
||||||
COPY config.sample.yaml /app
|
|
||||||
COPY config.local.yaml /app
|
|
||||||
COPY db_updater /app/db_updater
|
COPY db_updater /app/db_updater
|
||||||
|
|
||||||
CMD ["python", "-m", "db_updater.fill_db"]
|
CMD ["python", "-m", "db_updater.fill_db"]
|
||||||
|
@@ -14,7 +14,7 @@ from sqlalchemy.ext.asyncio import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from .base_class import Base
|
from .base_class import Base
|
||||||
from ..settings import DatabaseSettings
|
from settings import DatabaseSettings
|
||||||
|
|
||||||
logger = getLogger(__name__)
|
logger = getLogger(__name__)
|
||||||
|
|
@@ -4,9 +4,9 @@ from fastapi_cache.backends.redis import RedisBackend
|
|||||||
from redis import asyncio as aioredis
|
from redis import asyncio as aioredis
|
||||||
from yaml import safe_load
|
from yaml import safe_load
|
||||||
|
|
||||||
from backend.db import db
|
from db import db
|
||||||
from backend.idfm_interface.idfm_interface import IdfmInterface
|
from idfm_interface.idfm_interface import IdfmInterface
|
||||||
from backend.settings import CacheSettings, Settings
|
from settings import CacheSettings, Settings
|
||||||
|
|
||||||
|
|
||||||
CONFIG_PATH = environ.get("CONFIG_PATH", "./config.sample.yaml")
|
CONFIG_PATH = environ.get("CONFIG_PATH", "./config.sample.yaml")
|
@@ -7,9 +7,9 @@ from aiohttp import ClientSession
|
|||||||
from msgspec import ValidationError
|
from msgspec import ValidationError
|
||||||
from msgspec.json import Decoder
|
from msgspec.json import Decoder
|
||||||
|
|
||||||
from ..db import Database
|
|
||||||
from ..models import Line, Stop, StopArea
|
|
||||||
from .idfm_types import Destinations as IdfmDestinations, IdfmResponse, IdfmState
|
from .idfm_types import Destinations as IdfmDestinations, IdfmResponse, IdfmState
|
||||||
|
from db import Database
|
||||||
|
from models import Line, Stop, StopArea
|
||||||
|
|
||||||
|
|
||||||
class IdfmInterface:
|
class IdfmInterface:
|
@@ -12,7 +12,7 @@ from opentelemetry.sdk.resources import Resource, SERVICE_NAME
|
|||||||
from opentelemetry.sdk.trace import TracerProvider
|
from opentelemetry.sdk.trace import TracerProvider
|
||||||
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
||||||
|
|
||||||
from backend.db import db
|
from db import db
|
||||||
from dependencies import idfm_interface, redis_backend, settings
|
from dependencies import idfm_interface, redis_backend, settings
|
||||||
from routers import line, stop
|
from routers import line, stop
|
||||||
|
|
@@ -14,8 +14,8 @@ from sqlalchemy import (
|
|||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship, selectinload
|
from sqlalchemy.orm import Mapped, mapped_column, relationship, selectinload
|
||||||
from sqlalchemy.sql.expression import tuple_
|
from sqlalchemy.sql.expression import tuple_
|
||||||
|
|
||||||
from ..db import Base, db
|
from db import Base, db
|
||||||
from ..idfm_interface.idfm_types import (
|
from idfm_interface.idfm_types import (
|
||||||
IdfmState,
|
IdfmState,
|
||||||
IdfmLineState,
|
IdfmLineState,
|
||||||
TransportMode,
|
TransportMode,
|
@@ -26,8 +26,8 @@ from sqlalchemy.orm import (
|
|||||||
from sqlalchemy.schema import Index
|
from sqlalchemy.schema import Index
|
||||||
from sqlalchemy_utils.types.ts_vector import TSVectorType
|
from sqlalchemy_utils.types.ts_vector import TSVectorType
|
||||||
|
|
||||||
from ..db import Base, db
|
from db import Base, db
|
||||||
from ..idfm_interface.idfm_types import TransportMode, IdfmState, StopAreaType
|
from idfm_interface.idfm_types import TransportMode, IdfmState, StopAreaType
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .line import Line
|
from .line import Line
|
@@ -1,7 +1,7 @@
|
|||||||
from sqlalchemy import BigInteger, ForeignKey, String
|
from sqlalchemy import BigInteger, ForeignKey, String
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from ..db import Base, db
|
from db import Base, db
|
||||||
from .stop import _Stop
|
from .stop import _Stop
|
||||||
|
|
||||||
|
|
@@ -1,8 +1,8 @@
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
from fastapi_cache.decorator import cache
|
from fastapi_cache.decorator import cache
|
||||||
|
|
||||||
from backend.models import Line
|
from models import Line
|
||||||
from backend.schemas import Line as LineSchema, TransportMode
|
from schemas import Line as LineSchema, TransportMode
|
||||||
|
|
||||||
|
|
||||||
router = APIRouter(prefix="/line", tags=["line"])
|
router = APIRouter(prefix="/line", tags=["line"])
|
@@ -5,9 +5,9 @@ from typing import Sequence
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
from fastapi_cache.decorator import cache
|
from fastapi_cache.decorator import cache
|
||||||
|
|
||||||
from backend.idfm_interface import Destinations as IdfmDestinations, TrainStatus
|
from idfm_interface import Destinations as IdfmDestinations, TrainStatus
|
||||||
from backend.models import Stop, StopArea, StopShape
|
from models import Stop, StopArea, StopShape
|
||||||
from backend.schemas import (
|
from schemas import (
|
||||||
NextPassage as NextPassageSchema,
|
NextPassage as NextPassageSchema,
|
||||||
NextPassages as NextPassagesSchema,
|
NextPassages as NextPassagesSchema,
|
||||||
Stop as StopSchema,
|
Stop as StopSchema,
|
@@ -2,7 +2,7 @@ from enum import StrEnum
|
|||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from ..idfm_interface import (
|
from idfm_interface import (
|
||||||
IdfmLineState,
|
IdfmLineState,
|
||||||
IdfmState,
|
IdfmState,
|
||||||
TransportMode as IdfmTransportMode,
|
TransportMode as IdfmTransportMode,
|
@@ -1,6 +1,6 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from ..idfm_interface.idfm_types import TrainStatus
|
from idfm_interface.idfm_types import TrainStatus
|
||||||
|
|
||||||
|
|
||||||
class NextPassage(BaseModel):
|
class NextPassage(BaseModel):
|
@@ -1,6 +1,6 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from ..idfm_interface import StopAreaType
|
from idfm_interface import StopAreaType
|
||||||
|
|
||||||
|
|
||||||
class Stop(BaseModel):
|
class Stop(BaseModel):
|
@@ -16,9 +16,9 @@ from shapefile import Reader as ShapeFileReader, ShapeRecord # type: ignore
|
|||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
from yaml import safe_load
|
from yaml import safe_load
|
||||||
|
|
||||||
from backend.db import Base, db, Database
|
from api.db import Base, db, Database
|
||||||
from backend.models import ConnectionArea, Line, LinePicto, Stop, StopArea, StopShape
|
from api.models import ConnectionArea, Line, LinePicto, Stop, StopArea, StopShape
|
||||||
from backend.idfm_interface.idfm_types import (
|
from api.idfm_interface.idfm_types import (
|
||||||
ConnectionArea as IdfmConnectionArea,
|
ConnectionArea as IdfmConnectionArea,
|
||||||
IdfmLineState,
|
IdfmLineState,
|
||||||
Line as IdfmLine,
|
Line as IdfmLine,
|
||||||
@@ -31,8 +31,8 @@ from backend.idfm_interface.idfm_types import (
|
|||||||
StopLineAsso as IdfmStopLineAsso,
|
StopLineAsso as IdfmStopLineAsso,
|
||||||
TransportMode,
|
TransportMode,
|
||||||
)
|
)
|
||||||
from backend.idfm_interface.ratp_types import Picto as RatpPicto
|
from api.idfm_interface.ratp_types import Picto as RatpPicto
|
||||||
from backend.settings import Settings
|
from api.settings import Settings
|
||||||
|
|
||||||
|
|
||||||
CONFIG_PATH = environ.get("CONFIG_PATH", "./config.sample.yaml")
|
CONFIG_PATH = environ.get("CONFIG_PATH", "./config.sample.yaml")
|
||||||
|
Reference in New Issue
Block a user