Core SDK for carbon-aware computing
Project description
CarbonCue SDK
Core Python SDK for carbon-aware computing based on Green Software Foundation (GSF) principles.
Features
- 🌍 Real-time carbon intensity data from Electricity Maps
- 📊 SCI (Software Carbon Intensity) score calculation per GSF specification
- ⚡ Async/await support for high-performance applications
- 🔌 Extensible API client architecture
- 💾 Built-in caching to reduce API calls
- 🎯 Type-safe with Pydantic models
Installation
pip install carboncue-sdk
Quick Start
import asyncio
from carboncue_sdk import CarbonClient
async def main():
async with CarbonClient() as client:
# Get current carbon intensity
intensity = await client.get_current_intensity(
region="us-west-2",
provider="aws"
)
print(f"Current intensity: {intensity.carbon_intensity} gCO2eq/kWh")
# Calculate SCI score
sci = client.calculate_sci(
operational_emissions=100.0, # gCO2eq from energy usage
embodied_emissions=50.0, # gCO2eq from hardware
functional_unit=1000, # Number of requests
functional_unit_type="requests",
region="us-west-2"
)
print(f"SCI Score: {sci.score} gCO2eq/request")
asyncio.run(main())
Configuration
Set environment variables with CARBONCUE_ prefix:
export CARBONCUE_ELECTRICITY_MAPS_API_KEY=your_api_key
export CARBONCUE_DEFAULT_REGION=us-west-2
export CARBONCUE_CACHE_TTL_SECONDS=300
Or use a .env file:
CARBONCUE_ELECTRICITY_MAPS_API_KEY=your_api_key
CARBONCUE_DEFAULT_REGION=us-west-2
SCI Calculation
Implements the GSF Software Carbon Intensity specification:
SCI = (O + M) / R
Where:
O = Operational emissions (energy consumption × carbon intensity)
M = Embodied emissions (hardware manufacturing & infrastructure)
R = Functional unit (requests, users, transactions, etc.)
API Reference
CarbonClient
Main client for carbon-awareness operations.
Methods:
get_current_intensity(region, provider)- Get real-time carbon intensitycalculate_sci(...)- Calculate SCI score per GSF specclose()- Cleanup resources
Models
CarbonIntensity- Carbon intensity data with timestampSCIScore- Complete SCI calculation resultRegion- Cloud region informationEmissionsBreakdown- Detailed emissions breakdown
Development
# Install in development mode
cd packages/sdk
pip install -e ".[dev]"
# Run tests
pytest
# Type checking
mypy src/
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file carboncue_sdk-1.1.0.tar.gz.
File metadata
- Download URL: carboncue_sdk-1.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6318356a96885e53995ef61ea47df623bfc7259070e6d120ee93db3c9cb2921c
|
|
| MD5 |
72cfebb0f4404e311e3e1ab1625c7494
|
|
| BLAKE2b-256 |
bdfd57431ca97b674fea01afcd01ac7a4aa2c796e9de5a6738029fe39d260d8d
|
File details
Details for the file carboncue_sdk-1.1.0-py3-none-any.whl.
File metadata
- Download URL: carboncue_sdk-1.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a275a2b3daa7f1dec6060af4d5de0f05783448e18add081dd7fc49c752ca336
|
|
| MD5 |
ca5257118295e2f8ade00546884f082c
|
|
| BLAKE2b-256 |
47bed29d87d5b475b5f63e664fcefac5bf9453f829a612e0813f23b10de0e163
|