Skip to content

Commit 3aa600d

Browse files
authored
chore: install codecarbon in publish ci yml (#95)
1 parent 0ec7e50 commit 3aa600d

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
env:
1010
NODE_VERSION: "25"
11+
PYTHON_VERSION: "3.11"
1112

1213
jobs:
1314
publish:
@@ -23,9 +24,17 @@ jobs:
2324
with:
2425
node-version: ${{ env.NODE_VERSION }}
2526

27+
- name: Use Python
28+
uses: actions/setup-python@v6
29+
with:
30+
python-version: ${{ env.PYTHON_VERSION }}
31+
2632
- name: Install dependencies
2733
run: npm ci
2834

35+
- name: Install CodeCarbon
36+
run: python -m pip install --upgrade pip codecarbon
37+
2938
- name: Validate tag matches package version
3039
run: |
3140
TAG_VERSION="${GITHUB_REF_NAME#v}"

src/scripts/tracker.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import json
88
import argparse
99
import os
10-
from codecarbon import EmissionsTracker
1110
from metrics_utils import to_number
1211

1312

@@ -16,6 +15,12 @@
1615

1716
def create_tracker(emissions_file_path=None):
1817
"""Create tracker in single-run mode, optionally overriding CSV destination."""
18+
try:
19+
from codecarbon import EmissionsTracker
20+
except ModuleNotFoundError:
21+
print("CodeCarbon Python package is not installed. Run install/repair and try again.")
22+
sys.exit(1)
23+
1924
if not emissions_file_path:
2025
return EmissionsTracker(allow_multiple_runs=False)
2126

0 commit comments

Comments
 (0)