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 -m "Your release message"

This script automatically bumps the version, commits, tags, builds, and uploads to PyPI.

Before running it, create a .env file in the repo root with your PyPI token:

PYPI_TOKEN="pypi-your-token-here"

You can generate a token at pypi.org/manage/account/token.

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

jupyter_vre_workflow-0.1.249.tar.gz (4.2 MB view details)

Uploaded Source

File details

Details for the file jupyter_vre_workflow-0.1.249.tar.gz.

File metadata

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

File hashes

Hashes for jupyter_vre_workflow-0.1.249.tar.gz
Algorithm Hash digest
SHA256 7caefade85fded11f7f15f05d541fa878060126ad0c01f5f880327b1da2dbc65
MD5 cb2902597a59d330214cf2bf08d93595
BLAKE2b-256 d01a3f017b1c147a05a42ee2092eb5768a0362163a74c3970cd3308fe8223b49

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