Skip to content

Commit a30fe4d

Browse files
authored
Merge pull request #903 from mlco2/patch/add_cpu_power_csv_to_build
fix: add missing csv / json files to build
2 parents 6229037 + 63958e4 commit a30fe4d

29 files changed

Lines changed: 332 additions & 139 deletions

.github/workflows/package.yml

Lines changed: 106 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -8,87 +8,110 @@ on:
88
- "pyproject.toml"
99
branches: [master]
1010
jobs:
11-
build-package:
12-
runs-on: ubuntu-latest
11+
12+
build-package:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
18+
with:
19+
version: "latest"
20+
- name: Set up Python
21+
run: uv python install 3.12
22+
- name: Check versions
23+
run: uv run python .github/check_version.py -o
24+
- name: Build pip package
25+
run: uv build
26+
- name: Archive Pypi artifacts
27+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
28+
with:
29+
name: pypi_dist
30+
path: dist
31+
32+
test-package-from-wheel:
33+
runs-on: ubuntu-24.04
34+
needs: [build-package]
35+
steps:
36+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
with:
38+
sparse-checkout: |
39+
tests/
40+
pytest.ini
41+
sparse-checkout-cone-mode: false
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
44+
with:
45+
version: "latest"
46+
- name: Set up Python
47+
run: uv python install 3.12
48+
- name: Download built package
49+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
50+
with:
51+
name: pypi_dist
52+
path: dist
53+
- name: Create clean virtual environment
54+
run: |
55+
uv venv .venv --python 3.12
56+
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
57+
echo "$PWD/.venv/bin" >> $GITHUB_PATH
58+
- name: Install package from wheel (without source)
59+
run: |
60+
# Install the wheel and test dependencies without the source code
61+
uv pip install dist/*.whl
62+
uv pip install pytest pytest-mock requests-mock responses pandas
63+
- name: Test package integrity
64+
run: |
65+
# Run the package integrity tests to verify all data files are included
66+
uv run python -m pytest tests/test_package_integrity.py -v
67+
CODECARBON_ALLOW_MULTIPLE_RUNS=True pytest --ignore=tests/test_viz_data.py -vv -m 'not integ_test' tests/
68+
- name: Test CLI functionality
69+
run: |
70+
# Test that the CLI is functional
71+
codecarbon --help
72+
python -c "from codecarbon import EmissionsTracker; print('✓ Package import successful')"
73+
74+
build-conda:
75+
runs-on: ubuntu-24.04
1376
steps:
14-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15-
- name: Install uv
16-
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
17-
with:
18-
version: "latest"
19-
- name: Set up Python
20-
run: uv python install 3.12
21-
- name: Check versions
22-
run: |
23-
uv run python .github/check_version.py -o
24-
- name: Build pip package
25-
run: |
26-
uv build
27-
- name: Archive Pypi artifacts
28-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
29-
with:
30-
name: pypi_dist
31-
path: dist
32-
python-test:
33-
runs-on: ubuntu-24.04
34-
strategy:
35-
matrix:
36-
python-version: ["3.9", "3.12", "3.13"]
37-
steps:
38-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39-
- name: Install uv
40-
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
41-
with:
42-
version: "latest"
43-
- name: Set up Python ${{ matrix.python-version }}
44-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
45-
with:
46-
python-version: ${{ matrix.python-version }}
47-
- name: Install dependencies
48-
run: uv sync
49-
- name: Test package
50-
run: uv run task test-package
51-
build-conda:
52-
runs-on: ubuntu-24.04
53-
steps:
54-
- name: Checkout
55-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
56-
- name: Cache build
57-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
58-
with:
59-
path: /tmp/conda-bld
60-
key: build-conda-${{ github.sha }}
61-
- name: set version
62-
run: |
63-
python3 .github/pyproject_versions.py --replace True
64-
- name: Build conda package
65-
uses: prefix-dev/rattler-build-action@20cb88d3095cc01fa181385021c57f886d624879 # v0.2.16
66-
with:
67-
build-args: --channel codecarbon --channel conda-forge --output-dir /tmp/conda-bld
68-
recipe-path: .conda/recipe.yaml
69-
upload-artifact: false
70-
test-conda:
71-
runs-on: ubuntu-24.04
72-
needs: [ build-conda ]
73-
steps:
74-
# Checkout needed to get github.sha
75-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
76-
- name: Setup conda
77-
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
78-
with:
79-
activate-environment: codecarbon
80-
miniforge-version: latest
81-
python-version: 3.12
82-
use-mamba: true
83-
- name: Restore build
84-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
85-
with:
86-
path: /tmp/conda-bld
87-
key: build-conda-${{ github.sha }}
88-
fail-on-cache-miss: true
89-
- name: Install package
90-
shell: bash -l {0}
91-
run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon
92-
- name: Test conda package
93-
shell: bash -l {0}
94-
run: codecarbon --help
77+
- name: Checkout
78+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
79+
- name: Cache build
80+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
81+
with:
82+
path: /tmp/conda-bld
83+
key: build-conda-${{ github.sha }}
84+
- name: set version
85+
run: |
86+
python3 .github/pyproject_versions.py --replace True
87+
- name: Build conda package
88+
uses: prefix-dev/rattler-build-action@20cb88d3095cc01fa181385021c57f886d624879 # v0.2.16
89+
with:
90+
build-args: --channel codecarbon --channel conda-forge --output-dir /tmp/conda-bld
91+
recipe-path: .conda/recipe.yaml
92+
upload-artifact: false
93+
test-conda:
94+
runs-on: ubuntu-24.04
95+
needs: [ build-conda ]
96+
steps:
97+
# Checkout needed to get github.sha
98+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
99+
- name: Setup conda
100+
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
101+
with:
102+
activate-environment: codecarbon
103+
miniforge-version: latest
104+
python-version: 3.12
105+
use-mamba: true
106+
- name: Restore build
107+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
108+
with:
109+
path: /tmp/conda-bld
110+
key: build-conda-${{ github.sha }}
111+
fail-on-cache-miss: true
112+
- name: Install package
113+
shell: bash -l {0}
114+
run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon
115+
- name: Test conda package
116+
shell: bash -l {0}
117+
run: codecarbon --help

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,20 @@ Inside the docker container, run:
296296
- `conda build --python 3.11 .conda/ -c conda-forge --output-folder /conda_dist`
297297
- `anaconda upload --user codecarbon /conda_dist/noarch/codecarbon-*.tar.bz2`
298298

299+
#### Test the build in Docker
300+
301+
If you want to check the build is working, you could run:
302+
303+
```bash
304+
rm dist/*
305+
uv build
306+
docker run -it --rm -v $PWD:/data python:3.13 /bin/bash
307+
pip install pytest pytest-mock requests-mock responses pandas
308+
pip install --no-cache-dir /data/dist/codecarbon-*.whl -U --force-reinstall
309+
cp /data/tests/test_package_integrity.py .
310+
pytest test_package_integrity.py
311+
```
312+
299313
<!-- TOC --><a name="api-and-dashboard"></a>
300314
## API and Dashboard
301315

codecarbon/_version.py

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

docker/Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
FROM python:3.8@sha256:d411270700143fa2683cc8264d9fa5d3279fd3b6afff62ae81ea2f9d070e390c
2-
WORKDIR /opt
3-
1+
FROM python:3.13@sha256:28f60ab75da2183870846130cead1f6af30162148d3238348f78f89cf6160b5d
42
WORKDIR /opt/codecarbon
53
# Tips: relative path is from root project folder as we use context in docker-compose
6-
#COPY ./docker/.env.docker .env
7-
COPY setup.py .
8-
RUN python3 setup.py install
9-
COPY . .
10-
# TODO: install codecarbon package?
4+
# COPY ./docker/.env.docker .env
5+
# COPY . .
6+
# RUN pip install --no-cache-dir codecarbon-*.whl
7+
# COPY . .
8+
# TODO: install codecarbon package?

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: 3dc67ebe45c3e3f033bfe8c12db5ef23
3+
config: b7ea6f802c48a45c32e0628608376fd9
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/_sources/test_on_scaleway.rst.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Install and run the test:
3333
git clone https://github.com/mlco2/codecarbon.git
3434
cd codecarbon
3535
git checkout use-cpu-load
36-
pipx install hatch
37-
hatch run python examples/compare_cpu_load_and_RAPL.py
36+
curl -LsSf https://astral.sh/uv/install.sh | sh
37+
uv run python examples/compare_cpu_load_and_RAPL.py
3838
3939
To do a full code CPU load, we run the following command:
4040

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.3',
2+
VERSION: '3.0.4',
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.3 documentation</title>
9+
<title>Advanced Installation &mdash; CodeCarbon 3.0.4 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
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=9b3fc59f"></script>
16+
<script src="_static/documentation_options.js?v=50b65552"></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.3 documentation</title>
9+
<title>CodeCarbon API &mdash; CodeCarbon 3.0.4 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
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=9b3fc59f"></script>
16+
<script src="_static/documentation_options.js?v=50b65552"></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.3 documentation</title>
9+
<title>Comet Integration &mdash; CodeCarbon 3.0.4 documentation</title>
1010
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
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=9b3fc59f"></script>
16+
<script src="_static/documentation_options.js?v=50b65552"></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)