From bfc669cd116dc38cdea37edb597c96a864b57db1 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sat, 9 Sep 2023 23:34:04 +0200 Subject: [PATCH 1/8] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20pydantic-setting?= =?UTF-8?q?s=20to=20handle=20config=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/backend/settings.py | 75 ++++++++++++++++++++++--------------- backend/pyproject.toml | 8 +++- 2 files changed, 51 insertions(+), 32 deletions(-) diff --git a/backend/backend/settings.py b/backend/backend/settings.py index ff6bf84..ab2b75b 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -1,6 +1,14 @@ -from typing import Any +from __future__ import annotations -from pydantic import BaseModel, BaseSettings, Field, root_validator, SecretStr +from typing import Annotated + +from pydantic import BaseModel, SecretStr +from pydantic.functional_validators import model_validator +from pydantic_settings import ( + BaseSettings, + PydanticBaseSettingsSource, + SettingsConfigDict, +) class HttpSettings(BaseModel): @@ -9,28 +17,13 @@ class HttpSettings(BaseModel): cert: str | None = None -def check_user_password(cls, values: dict[str, Any]) -> dict[str, Any]: - user = values.get("user") - password = values.get("password") - - if user is not None and password is None: - raise ValueError("user is set, password shall be set too.") - - if password is not None and user is None: - raise ValueError("password is set, user shall be set too.") - - return values - - class DatabaseSettings(BaseModel): - name: str = "carrramba-encore-rate" - host: str = "127.0.0.1" - port: int = 5432 + name: str + host: str + port: int driver: str = "postgresql+psycopg" - user: str | None = None - password: SecretStr | None = None - - _user_password_validation = root_validator(allow_reuse=True)(check_user_password) + user: str + password: Annotated[SecretStr, check_user_password] class CacheSettings(BaseModel): @@ -38,9 +31,18 @@ class CacheSettings(BaseModel): host: str = "127.0.0.1" port: int = 6379 user: str | None = None - password: SecretStr | None = None + password: Annotated[SecretStr | None, check_user_password] = None - _user_password_validation = root_validator(allow_reuse=True)(check_user_password) + +@model_validator(mode="after") +def check_user_password(self) -> DatabaseSettings | CacheSettings: + if self.user is not None and self.password is None: + raise ValueError("user is set, password shall be set too.") + + if self.password is not None and self.user is None: + raise ValueError("password is set, user shall be set too.") + + return self class TracingSettings(BaseModel): @@ -50,10 +52,23 @@ class TracingSettings(BaseModel): class Settings(BaseSettings): app_name: str - idfm_api_key: SecretStr = Field(..., env="IDFM_API_KEY") - clear_static_data: bool = Field(False, env="CLEAR_STATIC_DATA") + idfm_api_key: SecretStr + clear_static_data: bool - http: HttpSettings = HttpSettings() - db: DatabaseSettings = DatabaseSettings() - cache: CacheSettings = CacheSettings() - tracing: TracingSettings = TracingSettings() + http: HttpSettings + db: DatabaseSettings + cache: CacheSettings + tracing: TracingSettings + + model_config = SettingsConfigDict(env_prefix="CER__", env_nested_delimiter="__") + + @classmethod + def settings_customise_sources( + cls, + settings_cls: type[BaseSettings], + init_settings: PydanticBaseSettingsSource, + env_settings: PydanticBaseSettingsSource, + dotenv_settings: PydanticBaseSettingsSource, + file_secret_settings: PydanticBaseSettingsSource, + ) -> tuple[PydanticBaseSettingsSource, ...]: + return env_settings, init_settings, file_secret_settings diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 8af85e7..0156387 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" python = "^3.11" aiohttp = "^3.8.3" aiofiles = "^22.1.0" -fastapi = "^0.95.0" +fastapi = "^0.103.0" uvicorn = "^0.20.0" msgspec = "^0.12.0" opentelemetry-instrumentation-fastapi = "^0.38b0" @@ -23,11 +23,12 @@ sqlalchemy = "^2.0.12" psycopg = "^3.1.9" pyyaml = "^6.0" fastapi-cache2 = {extras = ["redis"], version = "^0.2.1"} +pydantic-settings = "^2.0.3" [tool.poetry.group.db_updater.dependencies] aiofiles = "^22.1.0" aiohttp = "^3.8.3" -fastapi = "^0.95.0" +fastapi = "^0.103.0" msgspec = "^0.12.0" opentelemetry-instrumentation-fastapi = "^0.38b0" opentelemetry-instrumentation-sqlalchemy = "^0.38b0" @@ -41,11 +42,14 @@ pyyaml = "^6.0" sqlalchemy = "^2.0.12" sqlalchemy-utils = "^0.41.1" tqdm = "^4.65.0" +pydantic-settings = "^2.0.3" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" + + [tool.poetry.group.dev.dependencies] pylsp-mypy = "^0.6.2" mccabe = "^0.7.0" From 4fce832db594d069fa7dc61275d028ab8861f6b2 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 10 Sep 2023 11:45:08 +0200 Subject: [PATCH 2/8] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Rename=20docker=20file?= =?UTF-8?q?=20building=20api=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/{Dockerfile.backend => Dockerfile.api} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename backend/{Dockerfile.backend => Dockerfile.api} (100%) diff --git a/backend/Dockerfile.backend b/backend/Dockerfile.api similarity index 100% rename from backend/Dockerfile.backend rename to backend/Dockerfile.api From 8c493f8fabe20436b0a95c7ebfcf82bb1a525a25 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 10 Sep 2023 11:46:24 +0200 Subject: [PATCH 3/8] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Remove=20pg=5Ftrgm=20c?= =?UTF-8?q?reation=20from=20the=20db=20session=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pg_trgm extension will be created during db init, by the db-updated image. --- backend/backend/db/db.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/backend/db/db.py b/backend/backend/db/db.py index 28dbd18..0dac1b1 100644 --- a/backend/backend/db/db.py +++ b/backend/backend/db/db.py @@ -61,9 +61,6 @@ class Database: while not ret: try: async with self._async_engine.begin() as session: - await session.execute( - text("CREATE EXTENSION IF NOT EXISTS pg_trgm;") - ) if clear_static_data: await session.run_sync(Base.metadata.drop_all) await session.run_sync(Base.metadata.create_all) From f69aee1c9c8d54986f08f3db6440107dd99f5dc8 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 10 Sep 2023 12:04:25 +0200 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Remove=20driver=20a?= =?UTF-8?q?nd=20password=20from=20configuration=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Password will be provided by vault using an env variable. --- backend/config.sample.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/config.sample.yaml b/backend/config.sample.yaml index 018eca1..5362cf3 100644 --- a/backend/config.sample.yaml +++ b/backend/config.sample.yaml @@ -10,9 +10,7 @@ db: name: carrramba-encore-rate host: postgres port: 5432 - driver: postgresql+psycopg user: cer - password: cer_password cache: enable: true From cf5c4c62244ea4738236ee3a2762fa7a19f6805c Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 10 Sep 2023 12:07:20 +0200 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Fix=20CORS=20allowe?= =?UTF-8?q?d=20origins=20and=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/main.py b/backend/main.py index 93a4205..1eae69a 100755 --- a/backend/main.py +++ b/backend/main.py @@ -34,13 +34,12 @@ app = FastAPI(lifespan=lifespan) app.add_middleware( CORSMiddleware, - allow_origins=["https://localhost:4443", "https://localhost:3000"], + allow_origins=["http://carrramba.adrien.run", "https://carrramba.adrien.run"], allow_credentials=True, - allow_methods=["*"], + allow_methods=["OPTIONS", "GET"], allow_headers=["*"], ) - # The cache-control header entry is not managed properly by fastapi-cache: # For now, a request with a cache-control set to no-cache # is interpreted as disabling the use of the server cache. From 4cc8f60076376cfdf8d69d3c2ecf40295e8d986e Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 10 Sep 2023 12:17:48 +0200 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=90=9B=20Front:=20Use=20the=20public?= =?UTF-8?q?=20API=20server=20to=20fetch=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/businessData.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/businessData.tsx b/frontend/src/businessData.tsx index 89c73d3..d33df0a 100644 --- a/frontend/src/businessData.tsx +++ b/frontend/src/businessData.tsx @@ -28,8 +28,7 @@ export interface BusinessDataStore { export const BusinessDataContext = createContext(); export function BusinessDataProvider(props: { children: JSX.Element }) { - - const [serverUrl] = createSignal("https://localhost:4443"); + const [serverUrl] = createSignal("https://carrramba.adrien.run/api"); type Store = { lines: Lines; From bdbc72ab39446a2cc08550bb33704a05acba5dc3 Mon Sep 17 00:00:00 2001 From: Adrien Date: Sun, 10 Sep 2023 12:25:38 +0200 Subject: [PATCH 7/8] =?UTF-8?q?=F0=9F=90=9B=20Front:=20Fix=20URL=20used=20?= =?UTF-8?q?to=20fetch=20transport=20mode=20representation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/utils.tsx b/frontend/src/utils.tsx index 8771c73..2828ac7 100644 --- a/frontend/src/utils.tsx +++ b/frontend/src/utils.tsx @@ -26,7 +26,7 @@ export const TransportModeWeights: Record = { export function getTransportModeSrc(mode: string, color: boolean = true): string | undefined { let ret = undefined; if (validTransportModes.includes(mode)) { - return `/carrramba-encore-rate/public/symbole_${mode}_${color ? "" : "support_fonce_"}RVB.svg`; + return `/symbole_${mode}_${color ? "" : "support_fonce_"}RVB.svg`; } return ret; } From 3434802b31ed138bc428f7cc4f51955839c59750 Mon Sep 17 00:00:00 2001 From: Adrien Date: Wed, 20 Sep 2023 22:08:32 +0200 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=8E=A8=20Reorganize=20back-end=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile.api | 10 +++------- backend/Dockerfile.db_updater | 5 +---- backend/{backend => api}/__init__.py | 0 backend/{ => api}/config.local.yaml | 0 backend/{ => api}/config.sample.yaml | 0 backend/{backend => api}/db/__init__.py | 0 backend/{backend => api}/db/base_class.py | 0 backend/{backend => api}/db/db.py | 2 +- backend/{ => api}/dependencies.py | 6 +++--- backend/{backend => api}/idfm_interface/__init__.py | 0 .../{backend => api}/idfm_interface/idfm_interface.py | 4 ++-- backend/{backend => api}/idfm_interface/idfm_types.py | 0 backend/{backend => api}/idfm_interface/ratp_types.py | 0 backend/{ => api}/main.py | 2 +- backend/{backend => api}/models/__init__.py | 0 backend/{backend => api}/models/line.py | 4 ++-- backend/{backend => api}/models/stop.py | 4 ++-- backend/{backend => api}/models/user.py | 2 +- backend/{backend => api}/py.typed | 0 backend/{ => api}/routers/__init__.py | 0 backend/{ => api}/routers/line.py | 4 ++-- backend/{ => api}/routers/stop.py | 6 +++--- backend/{backend => api}/schemas/__init__.py | 0 backend/{backend => api}/schemas/line.py | 2 +- backend/{backend => api}/schemas/next_passage.py | 2 +- backend/{backend => api}/schemas/stop.py | 2 +- backend/{backend => api}/settings.py | 0 backend/db_updater/fill_db.py | 10 +++++----- 28 files changed, 29 insertions(+), 36 deletions(-) rename backend/{backend => api}/__init__.py (100%) rename backend/{ => api}/config.local.yaml (100%) rename backend/{ => api}/config.sample.yaml (100%) rename backend/{backend => api}/db/__init__.py (100%) rename backend/{backend => api}/db/base_class.py (100%) rename backend/{backend => api}/db/db.py (98%) rename backend/{ => api}/dependencies.py (86%) rename backend/{backend => api}/idfm_interface/__init__.py (100%) rename backend/{backend => api}/idfm_interface/idfm_interface.py (98%) rename backend/{backend => api}/idfm_interface/idfm_types.py (100%) rename backend/{backend => api}/idfm_interface/ratp_types.py (100%) rename backend/{ => api}/main.py (99%) rename backend/{backend => api}/models/__init__.py (100%) rename backend/{backend => api}/models/line.py (98%) rename backend/{backend => api}/models/stop.py (98%) rename backend/{backend => api}/models/user.py (96%) rename backend/{backend => api}/py.typed (100%) rename backend/{ => api}/routers/__init__.py (100%) rename backend/{ => api}/routers/line.py (91%) rename backend/{ => api}/routers/stop.py (97%) rename backend/{backend => api}/schemas/__init__.py (100%) rename backend/{backend => api}/schemas/line.py (98%) rename backend/{backend => api}/schemas/next_passage.py (89%) rename backend/{backend => api}/schemas/stop.py (92%) rename backend/{backend => api}/settings.py (100%) diff --git a/backend/Dockerfile.api b/backend/Dockerfile.api index 1f870b8..3ec23d4 100644 --- a/backend/Dockerfile.api +++ b/backend/Dockerfile.api @@ -9,7 +9,7 @@ ENV POETRY_NO_INTERACTION=1 \ WORKDIR /app -COPY ./pyproject.toml /app +COPY pyproject.toml /app RUN poetry install --only=main --no-root && \ rm -rf ${POETRY_CACHE_DIR} @@ -29,10 +29,6 @@ env VIRTUAL_ENV=/app/.venv \ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} -COPY backend /app/backend -COPY dependencies.py /app -COPY config.sample.yaml /app -COPY routers/ /app/routers -COPY main.py /app +COPY api /app/api -CMD ["python", "./main.py"] +CMD ["python", "./api/main.py"] diff --git a/backend/Dockerfile.db_updater b/backend/Dockerfile.db_updater index d5b2d09..3dcfbf1 100644 --- a/backend/Dockerfile.db_updater +++ b/backend/Dockerfile.db_updater @@ -34,10 +34,7 @@ env VIRTUAL_ENV=/app/.venv \ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} -COPY backend /app/backend -COPY dependencies.py /app -COPY config.sample.yaml /app -COPY config.local.yaml /app +COPY api /app/api COPY db_updater /app/db_updater CMD ["python", "-m", "db_updater.fill_db"] diff --git a/backend/backend/__init__.py b/backend/api/__init__.py similarity index 100% rename from backend/backend/__init__.py rename to backend/api/__init__.py diff --git a/backend/config.local.yaml b/backend/api/config.local.yaml similarity index 100% rename from backend/config.local.yaml rename to backend/api/config.local.yaml diff --git a/backend/config.sample.yaml b/backend/api/config.sample.yaml similarity index 100% rename from backend/config.sample.yaml rename to backend/api/config.sample.yaml diff --git a/backend/backend/db/__init__.py b/backend/api/db/__init__.py similarity index 100% rename from backend/backend/db/__init__.py rename to backend/api/db/__init__.py diff --git a/backend/backend/db/base_class.py b/backend/api/db/base_class.py similarity index 100% rename from backend/backend/db/base_class.py rename to backend/api/db/base_class.py diff --git a/backend/backend/db/db.py b/backend/api/db/db.py similarity index 98% rename from backend/backend/db/db.py rename to backend/api/db/db.py index 0dac1b1..bd4f840 100644 --- a/backend/backend/db/db.py +++ b/backend/api/db/db.py @@ -14,7 +14,7 @@ from sqlalchemy.ext.asyncio import ( ) from .base_class import Base -from ..settings import DatabaseSettings +from settings import DatabaseSettings logger = getLogger(__name__) diff --git a/backend/dependencies.py b/backend/api/dependencies.py similarity index 86% rename from backend/dependencies.py rename to backend/api/dependencies.py index 272a0c8..ecf6c11 100644 --- a/backend/dependencies.py +++ b/backend/api/dependencies.py @@ -4,9 +4,9 @@ from fastapi_cache.backends.redis import RedisBackend from redis import asyncio as aioredis from yaml import safe_load -from backend.db import db -from backend.idfm_interface.idfm_interface import IdfmInterface -from backend.settings import CacheSettings, Settings +from db import db +from idfm_interface.idfm_interface import IdfmInterface +from settings import CacheSettings, Settings CONFIG_PATH = environ.get("CONFIG_PATH", "./config.sample.yaml") diff --git a/backend/backend/idfm_interface/__init__.py b/backend/api/idfm_interface/__init__.py similarity index 100% rename from backend/backend/idfm_interface/__init__.py rename to backend/api/idfm_interface/__init__.py diff --git a/backend/backend/idfm_interface/idfm_interface.py b/backend/api/idfm_interface/idfm_interface.py similarity index 98% rename from backend/backend/idfm_interface/idfm_interface.py rename to backend/api/idfm_interface/idfm_interface.py index 7bcc734..23de96b 100644 --- a/backend/backend/idfm_interface/idfm_interface.py +++ b/backend/api/idfm_interface/idfm_interface.py @@ -7,9 +7,9 @@ from aiohttp import ClientSession from msgspec import ValidationError 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 db import Database +from models import Line, Stop, StopArea class IdfmInterface: diff --git a/backend/backend/idfm_interface/idfm_types.py b/backend/api/idfm_interface/idfm_types.py similarity index 100% rename from backend/backend/idfm_interface/idfm_types.py rename to backend/api/idfm_interface/idfm_types.py diff --git a/backend/backend/idfm_interface/ratp_types.py b/backend/api/idfm_interface/ratp_types.py similarity index 100% rename from backend/backend/idfm_interface/ratp_types.py rename to backend/api/idfm_interface/ratp_types.py diff --git a/backend/main.py b/backend/api/main.py similarity index 99% rename from backend/main.py rename to backend/api/main.py index 1eae69a..bcbaaaa 100755 --- a/backend/main.py +++ b/backend/api/main.py @@ -12,7 +12,7 @@ from opentelemetry.sdk.resources import Resource, SERVICE_NAME from opentelemetry.sdk.trace import TracerProvider 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 routers import line, stop diff --git a/backend/backend/models/__init__.py b/backend/api/models/__init__.py similarity index 100% rename from backend/backend/models/__init__.py rename to backend/api/models/__init__.py diff --git a/backend/backend/models/line.py b/backend/api/models/line.py similarity index 98% rename from backend/backend/models/line.py rename to backend/api/models/line.py index 786c585..ce0f2a5 100644 --- a/backend/backend/models/line.py +++ b/backend/api/models/line.py @@ -14,8 +14,8 @@ from sqlalchemy import ( from sqlalchemy.orm import Mapped, mapped_column, relationship, selectinload from sqlalchemy.sql.expression import tuple_ -from ..db import Base, db -from ..idfm_interface.idfm_types import ( +from db import Base, db +from idfm_interface.idfm_types import ( IdfmState, IdfmLineState, TransportMode, diff --git a/backend/backend/models/stop.py b/backend/api/models/stop.py similarity index 98% rename from backend/backend/models/stop.py rename to backend/api/models/stop.py index 05e05e2..02087cc 100644 --- a/backend/backend/models/stop.py +++ b/backend/api/models/stop.py @@ -26,8 +26,8 @@ from sqlalchemy.orm import ( from sqlalchemy.schema import Index from sqlalchemy_utils.types.ts_vector import TSVectorType -from ..db import Base, db -from ..idfm_interface.idfm_types import TransportMode, IdfmState, StopAreaType +from db import Base, db +from idfm_interface.idfm_types import TransportMode, IdfmState, StopAreaType if TYPE_CHECKING: from .line import Line diff --git a/backend/backend/models/user.py b/backend/api/models/user.py similarity index 96% rename from backend/backend/models/user.py rename to backend/api/models/user.py index 24a152c..62bbc28 100644 --- a/backend/backend/models/user.py +++ b/backend/api/models/user.py @@ -1,7 +1,7 @@ from sqlalchemy import BigInteger, ForeignKey, String from sqlalchemy.orm import Mapped, mapped_column, relationship -from ..db import Base, db +from db import Base, db from .stop import _Stop diff --git a/backend/backend/py.typed b/backend/api/py.typed similarity index 100% rename from backend/backend/py.typed rename to backend/api/py.typed diff --git a/backend/routers/__init__.py b/backend/api/routers/__init__.py similarity index 100% rename from backend/routers/__init__.py rename to backend/api/routers/__init__.py diff --git a/backend/routers/line.py b/backend/api/routers/line.py similarity index 91% rename from backend/routers/line.py rename to backend/api/routers/line.py index 917881f..5325d15 100644 --- a/backend/routers/line.py +++ b/backend/api/routers/line.py @@ -1,8 +1,8 @@ from fastapi import APIRouter, HTTPException from fastapi_cache.decorator import cache -from backend.models import Line -from backend.schemas import Line as LineSchema, TransportMode +from models import Line +from schemas import Line as LineSchema, TransportMode router = APIRouter(prefix="/line", tags=["line"]) diff --git a/backend/routers/stop.py b/backend/api/routers/stop.py similarity index 97% rename from backend/routers/stop.py rename to backend/api/routers/stop.py index 1e59f8d..caafb99 100644 --- a/backend/routers/stop.py +++ b/backend/api/routers/stop.py @@ -5,9 +5,9 @@ from typing import Sequence from fastapi import APIRouter, HTTPException from fastapi_cache.decorator import cache -from backend.idfm_interface import Destinations as IdfmDestinations, TrainStatus -from backend.models import Stop, StopArea, StopShape -from backend.schemas import ( +from idfm_interface import Destinations as IdfmDestinations, TrainStatus +from models import Stop, StopArea, StopShape +from schemas import ( NextPassage as NextPassageSchema, NextPassages as NextPassagesSchema, Stop as StopSchema, diff --git a/backend/backend/schemas/__init__.py b/backend/api/schemas/__init__.py similarity index 100% rename from backend/backend/schemas/__init__.py rename to backend/api/schemas/__init__.py diff --git a/backend/backend/schemas/line.py b/backend/api/schemas/line.py similarity index 98% rename from backend/backend/schemas/line.py rename to backend/api/schemas/line.py index 69f29bc..1182bcd 100644 --- a/backend/backend/schemas/line.py +++ b/backend/api/schemas/line.py @@ -2,7 +2,7 @@ from enum import StrEnum from pydantic import BaseModel -from ..idfm_interface import ( +from idfm_interface import ( IdfmLineState, IdfmState, TransportMode as IdfmTransportMode, diff --git a/backend/backend/schemas/next_passage.py b/backend/api/schemas/next_passage.py similarity index 89% rename from backend/backend/schemas/next_passage.py rename to backend/api/schemas/next_passage.py index e895190..1035393 100644 --- a/backend/backend/schemas/next_passage.py +++ b/backend/api/schemas/next_passage.py @@ -1,6 +1,6 @@ from pydantic import BaseModel -from ..idfm_interface.idfm_types import TrainStatus +from idfm_interface.idfm_types import TrainStatus class NextPassage(BaseModel): diff --git a/backend/backend/schemas/stop.py b/backend/api/schemas/stop.py similarity index 92% rename from backend/backend/schemas/stop.py rename to backend/api/schemas/stop.py index 78581ac..e323d8d 100644 --- a/backend/backend/schemas/stop.py +++ b/backend/api/schemas/stop.py @@ -1,6 +1,6 @@ from pydantic import BaseModel -from ..idfm_interface import StopAreaType +from idfm_interface import StopAreaType class Stop(BaseModel): diff --git a/backend/backend/settings.py b/backend/api/settings.py similarity index 100% rename from backend/backend/settings.py rename to backend/api/settings.py diff --git a/backend/db_updater/fill_db.py b/backend/db_updater/fill_db.py index 5bc740d..0995005 100755 --- a/backend/db_updater/fill_db.py +++ b/backend/db_updater/fill_db.py @@ -16,9 +16,9 @@ from shapefile import Reader as ShapeFileReader, ShapeRecord # type: ignore from tqdm import tqdm from yaml import safe_load -from backend.db import Base, db, Database -from backend.models import ConnectionArea, Line, LinePicto, Stop, StopArea, StopShape -from backend.idfm_interface.idfm_types import ( +from api.db import Base, db, Database +from api.models import ConnectionArea, Line, LinePicto, Stop, StopArea, StopShape +from api.idfm_interface.idfm_types import ( ConnectionArea as IdfmConnectionArea, IdfmLineState, Line as IdfmLine, @@ -31,8 +31,8 @@ from backend.idfm_interface.idfm_types import ( StopLineAsso as IdfmStopLineAsso, TransportMode, ) -from backend.idfm_interface.ratp_types import Picto as RatpPicto -from backend.settings import Settings +from api.idfm_interface.ratp_types import Picto as RatpPicto +from api.settings import Settings CONFIG_PATH = environ.get("CONFIG_PATH", "./config.sample.yaml")