Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion codecarbon/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,13 @@ def monitor(
typer.Option(help="Log level (critical, error, warning, info, debug)"),
] = "error",
):
"""Monitor your machine's carbon emissions."""
"""Monitor your machine's carbon emissions.

To track a single command instead, pass it after a -- separator:
codecarbon monitor -- python train.py
Emissions are appended to the same emissions.csv report. See
https://docs.codecarbon.io/latest/tutorials/cli/#track-any-command
"""

external_conf = _external_config()

Expand Down
9 changes: 9 additions & 0 deletions tests/cli/test_cli_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ def test_version_flag():
assert str(cli_main.__version__) in result.output


def test_monitor_help_explains_running_a_command():
"""`monitor --help` documents how to wrap a command, not just the machine."""
runner = CliRunner()
result = runner.invoke(cli_main.codecarbon, ["monitor", "--help"])
assert result.exit_code == 0
assert "To track a single command instead" in result.output
assert "codecarbon monitor -- python train.py" in result.output


def test_api_get_calls_api_and_prints(monkeypatch):
runner = CliRunner()
monkeypatch.setattr("codecarbon.core.api_client.ApiClient", FakeApiClient)
Expand Down
Loading