Skip to content
Open
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
22 changes: 20 additions & 2 deletions apps/codecarbon-demo/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
from codecarbon.viz.carbonboard import render_app
import os
from pathlib import Path

import codecarbon
import pandas as pd
from codecarbon.viz import components
from codecarbon.viz.carbonboard import render_app

# Workaround for a codecarbon bug: components.py opens the Canada geojson
# with a CWD-relative path. Point it at the installed package instead.
_PACKAGE_PARENT = Path(codecarbon.__file__).resolve().parent.parent


def _open_relative_to_package(file, *args, **kwargs):
if isinstance(file, str) and not os.path.isabs(file) and file.startswith("codecarbon/"):
file = _PACKAGE_PARENT / file
return open(file, *args, **kwargs)


components.open = _open_relative_to_package

df = pd.read_csv("emissions.csv")

Expand All @@ -8,4 +26,4 @@
server = app.server

if __name__ == "__main__":
app.run_server(debug=True)
app.run(debug=True)
9 changes: 9 additions & 0 deletions apps/codecarbon-demo/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "codecarbon-demo"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
"codecarbon[carbonboard]>=3.3.0",
"gunicorn>=26.2.0",
"pandas>=3.0.5",
]
189 changes: 155 additions & 34 deletions apps/codecarbon-demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,155 @@
APScheduler==3.7.0
Brotli==1.0.9
certifi==2021.5.30
charset-normalizer==2.0.4
click==8.0.1
codecarbon==1.2.0
dash==1.21.0
dash-bootstrap-components==0.13.0
dash-core-components==1.17.1
dash-html-components==1.1.4
dash-table==4.12.0
fire==0.4.0
Flask==2.0.1
Flask-Compress==1.10.1
future==0.18.2
gunicorn==20.1.0
idna==3.2
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
numpy==1.21.2
pandas==1.3.2
plotly==5.3.0
py-cpuinfo==8.0.0
pynvml==11.0.0
python-dateutil==2.8.2
pytz==2021.1
requests==2.26.0
six==1.16.0
tenacity==8.0.1
termcolor==1.1.0
tzlocal==2.1
urllib3==1.26.6
Werkzeug==2.0.1
# This file was autogenerated by uv via the following command:
# uv export --no-hashes --no-emit-project --format requirements-txt -o requirements.txt
annotated-doc==0.0.5
# via typer
annotated-types==0.8.0
# via pydantic
arrow==1.4.0
# via codecarbon
authlib==1.8.0
# via codecarbon
blinker==1.9.0
# via flask
certifi==2026.7.22
# via requests
cffi==2.1.1 ; platform_python_implementation != 'PyPy'
# via cryptography
charset-normalizer==3.5.1
# via requests
click==8.5.0
# via
# codecarbon
# flask
codecarbon==3.3.0
# via codecarbon-demo
colorama==0.4.6 ; sys_platform == 'win32'
# via typer
comm==0.2.3
# via dash
cryptography==50.0.1
# via
# authlib
# joserfc
dash==4.4.1
# via
# codecarbon
# dash-bootstrap-components
dash-bootstrap-components==2.0.4
# via codecarbon
fire==0.7.1
# via codecarbon
flask==3.1.3
# via dash
gunicorn==26.2.0
# via codecarbon-demo
idna==3.19
# via requests
importlib-metadata==9.0.1
# via dash
itsdangerous==2.2.0
# via flask
janus==2.0.0
# via dash
jinja2==3.1.6
# via flask
joserfc==1.7.5
# via
# authlib
# codecarbon
markdown-it-py==4.2.0
# via rich
markupsafe==3.0.3
# via
# flask
# jinja2
# werkzeug
mdurl==0.1.2
# via markdown-it-py
narwhals==2.25.0
# via plotly
nest-asyncio==1.6.0
# via dash
numpy==2.4.6 ; python_full_version < '3.12'
# via pandas
numpy==2.5.2 ; python_full_version >= '3.12'
# via pandas
nvidia-ml-py==13.610.43
# via codecarbon
packaging==26.3
# via plotly
pandas==3.0.5
# via
# codecarbon
# codecarbon-demo
plotly==7.0.0
# via dash
prometheus-client==0.26.0
# via codecarbon
prompt-toolkit==3.0.53
# via questionary
psutil==7.2.2
# via codecarbon
py-cpuinfo==9.0.0
# via codecarbon
pycountry==26.2.16
# via codecarbon
pycparser==3.0 ; implementation_name != 'PyPy' and platform_python_implementation != 'PyPy'
# via cffi
pydantic==2.13.5
# via
# codecarbon
# dash
pydantic-core==2.46.5
# via pydantic
pygments==2.21.0
# via rich
python-dateutil==2.9.0.post0
# via
# arrow
# pandas
questionary==2.1.1
# via codecarbon
rapidfuzz==3.14.6
# via codecarbon
requests==2.34.2
# via
# codecarbon
# dash
retrying==1.4.2
# via dash
rich==15.0.0
# via
# codecarbon
# typer
setuptools==84.0.0
# via dash
shellingham==1.5.4
# via typer
six==1.17.0
# via python-dateutil
termcolor==3.3.0
# via fire
typer==0.27.2
# via codecarbon
typing-extensions==4.16.0
# via
# dash
# pydantic
# pydantic-core
# typing-inspection
typing-inspection==0.4.4
# via pydantic
tzdata==2026.3
# via
# arrow
# pandas
urllib3==2.7.0
# via requests
wcwidth==0.8.3
# via prompt-toolkit
werkzeug==3.1.8
# via
# dash
# flask
zipp==4.1.0
# via importlib-metadata
2 changes: 1 addition & 1 deletion apps/codecarbon-demo/runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.8.2
python-3.11
Loading