Skip to content

fix(cli): use OfflineEmissionsTracker for offline monitor runs#1202

Merged
benoit-cty merged 2 commits into
masterfrom
fix/monitor-offline-tracker
May 20, 2026
Merged

fix(cli): use OfflineEmissionsTracker for offline monitor runs#1202
benoit-cty merged 2 commits into
masterfrom
fix/monitor-offline-tracker

Conversation

@davidberenstein1957
Copy link
Copy Markdown
Collaborator

Summary

  • codecarbon monitor --offline --country-iso-code FRA -- <command> delegates to run_and_monitor, which always constructed EmissionsTracker.
  • Offline kwargs (country_iso_code, region) were forwarded to BaseEmissionsTracker.__init__, causing: unexpected keyword argument 'country_iso_code'.
  • run_and_monitor now selects OfflineEmissionsTracker when country_iso_code is present in tracker kwargs (same signal as the top-level monitor command).

Test plan

  • uv run pytest tests/cli/test_monitor.py -q
  • Manual: codecarbon monitor --offline --country-iso-code FRA -- python -c "print('hello')"

Made with Cursor

@davidberenstein1957 davidberenstein1957 requested a review from a team as a code owner May 19, 2026 19:07
@davidberenstein1957 davidberenstein1957 force-pushed the fix/monitor-offline-tracker branch from ee75977 to 7094f40 Compare May 19, 2026 19:09
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.91%. Comparing base (5c3331a) to head (e68906a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1202   +/-   ##
=======================================
  Coverage   88.90%   88.91%           
=======================================
  Files          45       45           
  Lines        4301     4302    +1     
=======================================
+ Hits         3824     3825    +1     
  Misses        477      477           

☔ View full report in Codecov by Sentry.
📢 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
Copy link
Copy Markdown
Collaborator Author

@copilot can you improve the coverage of these tests?

Copy link
Copy Markdown
Contributor

@benoit-cty benoit-cty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this.

davidberenstein1957 and others added 2 commits May 20, 2026 17:48
Pass an explicit offline flag from monitor to run_and_monitor so tracker
selection matches the non-delegate path instead of inferring from kwargs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@benoit-cty benoit-cty force-pushed the fix/monitor-offline-tracker branch from 0463321 to e68906a Compare May 20, 2026 15:48
@benoit-cty benoit-cty merged commit d2ce064 into master May 20, 2026
13 checks passed
@benoit-cty benoit-cty deleted the fix/monitor-offline-tracker branch May 20, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants