Skip to main content

A JupyterLab extension for workflow sustainability metrics.

Project description

๐ŸŒฑ๐ŸŒโ™ป๏ธ EcoJupyter (a GreenDIGIT project)

EcoJupyter is an platform-agnostic sustainability assessment tool for AI infrastructures. The current version is focused on Jupyter Notebook.

This tool was developed for the GreenDIGIT EU Project, with the main goal of providing a platform agnostic and easily-pluggable sustainability and reproducibility tool.

This code is open-source, so feel free to copy/paste it into your machine. Please, keep in mind that this is still WIP: it works best with L1EcoVRE infrastructure configuration and scripts. For more info please contact the main contributor.

Main features

  • Read energy metrics through Prometheus and Scaphandre in real-time charts.
  • Energy computed KPIs such as SCI, SCI/Unit and Energy/Unit.
  • Metadata manager and exporter for Federated Data Management Infrastructures (FDMI).

It works best with JupyterK8sMonitor infrastructure configuration and scripts. For more info please contact the main contributor.

EcoJupyter_main_app

Installation

In order to install the tool as an extension in Jupyter Notebook or Lab (not in development), simply install the tool in your Python environment where Jupyter is running.

pip install --upgrade ecojupyter

Development & Extension Framework

This repository was initially scaffolded using the official JupyterLab Extension Tutorial.
As a result, the extension supports a development mode with live reloading, allowing for real-time updates to the UI as you modify TypeScript/React components.

To launch the development environment (as per the tutorial), run:

./scripts/start-jupyterlab-dev.sh

This will start JupyterLab in development mode, ideal for iterating on the UI and debugging extension logic interactively.

Python Package & Deployment The Python package is published on PyPI and can be built locally via:

./scripts/build-rel-package.sh

This script automatically packages the extension and prepares it for upload, enabling a simple and consistent release workflow.

Future Improvements

  • Version-based deployment: easily extendable via GitHub releases or semantic versioning.
  • CI/CD integration: GitHub Actions workflows are already present and can be extended for linting, testing, and publishing.
  • Custom builds: additional scripts like install-conda.sh and uninstall-conda.sh support environment setup and teardown, aiding reproducibility.

Project structure

API definitions

EcoJupyter's front-end connects with the server's back-end using the IPython kernel through the IKernelConnection.executeRequest() channelโ€”used to execute Kernel request on demand, written in Python or as a shell script. In the future a full-fledge RESTful API should be implemented to properly enforce types, definitions and methods. For the POC timeline this was the most reasonable trade-off between flexibility and effectiveness.

The methods can be found in apiScripts.ts module file, with all the API-like methods used defined and self-described.

Folder Structure

EcoJupyter/
โ”œโ”€โ”€ .copier-answers.yml
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .prettierignore
โ”œโ”€โ”€ .yarnrc.yml
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ RELEASE.md
โ”œโ”€โ”€ Untitled.ipynb
โ”œโ”€โ”€ install.json
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ setup.py
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ yarn.lock
โ”œโ”€โ”€ .github
โ”‚   โ””โ”€โ”€ workflows
โ”‚       โ”œโ”€โ”€ binder-on-pr.yml
โ”‚       โ”œโ”€โ”€ build.yml
โ”‚       โ”œโ”€โ”€ check-release.yml
โ”‚       โ”œโ”€โ”€ enforce-label.yml
โ”‚       โ”œโ”€โ”€ prep-release.yml
โ”‚       โ”œโ”€โ”€ publish-release.yml
โ”‚       โ””โ”€โ”€ update-integration-tests.yml
โ”œโ”€โ”€ assets
โ”‚   โ””โ”€โ”€ EcoJupyter_screenshot.png
โ”œโ”€โ”€ ecojupyter
โ”‚   โ””โ”€โ”€ __init__.py
โ””โ”€โ”€ scripts
โ”‚   โ”œโ”€โ”€ add-catalogue-entry.sh
โ”‚   โ”œโ”€โ”€ build-rel-package.sh
โ”‚   โ”œโ”€โ”€ install-conda.sh
โ”‚   โ”œโ”€โ”€ start-jupyterlab-dev.sh
โ”‚   โ””โ”€โ”€ uninstall-conda.sh
โ””โ”€โ”€ src
    โ”œโ”€โ”€ api
    โ”‚   โ”œโ”€โ”€ ApiTemp.ts
    โ”‚   โ”œโ”€โ”€ api-temp-openapi.yml
    โ”‚   โ”œโ”€โ”€ apiScripts.ts
    โ”‚   โ”œโ”€โ”€ getCarbonIntensityData.ts
    โ”‚   โ”œโ”€โ”€ getScaphData.ts
    โ”‚   โ”œโ”€โ”€ handleNotebookContents.ts
    โ”‚   โ””โ”€โ”€ monitorCellExecutions.ts
    โ”œโ”€โ”€ components
    โ”‚   โ”œโ”€โ”€ FetchMetricsComponents.tsx
    โ”‚   โ”œโ”€โ”€ KPIComponent.tsx
    โ”‚   โ”œโ”€โ”€ KpiValue.tsx
    โ”‚   โ”œโ”€โ”€ MetricSelector.tsx
    โ”‚   โ””โ”€โ”€ ...
    โ”œโ”€โ”€ dialog
    โ”‚   โ””โ”€โ”€ CreateChartDialog.tsx
    โ”œโ”€โ”€ helpers
    โ”‚   โ”œโ”€โ”€ constants.ts
    โ”‚   โ”œโ”€โ”€ types.ts
    โ”‚   โ””โ”€โ”€ utils.ts
    โ”œโ”€โ”€ index.ts
    โ””โ”€โ”€ widget.tsx

Development setup

Create and activate a local Python environment:

python -m venv .venv
source .venv/bin/activate

Install JupyterLab and this extension in editable mode:

python -m pip install "jupyterlab>=4.0.0,<5"
SKIP_JUPYTER_BUILDER=1 python -m pip install -e .
yarn install

# Run everytime some ts file in src/ changes.
yarn build:lib --skipLibCheck
PATH=.venv/bin:$PATH jupyter labextension build --development True .

PATH=.venv/bin:$PATH jupyter labextension develop . --overwrite

Install the frontend dependencies and watch the extension sources:

yarn install
yarn watch

In another terminal, activate the same environment and start JupyterLab:

source .venv/bin/activate
jupyter lab

Commands for a hard refresh during development:

yarn build:lib --skipLibCheck
PATH=.venv/bin:$PATH jupyter labextension build --development True .
PATH=.venv/bin:$PATH jupyter labextension develop . --overwrite

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecojupyter-0.1.248.tar.gz (4.0 MB view details)

Uploaded Source

File details

Details for the file ecojupyter-0.1.248.tar.gz.

File metadata

  • Download URL: ecojupyter-0.1.248.tar.gz
  • Upload date:
  • Size: 4.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for ecojupyter-0.1.248.tar.gz
Algorithm Hash digest
SHA256 6ed996998643f20e17812b8544ecf403f4715dea625635721937add84094f0f4
MD5 04bd6d7f9f0dc7f7e5cb25d37f4dc1fe
BLAKE2b-256 2e1f6ff20e17ad9b95988fb2ecb30a6bdd40f442dfddfa95928f7b3f0294fbad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page