codecarbon 2.7.4__tar.gz → 2.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codecarbon-2.7.4 → codecarbon-2.8.1}/.gitignore +2 -2
- {codecarbon-2.7.4 → codecarbon-2.8.1}/PKG-INFO +1 -1
- codecarbon-2.8.1/codecarbon/_version.py +1 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/cli/main.py +13 -3
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/api_client.py +2 -1
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/config.py +12 -0
- codecarbon-2.8.1/codecarbon/data/private_infra/global_energy_mix.json +4475 -0
- codecarbon-2.8.1/codecarbon/data/private_infra/our_world_in_data.ipynb +2536 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/emissions_tracker.py +16 -5
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/external/hardware.py +24 -7
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/lock.py +1 -1
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/http.py +17 -1
- {codecarbon-2.7.4 → codecarbon-2.8.1}/pyproject.toml +1 -1
- codecarbon-2.7.4/codecarbon/_version.py +0 -1
- codecarbon-2.7.4/codecarbon/data/private_infra/global_energy_mix.json +0 -1640
- codecarbon-2.7.4/codecarbon/data/private_infra/our_world_in_data.ipynb +0 -1784
- {codecarbon-2.7.4 → codecarbon-2.8.1}/LICENSE +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/README.md +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/__init__.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/cli/__init__.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/cli/cli_utils.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/__init__.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/cloud.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/co2_signal.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/cpu.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/emissions.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/gpu.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/measure.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/powermetrics.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/rapl.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/schemas.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/units.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/core/util.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/canada_provinces.geojson +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/cloud/impact.csv +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/hardware/cpu_power.csv +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/2016/canada_energy_mix.json +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/2016/global_energy_mix-old.json +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/2016/usa_emissions.json +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/2020/01_get_world_carbon_intensity.ipynb +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/2020/02_convert_csv_to_json.ipynb +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/2020/03_add_eu_data.ipynb +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/2020/eu-carbon-intensity-electricity.csv +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/2023-07-07-22-40-48.png +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/carbon_intensity_per_source.json +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/data/private_infra/world_energy_mix.csv +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/external/__init__.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/external/geography.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/external/logger.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/external/scheduler.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/external/task.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/input.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/__init__.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/base_output.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/emissions_data.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/file.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/logger.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/metrics/__init__.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/metrics/logfire.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/metrics/metric_docs.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/output_methods/metrics/prometheus.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/__init__.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/assets/__init__.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/assets/car_icon.png +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/assets/house_icon.png +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/assets/tv_icon.png +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/carbonboard.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/carbonboard_on_api.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/components.py +0 -0
- {codecarbon-2.7.4 → codecarbon-2.8.1}/codecarbon/viz/data.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.8.1"
|
|
@@ -316,16 +316,26 @@ def monitor(
|
|
|
316
316
|
api (Annotated[bool, typer.Option, optional): Choose to call Code Carbon API or not. Defaults to True.
|
|
317
317
|
"""
|
|
318
318
|
experiment_id = get_existing_local_exp_id()
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
token = None
|
|
320
|
+
if api:
|
|
321
|
+
if experiment_id is None:
|
|
322
|
+
print("ERROR: No experiment id, call 'codecarbon init' first.", err=True)
|
|
323
|
+
token = _get_access_token()
|
|
321
324
|
print("CodeCarbon is going in an infinite loop to monitor this machine.")
|
|
322
325
|
with EmissionsTracker(
|
|
323
326
|
measure_power_secs=measure_power_secs,
|
|
324
327
|
api_call_interval=api_call_interval,
|
|
325
328
|
save_to_api=api,
|
|
326
|
-
|
|
329
|
+
access_token=token,
|
|
330
|
+
) as tracker:
|
|
327
331
|
# Infinite loop
|
|
328
332
|
while True:
|
|
333
|
+
if (
|
|
334
|
+
hasattr(tracker, "_another_instance_already_running")
|
|
335
|
+
and tracker._another_instance_already_running
|
|
336
|
+
):
|
|
337
|
+
print("Another instance of CodeCarbon is already running. Exiting.")
|
|
338
|
+
break
|
|
329
339
|
time.sleep(300)
|
|
330
340
|
|
|
331
341
|
|
|
@@ -43,6 +43,7 @@ class ApiClient: # (AsyncClient)
|
|
|
43
43
|
endpoint_url="https://dash-dev.cleverapps.io/api", # beta API
|
|
44
44
|
experiment_id=None,
|
|
45
45
|
api_key=None,
|
|
46
|
+
access_token=None,
|
|
46
47
|
conf=None,
|
|
47
48
|
):
|
|
48
49
|
"""
|
|
@@ -54,7 +55,7 @@ class ApiClient: # (AsyncClient)
|
|
|
54
55
|
self.experiment_id = experiment_id
|
|
55
56
|
self.api_key = api_key
|
|
56
57
|
self.conf = conf
|
|
57
|
-
self.access_token =
|
|
58
|
+
self.access_token = access_token
|
|
58
59
|
if self.experiment_id is not None:
|
|
59
60
|
self._create_run(self.experiment_id)
|
|
60
61
|
import warnings
|
|
@@ -3,6 +3,8 @@ import os
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import List
|
|
5
5
|
|
|
6
|
+
from codecarbon.external.logger import logger
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
def clean_env_key(k: str) -> str:
|
|
8
10
|
"""
|
|
@@ -96,6 +98,16 @@ def get_hierarchical_config():
|
|
|
96
98
|
home = Path.home()
|
|
97
99
|
global_path = str((home / ".codecarbon.config").expanduser().resolve())
|
|
98
100
|
local_path = str((cwd / ".codecarbon.config").expanduser().resolve())
|
|
101
|
+
if Path(global_path).exists():
|
|
102
|
+
logger.info(
|
|
103
|
+
f"Codecarbon is taking the configuration from global file: {global_path}"
|
|
104
|
+
)
|
|
105
|
+
if Path(local_path).exists():
|
|
106
|
+
logger.info(f"Some variables are overriden by the local file: {local_path}")
|
|
107
|
+
elif Path(local_path).exists():
|
|
108
|
+
logger.info(
|
|
109
|
+
f"Codecarbon is taking the configuration from the local file {local_path}"
|
|
110
|
+
)
|
|
99
111
|
|
|
100
112
|
config.read([global_path, local_path])
|
|
101
113
|
config.read_dict(parse_env_config())
|