fix(cli): report actual emissions file path - #1331
davidberenstein1957 wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1331 +/- ##
=======================================
Coverage 91.70% 91.70%
=======================================
Files 49 49
Lines 5157 5158 +1
=======================================
+ Hits 4729 4730 +1
Misses 428 428 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5dc9467 to
4bf4bcb
Compare
The monitor report resolved the output path from `output_file` alone, which is only the basename, so `os.path.abspath` resolved it against the CWD and ignored `output_dir`. Users were told the file was somewhere it was not. Ask the output handlers for their `save_file_path` instead, which also prints nothing when CSV output is disabled. Keeps the `typing_extensions.Annotated` import the CLI needs on older Pythons. Closes #1322 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ba5bab5 to
cbf6e59
Compare
Verdict: ✅ Approve with nitsThe bug is real. The CLI report used Nits:
|
BoAmpsOutput now exposes save_file_path once a report is written, so the monitor summary lists it. Add the relative-path test the PR description mentions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Made the changes in 869852b: merged master, BoAmps reports now listed, added the relative-path test.
|
Description
codecarbon/cli/monitor.pynow asks the tracker's output handlers for theirsave_file_pathinstead of reconstructing the path from config keys. This keeps the CLI correct if the path logic changes, prints nothing when CSV output is disabled (previously a confidently wrong path), and handles multiple file handlers.Related Issue
Fixes #1322
Motivation and Context
The
codecarbon monitorpost-run report resolved the emissions file path fromtracker._conf["output_file"], which is only the basename.os.path.abspaththen resolved it against the current working directory, so anyoutput_dirother than the default"."produced a path where the file does not actually exist. The CLI defaults tolog_level="error", which suppresses the correct INFO lineFileOutputlogs, so the wrong path was the only one the user saw. This is a display-only change; no measurement or file-writing behavior is affected.How Has This Been Tested?
Three new tests in
tests/cli/test_monitor.py:test_run_and_monitor_reports_output_dir,test_run_and_monitor_reports_relative_path_from_cwd, andtest_run_and_monitor_reports_no_path_without_file_output. The first and third fail on master and pass with this change.uv run pytest tests/cli/test_monitor.py -q→ 10 passed.Screenshots (if appropriate):
N/A
Types of changes
AI Usage Disclosure
Checklist:
Also includes a related fix reporting the BoAmps output path in the CLI summary, with a relative-path test in
tests/test_boamps_output.py.