mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-26 14:32:28 +03:00
fix(config): keep the default path when a path variable is blank
- TRADINGAGENTS_RESULTS_DIR, _CACHE_DIR and _MEMORY_LOG_PATH left blank no longer resolve to an empty path
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -100,6 +101,21 @@ def test_empty_env_value_is_passthrough(monkeypatch):
|
|||||||
assert dc.DEFAULT_CONFIG["max_debate_rounds"] == 1
|
assert dc.DEFAULT_CONFIG["max_debate_rounds"] == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_empty_path_value_keeps_the_default_path(monkeypatch):
|
||||||
|
""".env.example lists the path variables blank; uncommenting one made the
|
||||||
|
path empty, and the graph failed creating its directories."""
|
||||||
|
dc = _reload_with_env(
|
||||||
|
monkeypatch,
|
||||||
|
TRADINGAGENTS_RESULTS_DIR="",
|
||||||
|
TRADINGAGENTS_CACHE_DIR="",
|
||||||
|
TRADINGAGENTS_MEMORY_LOG_PATH="",
|
||||||
|
)
|
||||||
|
home = dc._TRADINGAGENTS_HOME
|
||||||
|
assert dc.DEFAULT_CONFIG["results_dir"] == os.path.join(home, "logs")
|
||||||
|
assert dc.DEFAULT_CONFIG["data_cache_dir"] == os.path.join(home, "cache")
|
||||||
|
assert dc.DEFAULT_CONFIG["memory_log_path"] == os.path.join(home, "memory", "trading_memory.md")
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_int_raises(monkeypatch):
|
def test_invalid_int_raises(monkeypatch):
|
||||||
"""Garbage int values should surface a ValueError at import, not silently misconfigure."""
|
"""Garbage int values should surface a ValueError at import, not silently misconfigure."""
|
||||||
monkeypatch.setenv("TRADINGAGENTS_MAX_DEBATE_ROUNDS", "not-a-number")
|
monkeypatch.setenv("TRADINGAGENTS_MAX_DEBATE_ROUNDS", "not-a-number")
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ def _apply_env_overrides(config: dict) -> dict:
|
|||||||
|
|
||||||
DEFAULT_CONFIG = _apply_env_overrides({
|
DEFAULT_CONFIG = _apply_env_overrides({
|
||||||
"project_dir": os.path.abspath(os.path.join(os.path.dirname(__file__), ".")),
|
"project_dir": os.path.abspath(os.path.join(os.path.dirname(__file__), ".")),
|
||||||
"results_dir": os.getenv("TRADINGAGENTS_RESULTS_DIR", os.path.join(_TRADINGAGENTS_HOME, "logs")),
|
"results_dir": os.getenv("TRADINGAGENTS_RESULTS_DIR") or os.path.join(_TRADINGAGENTS_HOME, "logs"),
|
||||||
"data_cache_dir": os.getenv("TRADINGAGENTS_CACHE_DIR", os.path.join(_TRADINGAGENTS_HOME, "cache")),
|
"data_cache_dir": os.getenv("TRADINGAGENTS_CACHE_DIR") or os.path.join(_TRADINGAGENTS_HOME, "cache"),
|
||||||
"memory_log_path": os.getenv("TRADINGAGENTS_MEMORY_LOG_PATH", os.path.join(_TRADINGAGENTS_HOME, "memory", "trading_memory.md")),
|
"memory_log_path": os.getenv("TRADINGAGENTS_MEMORY_LOG_PATH") or os.path.join(_TRADINGAGENTS_HOME, "memory", "trading_memory.md"),
|
||||||
# Optional cap on the number of resolved memory log entries. When set,
|
# Optional cap on the number of resolved memory log entries. When set,
|
||||||
# the oldest resolved entries are pruned once this limit is exceeded.
|
# the oldest resolved entries are pruned once this limit is exceeded.
|
||||||
# Pending entries are never pruned. None disables rotation entirely.
|
# Pending entries are never pruned. None disables rotation entirely.
|
||||||
|
|||||||
Reference in New Issue
Block a user