Skip to content
Merged
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
9 changes: 6 additions & 3 deletions codecarbon/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,17 @@ def monitor(
api (Annotated[bool, typer.Option, optional): Choose to call Code Carbon API or not. Defaults to True.
"""
experiment_id = get_existing_local_exp_id()
if api and experiment_id is None:
print("ERROR: No experiment id, call 'codecarbon init' first.", err=True)
token = None
if api:
if experiment_id is None:
print("ERROR: No experiment id, call 'codecarbon init' first.", err=True)
token = _get_access_token()
print("CodeCarbon is going in an infinite loop to monitor this machine.")
with EmissionsTracker(
measure_power_secs=measure_power_secs,
api_call_interval=api_call_interval,
save_to_api=api,
access_token=_get_access_token(),
access_token=token,
) as tracker:
# Infinite loop
while True:
Expand Down
Loading