mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-11-27 19:46:20 +02:00
refactor(cli): save a run's reports through the graph, as a script does
- TradingAgentsGraph.default_report_path names the results_dir/reports/TICKER_stamp folder; save_reports and the CLI both use it
This commit is contained in:
@@ -95,10 +95,14 @@ def test_save_and_show_answer_the_questions_after_the_run(monkeypatch, tmp_path)
|
||||
monkeypatch.setattr(run.typer, "prompt", no_prompt)
|
||||
shown = []
|
||||
monkeypatch.setattr(run, "display_complete_report", lambda state: shown.append(state))
|
||||
graph = type("G", (), {"run_settings": lambda self: {}})()
|
||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||
|
||||
graph = object.__new__(TradingAgentsGraph)
|
||||
graph.config = {"results_dir": str(tmp_path)}
|
||||
graph.run_settings = lambda: {}
|
||||
state = {"market_report": "M", "final_trade_decision": "**Rating**: Hold"}
|
||||
|
||||
run._offer_reports(state, graph, {"results_dir": str(tmp_path)}, "NVDA", save=True, show=False)
|
||||
run._offer_reports(state, graph, "NVDA", save=True, show=False)
|
||||
|
||||
assert list(tmp_path.glob("reports/NVDA_*/complete_report.md"))
|
||||
assert shown == []
|
||||
|
||||
@@ -50,8 +50,10 @@ def test_save_reports_explicit_path(tmp_path):
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_save_reports_defaults_under_results_dir(tmp_path):
|
||||
mock_self = SimpleNamespace(config={"results_dir": str(tmp_path)}, run_settings=lambda: SETTINGS)
|
||||
out = TradingAgentsGraph.save_reports(mock_self, _state(), "AAPL")
|
||||
graph = object.__new__(TradingAgentsGraph)
|
||||
graph.config = {"results_dir": str(tmp_path)}
|
||||
graph.run_settings = lambda: SETTINGS
|
||||
out = graph.save_reports(_state(), "AAPL")
|
||||
assert out.exists()
|
||||
assert out.parent.parent.name == "reports" # results_dir/reports/AAPL_<stamp>/...
|
||||
assert out.parent.name.startswith("AAPL_")
|
||||
|
||||
Reference in New Issue
Block a user