Cross-language lightweight SDK for Carbon Live / GreenRefactor dashboard
Project description
GreenRefactor Python SDK
WS öncelikli, HTTP fallback’li Python istemcisi. pycarbon.dashboard.server ile konuşur.
Kurulum (yerel pip)
cd /Users/aligokkaya/Desktop/Carbon/code-carbon/sdks/greenrefactor-python
python -m venv .venv
source .venv/bin/activate
pip install -e .
Bu sayede greenrefactor modülünü import edebilirsin.
Örnekler
Tüm örnekler examples/ altında. Ortak adımlar:
cd /Users/aligokkaya/Desktop/Carbon/code-carbon/sdks/greenrefactor-python/examples
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt # -e .. içerir
Basit Span (simple_span.py)
CARBON_HOST=127.0.0.1 python simple_span.py
Script CarbonClient ile bir session başlatır ve @carbon_span dekoratörüyle CPU-yoğun işi dashboard’a gönderir.
SDK artık span başlangıç/bitiş mesajlarına otomatik olarak
ts(timestamp) ekler ve decorator/context manager'larametasözlüğü geçebilirsin.
Örnek kullanım:
from greenrefactor import carbon_span, send_heartbeat
send_heartbeat(
agent="python-simple",
version="1.0.0",
interval=30,
meta={"lang": "python", "env": "local"},
)
@carbon_span("python-demo.work", meta=lambda: {"phase": "warmup"})
def heavy_python_work():
...
send_heartbeat sadece HTTP üzerinden /api/v1/heartbeat çağırır; ws bağlantısı gerektirmez.
Ağır Test (demo.py)
BURN_MINUTES=1 python demo.py
CPU, disk, bellek ve opsiyonel GPU/net yükleri oluşturur. Dashboard’da belirgin enerji artışı görürsün.
Unutma: Önce backend’i aç (
python -m pycarbon.dashboard.serverveya Docker imajı).
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 greenrefactor_python-0.3.11.tar.gz.
File metadata
- Download URL: greenrefactor_python-0.3.11.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0067a162fec65a13431d58f50454bb03071848a77c511fb4efa497c108cacf28
|
|
| MD5 |
88f6d26a7aaaabc88a389ccb00f4bf7b
|
|
| BLAKE2b-256 |
030f4f9525594ca8288ffc27dbe109777cb95b8b89ee5c4496ab5c708ca850c3
|
File details
Details for the file greenrefactor_python-0.3.11-py3-none-any.whl.
File metadata
- Download URL: greenrefactor_python-0.3.11-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54b423c315f1b67869cbbb4a0960a3d328b375963dc067bec87d0b151a98f7ff
|
|
| MD5 |
dfccb69184be20df2736d926334fed57
|
|
| BLAKE2b-256 |
080afa2c1b50dd4866d70246ad895bd0ab60a4bb0e943d31a79cca6dac8ed3fe
|