Drop support for using comma separated values in monitor_directories, only use that logic when converting from env vars
This commit is contained in:
parent
469d993542
commit
268c26eb4e
3 changed files with 18 additions and 18 deletions
|
|
@ -465,3 +465,13 @@ haiku-rag init-config --from-env
|
|||
```
|
||||
|
||||
This will read your current environment variables and generate a `haiku.rag.yaml` file with those settings.
|
||||
|
||||
!!! note
|
||||
When migrating from environment variables, list values like `MONITOR_DIRECTORIES` that were comma-separated (`/path1,/path2`) will be converted to proper YAML lists. In YAML, always use list syntax:
|
||||
|
||||
```yaml
|
||||
storage:
|
||||
monitor_directories:
|
||||
- /path/to/dir1
|
||||
- /path/to/dir2
|
||||
```
|
||||
|
|
|
|||
|
|
@ -131,6 +131,13 @@ def load_config_from_env() -> dict:
|
|||
for env_var, path in env_mappings.items():
|
||||
value = os.getenv(env_var)
|
||||
if value is not None:
|
||||
# Special handling for MONITOR_DIRECTORIES - parse comma-separated list
|
||||
if env_var == "MONITOR_DIRECTORIES":
|
||||
if value.strip():
|
||||
value = [p.strip() for p in value.split(",") if p.strip()]
|
||||
else:
|
||||
value = []
|
||||
|
||||
if isinstance(path, tuple):
|
||||
current = result
|
||||
for key in path[:-1]:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from pathlib import Path
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from haiku.rag.utils import get_default_data_dir
|
||||
|
||||
|
|
@ -76,20 +76,3 @@ class AppConfig(BaseModel):
|
|||
processing: ProcessingConfig = Field(default_factory=ProcessingConfig)
|
||||
providers: ProvidersConfig = Field(default_factory=ProvidersConfig)
|
||||
a2a: A2AConfig = Field(default_factory=A2AConfig)
|
||||
|
||||
@field_validator("storage", mode="before")
|
||||
@classmethod
|
||||
def parse_storage(cls, v):
|
||||
"""Parse storage config, handling comma-separated monitor directories."""
|
||||
if isinstance(v, dict) and "monitor_directories" in v:
|
||||
dirs = v["monitor_directories"]
|
||||
if isinstance(dirs, str):
|
||||
if not dirs.strip():
|
||||
v["monitor_directories"] = []
|
||||
else:
|
||||
v["monitor_directories"] = [
|
||||
Path(path.strip()).absolute()
|
||||
for path in dirs.split(",")
|
||||
if path.strip()
|
||||
]
|
||||
return v
|
||||
|
|
|
|||
Loading…
Reference in a new issue