Skip to content

fix(cli): report actual emissions file path - #1331

Open
davidberenstein1957 wants to merge 1 commit into
masterfrom
fix/cli-output-path-report
Open

fix(cli): report actual emissions file path#1331
davidberenstein1957 wants to merge 1 commit into
masterfrom
fix/cli-output-path-report

Conversation

@davidberenstein1957

Copy link
Copy Markdown
Collaborator

The codecarbon monitor post-run report resolved the emissions file path from tracker._conf["output_file"], which is only the basename. os.path.abspath then resolved it against the current working directory, so any output_dir other than the default "." produced a path where the file is not. The CLI defaults to log_level="error", which suppresses the correct INFO line FileOutput logs, so the wrong path was the only one the user saw.

What changed

codecarbon/cli/monitor.py now asks the tracker's output handlers for their save_file_path instead 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.

Verification

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, test_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.

Display-only change; no measurement or file-writing behaviour is affected.

Closes #1322

🤖 Generated with Claude Code

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.43%. Comparing base (3ec31a0) to head (cbf6e59).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1331      +/-   ##
==========================================
- Coverage   91.43%   91.43%   -0.01%     
==========================================
  Files          49       49              
  Lines        5057     5056       -1     
==========================================
- Hits         4624     4623       -1     
  Misses        433      433              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@davidberenstein1957
davidberenstein1957 marked this pull request as ready for review August 12, 2026 19:14
@davidberenstein1957
davidberenstein1957 requested a review from a team as a code owner August 12, 2026 19:14
@davidberenstein1957
davidberenstein1957 force-pushed the fix/cli-output-path-report branch from 5dc9467 to 4bf4bcb Compare August 19, 2026 14:26
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>
@davidberenstein1957
davidberenstein1957 force-pushed the fix/cli-output-path-report branch from ba5bab5 to cbf6e59 Compare August 20, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codecarbon monitor prints a "Saved to" path that ignores output_dir

1 participant