Add Dalidou storage foundation and deployment prep
This commit is contained in:
@@ -6,8 +6,21 @@ from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
env: str = "development"
|
||||
debug: bool = False
|
||||
log_level: str = "INFO"
|
||||
data_dir: Path = Path("./data")
|
||||
db_dir: Path | None = None
|
||||
chroma_dir: Path | None = None
|
||||
cache_dir: Path | None = None
|
||||
tmp_dir: Path | None = None
|
||||
vault_source_dir: Path = Path("./sources/vault")
|
||||
drive_source_dir: Path = Path("./sources/drive")
|
||||
source_vault_enabled: bool = True
|
||||
source_drive_enabled: bool = True
|
||||
log_dir: Path = Path("./logs")
|
||||
backup_dir: Path = Path("./backups")
|
||||
run_dir: Path = Path("./run")
|
||||
host: str = "127.0.0.1"
|
||||
port: int = 8100
|
||||
|
||||
@@ -29,11 +42,100 @@ class Settings(BaseSettings):
|
||||
|
||||
@property
|
||||
def db_path(self) -> Path:
|
||||
return self.data_dir / "atocore.db"
|
||||
legacy_path = self.resolved_data_dir / "atocore.db"
|
||||
if self.db_dir is not None:
|
||||
return self.resolved_db_dir / "atocore.db"
|
||||
if legacy_path.exists():
|
||||
return legacy_path
|
||||
return self.resolved_db_dir / "atocore.db"
|
||||
|
||||
@property
|
||||
def chroma_path(self) -> Path:
|
||||
return self.data_dir / "chroma"
|
||||
return self._resolve_path(self.chroma_dir or (self.resolved_data_dir / "chroma"))
|
||||
|
||||
@property
|
||||
def cache_path(self) -> Path:
|
||||
return self._resolve_path(self.cache_dir or (self.resolved_data_dir / "cache"))
|
||||
|
||||
@property
|
||||
def tmp_path(self) -> Path:
|
||||
return self._resolve_path(self.tmp_dir or (self.resolved_data_dir / "tmp"))
|
||||
|
||||
@property
|
||||
def resolved_data_dir(self) -> Path:
|
||||
return self._resolve_path(self.data_dir)
|
||||
|
||||
@property
|
||||
def resolved_db_dir(self) -> Path:
|
||||
return self._resolve_path(self.db_dir or (self.resolved_data_dir / "db"))
|
||||
|
||||
@property
|
||||
def resolved_vault_source_dir(self) -> Path:
|
||||
return self._resolve_path(self.vault_source_dir)
|
||||
|
||||
@property
|
||||
def resolved_drive_source_dir(self) -> Path:
|
||||
return self._resolve_path(self.drive_source_dir)
|
||||
|
||||
@property
|
||||
def resolved_log_dir(self) -> Path:
|
||||
return self._resolve_path(self.log_dir)
|
||||
|
||||
@property
|
||||
def resolved_backup_dir(self) -> Path:
|
||||
return self._resolve_path(self.backup_dir)
|
||||
|
||||
@property
|
||||
def resolved_run_dir(self) -> Path:
|
||||
if self.run_dir == Path("./run"):
|
||||
return self._resolve_path(self.resolved_data_dir.parent / "run")
|
||||
return self._resolve_path(self.run_dir)
|
||||
|
||||
@property
|
||||
def machine_dirs(self) -> list[Path]:
|
||||
return [
|
||||
self.db_path.parent,
|
||||
self.chroma_path,
|
||||
self.cache_path,
|
||||
self.tmp_path,
|
||||
self.resolved_log_dir,
|
||||
self.resolved_backup_dir,
|
||||
self.resolved_run_dir,
|
||||
]
|
||||
|
||||
@property
|
||||
def source_specs(self) -> list[dict[str, object]]:
|
||||
return [
|
||||
{
|
||||
"name": "vault",
|
||||
"enabled": self.source_vault_enabled,
|
||||
"path": self.resolved_vault_source_dir,
|
||||
"read_only": True,
|
||||
},
|
||||
{
|
||||
"name": "drive",
|
||||
"enabled": self.source_drive_enabled,
|
||||
"path": self.resolved_drive_source_dir,
|
||||
"read_only": True,
|
||||
},
|
||||
]
|
||||
|
||||
@property
|
||||
def source_dirs(self) -> list[Path]:
|
||||
return [spec["path"] for spec in self.source_specs if spec["enabled"]]
|
||||
|
||||
def _resolve_path(self, path: Path) -> Path:
|
||||
return path.expanduser().resolve(strict=False)
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
|
||||
def ensure_runtime_dirs() -> None:
|
||||
"""Create writable runtime directories for machine state and logs.
|
||||
|
||||
Source directories are intentionally excluded because they are treated as
|
||||
read-only ingestion inputs by convention.
|
||||
"""
|
||||
for directory in settings.machine_dirs:
|
||||
directory.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user