Skip to content

Commit a2a1cc7

Browse files
authored
Merge pull request #831 from mlco2/fix/config_#830
Fix type error #830
2 parents 62bd434 + 7780c96 commit a2a1cc7

25 files changed

+56
-48
lines changed

codecarbon/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.0.0"
1+
__version__ = "3.0.1"

codecarbon/emissions_tracker.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,18 @@ def _set_from_conf(
123123
# no value provided in the constructor for `name`: check in the conf
124124
# (using the provided default value)
125125
value = self._external_conf.get(name, default)
126-
127-
# parse to `return_type` if needed
128-
if return_type is not None:
126+
if value is not None and return_type is not None:
129127
if return_type is bool:
130128
value = str(value).lower() == "true"
131129
else:
132130
assert callable(return_type)
133-
value = return_type(value)
131+
try:
132+
value = return_type(value)
133+
except (ValueError, TypeError):
134+
logger.error(
135+
f"CONFIG - Value for '{name}' must be of type '{return_type.__name__}'. Got '{value}' instead. It will be ignored."
136+
)
137+
value = None
134138
# Check conf
135139
if name == "output_dir":
136140
if not os.path.exists(value):
@@ -280,10 +284,10 @@ def __init__(
280284
self._set_from_conf(tracking_mode, "tracking_mode", "machine")
281285
self._set_from_conf(on_csv_write, "on_csv_write", "append")
282286
self._set_from_conf(logger_preamble, "logger_preamble", "")
283-
self._set_from_conf(force_cpu_power, "force_cpu_power")
284-
self._set_from_conf(force_ram_power, "force_ram_power")
287+
self._set_from_conf(force_cpu_power, "force_cpu_power", None, float)
288+
self._set_from_conf(force_ram_power, "force_ram_power", None, float)
285289
self._set_from_conf(pue, "pue", 1.0, float)
286-
self._set_from_conf(force_mode_cpu_load, "force_mode_cpu_load", False)
290+
self._set_from_conf(force_mode_cpu_load, "force_mode_cpu_load", False, bool)
287291
self._set_from_conf(
288292
experiment_id, "experiment_id", "5b0fa12a-3dd7-45bb-9766-cc326314d9f1"
289293
)

docs/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: d75eb8ce15708524ae1fb27acec993bc
3+
config: efdde624c3e18e32d8a147d48b8c5ee5
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/_static/documentation_options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const DOCUMENTATION_OPTIONS = {
2-
VERSION: '3.0.0',
2+
VERSION: '3.0.1',
33
LANGUAGE: 'en',
44
COLLAPSE_INDEX: false,
55
BUILDER: 'html',

docs/advanced_installation.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
77

88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9-
<title>Advanced Installation &mdash; CodeCarbon 3.0.0 documentation</title>
9+
<title>Advanced Installation &mdash; CodeCarbon 3.0.1 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
1111
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
1212

1313

1414
<script src="_static/jquery.js?v=5d32c60e"></script>
1515
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
16-
<script src="_static/documentation_options.js?v=acc74ff5"></script>
16+
<script src="_static/documentation_options.js?v=08bfcbec"></script>
1717
<script src="_static/doctools.js?v=9bcbadda"></script>
1818
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
1919
<script src="_static/js/theme.js"></script>

docs/api.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
77

88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9-
<title>CodeCarbon API &mdash; CodeCarbon 3.0.0 documentation</title>
9+
<title>CodeCarbon API &mdash; CodeCarbon 3.0.1 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
1111
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
1212

1313

1414
<script src="_static/jquery.js?v=5d32c60e"></script>
1515
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
16-
<script src="_static/documentation_options.js?v=acc74ff5"></script>
16+
<script src="_static/documentation_options.js?v=08bfcbec"></script>
1717
<script src="_static/doctools.js?v=9bcbadda"></script>
1818
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
1919
<script src="_static/js/theme.js"></script>

docs/comet.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
77

88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9-
<title>Comet Integration &mdash; CodeCarbon 3.0.0 documentation</title>
9+
<title>Comet Integration &mdash; CodeCarbon 3.0.1 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
1111
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
1212

1313

1414
<script src="_static/jquery.js?v=5d32c60e"></script>
1515
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
16-
<script src="_static/documentation_options.js?v=acc74ff5"></script>
16+
<script src="_static/documentation_options.js?v=08bfcbec"></script>
1717
<script src="_static/doctools.js?v=9bcbadda"></script>
1818
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
1919
<script src="_static/js/theme.js"></script>

docs/edit/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# The full version, including alpha/beta/rc tags
2626

27-
release = "3.0.0"
27+
release = "3.0.1"
2828

2929
# -- General configuration ---------------------------------------------------
3030

docs/examples.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
77

88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9-
<title>Examples &mdash; CodeCarbon 3.0.0 documentation</title>
9+
<title>Examples &mdash; CodeCarbon 3.0.1 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
1111
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
1212

1313

1414
<script src="_static/jquery.js?v=5d32c60e"></script>
1515
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
16-
<script src="_static/documentation_options.js?v=acc74ff5"></script>
16+
<script src="_static/documentation_options.js?v=08bfcbec"></script>
1717
<script src="_static/doctools.js?v=9bcbadda"></script>
1818
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
1919
<script src="_static/js/theme.js"></script>

docs/faq.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
77

88
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9-
<title>Frequently Asked Questions &mdash; CodeCarbon 3.0.0 documentation</title>
9+
<title>Frequently Asked Questions &mdash; CodeCarbon 3.0.1 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
1111
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
1212

1313

1414
<script src="_static/jquery.js?v=5d32c60e"></script>
1515
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
16-
<script src="_static/documentation_options.js?v=acc74ff5"></script>
16+
<script src="_static/documentation_options.js?v=08bfcbec"></script>
1717
<script src="_static/doctools.js?v=9bcbadda"></script>
1818
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
1919
<script src="_static/js/theme.js"></script>

0 commit comments

Comments
 (0)