Skip to content

Commit d99fe87

Browse files
authored
Merge pull request #441 from mlco2/bug/dash-org-refresh
Load the organization list
2 parents 9f01ad2 + ec5d8da commit d99fe87

32 files changed

+68
-47
lines changed

.conda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "2.3.0" %}
1+
{% set version = "2.3.1" %}
22

33
package:
44
name: codecarbon

codecarbon/_version.py

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

codecarbon/emissions_tracker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ def start_task(self, task_name=None) -> None:
433433
:return: None
434434
"""
435435
# Stop scheduler as we do not want it to interfere with the task measurement
436-
self._scheduler.stop()
436+
if self._scheduler:
437+
self._scheduler.stop()
437438

438439
if self._active_task:
439440
logger.info("A task is already under measure")

codecarbon/external/scheduler.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def stop(self):
4545
"""
4646
Stop the scheduler.
4747
"""
48-
self._lock.acquire()
49-
self._stopped = True
50-
self._timer.cancel()
51-
self._lock.release()
48+
if not self._stopped:
49+
self._lock.acquire()
50+
self._stopped = True
51+
self._timer.cancel()
52+
self._lock.release()

codecarbon/prometheus/metric_definitions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@
6161
)
6262
cpu_energy_gauge = Gauge(
6363
"codecarbon_cpu_energy",
64-
"Energy used per CPU (kW)",
64+
"Energy used per CPU (kWh)",
6565
registry=registry,
6666
)
6767
gpu_energy_gauge = Gauge(
6868
"codecarbon_gpu_energy",
69-
"Energy used per GPU (kW)",
69+
"Energy used per GPU (kWh)",
7070
registry=registry,
7171
)
7272
ram_energy_gauge = Gauge(
7373
"codecarbon_ram_energy",
74-
"Energy used per RAM (kW)",
74+
"Energy used per RAM (kWh)",
7575
registry=registry,
7676
)
7777
energy_consumed_gauge = Gauge(

dashboard/layout/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def serve_layout():
7777
df_org.name, df_org.id
7878
)
7979
],
80-
# multi=False,
80+
clearable=False,
8181
value=orga_id,
8282
# value=df_org.id.unique().tolist()[0],
8383
# value="Select your organization",

dashboard/layout/callbacks.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
get_experiment_sums,
1010
get_lastrun,
1111
get_orga_sums,
12+
get_organization_list,
1213
get_project,
1314
get_project_list,
1415
get_project_sums,
@@ -595,3 +596,21 @@ def update_map(start_date, end_date, project, kpi):
595596
showland=True, landcolor="#6f898e", showocean=True, oceancolor="#759FA8"
596597
)
597598
return container, fig
599+
600+
601+
# Refresh organizations list
602+
@app.callback(
603+
[
604+
Output(component_id="org-dropdown", component_property="options"),
605+
Output(component_id="org-dropdown", component_property="value"),
606+
],
607+
[Input("url-location", "pathname")],
608+
)
609+
def refresh_org_list(url):
610+
df_org = get_organization_list()
611+
org_id = df_org.id.unique().tolist()[1]
612+
options = [
613+
{"label": orgName, "value": orgId}
614+
for orgName, orgId in zip(df_org.name, df_org.id)
615+
]
616+
return options, org_id

dashboard/layout/components.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def get_header():
1313
[html.Img(src="/assets/logo.png")], href="https://codecarbon.io"
1414
),
1515
html.P("Track and reduce CO2 emissions from your computing"),
16+
dcc.Location(id="url-location", refresh=False),
1617
dcc.DatePickerRange(
1718
id="periode",
1819
day_size=39,

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 hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 81e476ce26cd3132ed5caa32c12cc2be
3+
config: c3b8b30a290e8beba1f269fcdc97e097
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/_sources/output.rst.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Output
44
======
55

6-
CSV
6+
CSV
77
---
88

99
The package has an in-built logger that logs data into a CSV file named ``emissions.csv`` in the ``output_dir``, provided as an
@@ -36,13 +36,13 @@ input parameter (defaults to the current directory), for each experiment tracked
3636
* - ram_power
3737
- RAM power (W)
3838
* - cpu_energy
39-
- Energy used per CPU (kW)
39+
- Energy used per CPU (kWh)
4040
* - gpu_energy
41-
- Energy used per GPU (kW)
41+
- Energy used per GPU (kWh)
4242
* - ram_energy
43-
- Energy used per RAM (kW)
43+
- Energy used per RAM (kWh)
4444
* - energy_consumed
45-
- sum of cpu_energy, gpu_energy and ram_energy (kW)
45+
- sum of cpu_energy, gpu_energy and ram_energy (kWh)
4646
* - country_name
4747
- Name of the country where the infrastructure is hosted
4848
* - country_iso_code

0 commit comments

Comments
 (0)