paths.py: make DATA_DIR/LOGS_DIR env-overridable to avoid /app/data volume collision
After the repo split the code lives at the image root, so the Python package data/ and the runtime data dir <root>/data are the same path (/app/data). The deploy compose mounts the appdata volume there, shadowing data/*.py so 'import data.climate' fails at container boot. THERMOGRAPH_DATA_DIR (and _LOGS_DIR) now let the container point runtime state at a path outside the code tree; local dev is unchanged (defaults to <root>/data).
This commit is contained in:
parent
8555e705a9
commit
7b7727f234
1 changed files with 10 additions and 2 deletions
12
paths.py
12
paths.py
|
|
@ -12,8 +12,16 @@ keep doing so; these are only the defaults.
|
|||
import os
|
||||
|
||||
REPO_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
DATA_DIR = os.path.join(REPO_DIR, "data")
|
||||
LOGS_DIR = os.path.join(REPO_DIR, "logs")
|
||||
# Runtime state dirs default under the repo root, but MUST be overridable: after
|
||||
# the repo split the code lives at the image root (/app), so the Python package
|
||||
# `data/` and the runtime data dir `<root>/data` collide at the same path. When
|
||||
# a persistent volume is mounted at that path (as the deploy compose does for
|
||||
# the parquet cache / notifier.lock / geonames) it shadows and erases the
|
||||
# `data/*.py` modules, so `import data.climate` fails at boot. Point
|
||||
# THERMOGRAPH_DATA_DIR (and _LOGS_DIR) at a path OUTSIDE the code tree in the
|
||||
# container to keep the volume clear of the package.
|
||||
DATA_DIR = os.environ.get("THERMOGRAPH_DATA_DIR") or os.path.join(REPO_DIR, "data")
|
||||
LOGS_DIR = os.environ.get("THERMOGRAPH_LOGS_DIR") or os.path.join(REPO_DIR, "logs")
|
||||
|
||||
# Bundled reference data shipped alongside the code (generated by gen_cities /
|
||||
# gen_flavor), not runtime state — hence at the repo root, not data/.
|
||||
|
|
|
|||
Loading…
Reference in a new issue