Skip to content

feat(cli): expose tracker options on codecarbon monitor - #1421

Open
HarshRajSinghania wants to merge 1 commit into
mlco2:masterfrom
HarshRajSinghania:feat/monitor-dynamic-tracker-options
Open

HarshRajSinghania wants to merge 1 commit into
mlco2:masterfrom
HarshRajSinghania:feat/monitor-dynamic-tracker-options

Conversation

@HarshRajSinghania

Copy link
Copy Markdown

Summary

Generate additional codecarbon monitor flags from BaseEmissionsTracker.__init__ so CLI options such as --pue and --wue stay aligned with the package API.

Motivation

Fixes #1273. codecarbon monitor --help previously exposed only a small subset of tracker settings. The issue asked for a dynamic implementation that stays synchronized with the tracker constructor.

Implementation

  • Add codecarbon/cli/tracker_options.py to inspect simple str/int/float/bool constructor parameters and publish matching Typer flags.
  • Keep the existing mode-specific monitor options (--offline, --api, measure interval, log level, country/region).
  • Forward only flags that were actually provided so .codecarbon.config and CODECARBON_* values are not overwritten.
  • Skip non-CLI types (logging_logger, output_handlers, output_methods).

Testing

Ran:

PYTHONPATH=. python3 -m pytest tests/cli/test_tracker_options.py tests/cli/test_cli_main.py::test_monitor_offline_initializes_offline_tracker tests/cli/test_cli_main.py::test_monitor_forwards_generated_tracker_options -q

Result: the new tests passed (4 in test_tracker_options.py) plus the existing offline tracker initialization test.

Also invoked codecarbon monitor --help via Typer's CliRunner and confirmed --pue, --wue, and --force-cpu-power appear.

Some other tests in tests/cli/test_cli_main.py failed in this environment because optional packages such as prometheus_client were not installed; those failures look unrelated to this change.

Notes

Complex constructor arguments that cannot be expressed as a single flag are intentionally omitted.

Generate additional `codecarbon monitor` flags from BaseEmissionsTracker.__init__ so options such as --pue and --wue stay in sync with the package API.

Fixes mlco2#1273
@HarshRajSinghania
HarshRajSinghania requested a review from a team as a code owner September 21, 2026 08:41

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

1 participant