From ac90d502392ff4e6842495970a1230a8c87cb4a6 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Sun, 26 Mar 2023 19:29:13 +0200 Subject: [PATCH] Remove lean mode --- README.md | 2 -- api/config.dev.py | 1 - api/config.py.example | 5 --- api/obs/api/app.py | 4 +-- api/obs/api/process.py | 9 ++---- api/obs/api/routes/frontend.py | 28 +++++++---------- deployment/examples/config.py | 25 ++++++--------- docs/lean-mode.md | 57 ---------------------------------- 8 files changed, 25 insertions(+), 106 deletions(-) delete mode 100644 docs/lean-mode.md diff --git a/README.md b/README.md index 1fbbd7f..0e61270 100644 --- a/README.md +++ b/README.md @@ -192,8 +192,6 @@ docker-compose run --rm api alembic upgrade head ## Import OpenStreetMap data -**Hint:** This step may be skipped if you are using [Lean mode](./docs/lean-mode.md). - You need to import road information from OpenStreetMap for the portal to work. This information is stored in your PostgreSQL database and used when processing tracks (instead of querying the Overpass API), as well as for vector tile diff --git a/api/config.dev.py b/api/config.dev.py index 7889740..d5a402f 100644 --- a/api/config.dev.py +++ b/api/config.dev.py @@ -4,7 +4,6 @@ DEBUG = True VERBOSE = False AUTO_RELOAD = True SECRET = "!!!!!!!!!!!!CHANGE ME!!!!!!!!!!!!" -LEAN_MODE = False POSTGRES_URL = "postgresql+asyncpg://obs:obs@postgres/obs" POSTGRES_POOL_SIZE = 20 POSTGRES_MAX_OVERFLOW = 2 * POSTGRES_POOL_SIZE diff --git a/api/config.py.example b/api/config.py.example index 9e6096d..e2ff283 100644 --- a/api/config.py.example +++ b/api/config.py.example @@ -7,11 +7,6 @@ DEBUG = False VERBOSE = DEBUG AUTO_RELOAD = DEBUG -# Turn on lean mode to simplify the setup. Lots of features will be -# unavailable, but you will not need to manage OpenStreetMap data. Please make -# sure to configure the OBS_FACE_CACHE_DIR correctly for lean mode. -LEAN_MODE = False - # Required to encrypt or sign sessions, cookies, tokens, etc. SECRET = "!!!<<>>!!!" diff --git a/api/obs/api/app.py b/api/obs/api/app.py index fa14e1a..b785512 100644 --- a/api/obs/api/app.py +++ b/api/obs/api/app.py @@ -320,9 +320,7 @@ from .routes import ( exports, ) -if not app.config.LEAN_MODE: - from .routes import tiles, mapdetails - +from .routes import tiles, mapdetails from .routes import frontend diff --git a/api/obs/api/process.py b/api/obs/api/process.py index 79a39d8..01a601d 100644 --- a/api/obs/api/process.py +++ b/api/obs/api/process.py @@ -25,7 +25,7 @@ from obs.face.filter import ( RequiredFieldsFilter, ) -from obs.face.osm import DataSource, DatabaseTileSource, OverpassTileSource +from obs.face.osm import DataSource, DatabaseTileSource from obs.api.db import OvertakingEvent, RoadUsage, Track, UserDevice, make_session from obs.api.app import app @@ -39,12 +39,7 @@ def get_data_source(): mode, the OverpassTileSource is used to fetch data on demand. In normal mode, the roads database is used. """ - if app.config.LEAN_MODE: - tile_source = OverpassTileSource(cache_dir=app.config.OBS_FACE_CACHE_DIR) - else: - tile_source = DatabaseTileSource() - - return DataSource(tile_source) + return DataSource(DatabaseTileSource()) async def process_tracks_loop(delay): diff --git a/api/obs/api/routes/frontend.py b/api/obs/api/routes/frontend.py index 7ccaa70..6f6e25f 100644 --- a/api/obs/api/routes/frontend.py +++ b/api/obs/api/routes/frontend.py @@ -14,22 +14,18 @@ if app.config.FRONTEND_CONFIG: **req.app.config.FRONTEND_CONFIG, "apiUrl": f"{req.ctx.api_url}/api", "loginUrl": f"{req.ctx.api_url}/login", - "obsMapSource": ( - None - if app.config.LEAN_MODE - else { - "type": "vector", - "tiles": [ - req.ctx.api_url - + req.app.url_for("tiles", zoom="000", x="111", y="222.pbf") - .replace("000", "{z}") - .replace("111", "{x}") - .replace("222", "{y}") - ], - "minzoom": 0, - "maxzoom": 14, - } - ), + "obsMapSource": { + "type": "vector", + "tiles": [ + req.ctx.api_url + + req.app.url_for("tiles", zoom="000", x="111", y="222.pbf") + .replace("000", "{z}") + .replace("111", "{x}") + .replace("222", "{y}") + ], + "minzoom": 0, + "maxzoom": 14, + }, } return response.json(result) diff --git a/deployment/examples/config.py b/deployment/examples/config.py index 1927434..646b7ed 100644 --- a/deployment/examples/config.py +++ b/deployment/examples/config.py @@ -1,35 +1,30 @@ # Bind address of the server -#HOST = "127.0.0.1" -#PORT = 3000 +# HOST = "127.0.0.1" +# PORT = 3000 # Extended log output, but slower DEBUG = False VERBOSE = DEBUG AUTO_RELOAD = DEBUG -# Turn on lean mode to simplify the setup. Lots of features will be -# unavailable, but you will not need to manage OpenStreetMap data. Please make -# sure to configure the OBS_FACE_CACHE_DIR correctly for lean mode. -LEAN_MODE = False - # Required to encrypt or sign sessions, cookies, tokens, etc. -#SECRET = "!!!<<>>!!!" +# SECRET = "!!!<<>>!!!" # Connection to the database -#POSTGRES_URL = "postgresql+asyncpg://user:pass@host/dbname" -#POSTGRES_POOL_SIZE = 20 -#POSTGRES_MAX_OVERFLOW = 2 * POSTGRES_POOL_SIZE +# POSTGRES_URL = "postgresql+asyncpg://user:pass@host/dbname" +# POSTGRES_POOL_SIZE = 20 +# POSTGRES_MAX_OVERFLOW = 2 * POSTGRES_POOL_SIZE # URL to the keycloak realm, as reachable by the API service. This is not # necessarily its publicly reachable URL, keycloak advertises that iself. -#KEYCLOAK_URL = "http://localhost:1234/auth/realms/obs/" +# KEYCLOAK_URL = "http://localhost:1234/auth/realms/obs/" # Auth client credentials -#KEYCLOAK_CLIENT_ID = "portal" -#KEYCLOAK_CLIENT_SECRET = "00000000-0000-0000-0000-000000000000" +# KEYCLOAK_CLIENT_ID = "portal" +# KEYCLOAK_CLIENT_SECRET = "00000000-0000-0000-0000-000000000000" # Whether the API should run the worker loop, or a dedicated worker is used -#DEDICATED_WORKER = True +# DEDICATED_WORKER = True # The root of the frontend. Needed for redirecting after login, and for CORS. # Set to None if frontend is served by the API. diff --git a/docs/lean-mode.md b/docs/lean-mode.md deleted file mode 100644 index 7bf3751..0000000 --- a/docs/lean-mode.md +++ /dev/null @@ -1,57 +0,0 @@ -# Lean mode - -The application can be configured in "lean mode" through the `LEAN_MODE` -setting in `config.py`. A lean installation is easier to set up, as a few steps -can be skipped. However, the performance of the application will degrade in -lean mode, and lots of advanced features will not be available. - -Lean mode is meant as an entrypoint to get started with collecting data, -without the hassle of importing and maintaining OpenStreetMap data. - -## Disabled features in lean mode - -* No map tiles are generated. -* The frontend will not show an overview map, only per-track maps. -* The `roads` database table is not used, neither for processing tracks, nor - for generating map tiles. -* The API will not generate auxiliary information for display on the - (nonexistent) map, such as per-road statistics. - -## Switch to/from lean mode - -To enable lean mode, set the following in your `config.py` (or in -`config.overrides.py`, especially in development setups): - -```python -LEAN_MODE = True -``` - -To disable lean mode, set it to `False` instead. - -For lean mode, it is important that the config variable `OBS_FACE_CACHE_DIR` is -properly set, or that you are happy with its default value of using -`$DATA_DIR/obs-face-cache`. - -When turning off lean mode, make sure to fill your `roads` table properly, as -otherwise the track processing will not work. When turning on lean mode, you -may truncate the `roads` table to save space, but you don't need to, it simply -becomes unused. - -## Benefits - -* When using lean mode, you can skip the import of OpenStreetMap data during - setup, and you also do not need to keep it updated. -* People can already start uploading data and the data is also processed, - giving you as a maintainer more time to set up the full application, if you - want to. - -## Drawbacks - -* Lean mode is less performant when processing tracks. -* Lean mode track processing depends on the Overpass API data source, which may - be slow, unavailable, or rate limiting the requests, so processing may fail. - We use caching to prevent some issues, but as we depend on a third party - service here that is accessed for free and that generates a lot of server - load, we really can't ask for much. If you frequently run into issues, the - best bet is to manage OSM data yourself and turn off lean mode. -* Of course some features are missing.