Skip to content

feat(cli): forward monitor tracker options - #1275

Open
lntutor wants to merge 4 commits into
mlco2:masterfrom
lntutor:fix/monitor-options-1273
Open

lntutor wants to merge 4 commits into
mlco2:masterfrom
lntutor:fix/monitor-options-1273

Conversation

@lntutor

@lntutor lntutor commented Jul 26, 2026 •

Copy link
Copy Markdown

Description

Forward tracker constructor options passed to codecarbon monitor, including --pue and --allow-multiple-runs. Accepted option names are derived from BaseEmissionsTracker.__init__ so the CLI continues to recognize future scalar tracker options. CLI coverage verifies typed float and boolean forwarding.

Related Issue

Fixes #1273

Motivation and Context

The monitor command accepted tracker configuration but did not forward several supported constructor options. This made CLI monitoring behave differently from direct tracker use.

How Has This Been Tested?

  • uv run python -m pytest tests/cli/test_cli_main.py -q
  • uv run ruff check codecarbon/cli/main.py tests/cli/test_cli_main.py
  • uv run ruff format --check codecarbon/cli/main.py tests/cli/test_cli_main.py

uv run mypy codecarbon/cli/main.py is currently blocked by 285 existing type errors across 19 project modules.

Screenshots (if appropriate):

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

AI Usage Disclosure

  • 🟥 AI-vibecoded: You cannot explain the logic. Car analogy : the car drive by itself, you are outside it and just tell it where to go.
  • 🟠 AI-generated: Car analogy : the car drive by itself, you are inside and give instructions.
  • ⭐ AI-assisted. Car analogy : you drive the car, AI help you find your way.
  • ♻️ No AI used. Car analogy : you drive the car.

OpenAI Codex assisted with implementation and test preparation. I personally reviewed and tested every submitted line, understand the implementation, and can explain and maintain it.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/how-to/contributing.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@lntutor
lntutor requested a review from a team as a code owner July 26, 2026 10:31
@benoit-cty

Copy link
Copy Markdown
Contributor

Hello, thanks for the contribution. Can you keep our PR template ?

@lntutor
lntutor force-pushed the fix/monitor-options-1273 branch from 060a21e to a3ede3f Compare July 31, 2026 01:30
@lntutor

lntutor commented Jul 31, 2026

Copy link
Copy Markdown
Author

Updated the PR description to the complete repository template, including the required 🟠 AI-generated disclosure. I personally reviewed and tested every submitted line, understand the implementation, and can explain and support it through review and after merge.

@codecov

codecov Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.08%. Comparing base (8a8776a) to head (a6d4bfe).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1275   +/-   ##
=======================================
  Coverage   92.07%   92.08%           
=======================================
  Files          49       49           
  Lines        5202     5204    +2     
=======================================
+ Hits         4790     4792    +2     
  Misses        412      412           

☔ 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.

Comment thread codecarbon/cli/main.py Outdated
Comment thread codecarbon/cli/main.py Outdated
Assisted-by: OpenAI Codex GPT-5 <noreply@openai.com>
Signed-off-by: Loi Nguyen <vanloi999@gmail.com>
@lntutor
lntutor force-pushed the fix/monitor-options-1273 branch from a3ede3f to 5b4f3c1 Compare August 8, 2026 14:54
@kvnloo

kvnloo commented Aug 31, 2026

Copy link
Copy Markdown

At exact head 51c955be:

--gpu-ids is forwarded as the raw string "0,2". A collaborator asked to carry over #1298's comma-split-to-list parse (with credit). The new test currently asserts the string. Same for --output-methods ("csv,logger"). Confirm EmissionsTracker.__init__ accepts a string, or parse to list before merge.

Public CLI flags also need docs (docs/reference/cli.md still only lists --no-api / --offline / --country-iso-code / --log-level). CONTRIBUTING requires docs for public-interface changes.

PR body is stale: it still says option names are derived from BaseEmissionsTracker.__init__. That helper was deleted in 5b4f3c19 after the maintainer asked for an explicit list.

Also rebase onto current master d1fb78ab and coordinate with open #1402, which edits the same monitor() function.

Keep master's config-aware defaults for project_name, measure_power_secs, api_call_interval and log_level, and add the explicit tracker options on top. The forwarding test now stubs the user config and no longer expects region when it is not given.

This branch has not been deployed

No deployments
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.

Allow all options to codecarbon monitor

6 participants