CarbonAwareComputing.ExecutionForecast
1.1.3
See the version list below for details.
dotnet add package CarbonAwareComputing.ExecutionForecast --version 1.1.3
NuGet\Install-Package CarbonAwareComputing.ExecutionForecast -Version 1.1.3
<PackageReference Include="CarbonAwareComputing.ExecutionForecast" Version="1.1.3" />
paket add CarbonAwareComputing.ExecutionForecast --version 1.1.3
#r "nuget: CarbonAwareComputing.ExecutionForecast, 1.1.3"
// Install CarbonAwareComputing.ExecutionForecast as a Cake Addin #addin nuget:?package=CarbonAwareComputing.ExecutionForecast&version=1.1.3 // Install CarbonAwareComputing.ExecutionForecast as a Cake Tool #tool nuget:?package=CarbonAwareComputing.ExecutionForecast&version=1.1.3
Carbon Aware Computing
Execute computing tasks when the grid is powered by renewable energy
The goal of this project is to provide developers with hassle free, easy to use, ready to run tools for carbon aware computing. All libraries and data are open source and open data with unrestricted usage. Within private, open source and commercial software.
time-shifting, demand-shifting
The basic idea behind the time-shifting approach is to move the computing load in to a point in time, when the power grid has a maximum of renewable energy. This will result in a lower emission of CO2 of your computing task.
This project will deliver a set of libraries, services and data. There are mostly extensions to other projects and all credits belong to them. To forecast the best execution time the Carbon Aware SDK from the Green Software Foundation is used. The Forecast data is from Energy Charts provided by Frauenhofer ISE.
Get the best execution time as library
Use the NuGet-package for your .NET project to get the best execution time for a task, in a given Execution-Window for a estimated duration. The lib will calculate the optimal execution time within the provided forecast data.
Installation
Just add the package to your project.
Install-Package CarbonAwareComputing.ExecutionForecast
Usage
Instantiate a CarbonAwareDataProvider and call CalculateBestExecutionTime
// Hold the provider as singleton. The forecast data is cached
var provider = new CarbonAwareDataProviderOpenData();
var forecast = provider.CalculateBestExecutionTime(
ComputingLocations.Germany,
DateTimeOffset.Now,
DateTimeOffset.Now + TimeSpan.FromHours(8),
TimeSpan.FromMinutes(20)
);
var executionTime = forecast.Match(
noForecast =>
{
Console.WriteLine("No forecast available. Use fallback");
return DateTimeOffset.Now;
},
bestExecutionTime =>
{
Console.WriteLine($"Forecast available for a task of {bestExecutionTime.Duration} length");
return bestExecutionTime.ExecutionTime;
});
In the above example we will get a optimal execution time for the German Power Grid from now to 8 hours for a task with an estimated duration of 20 minutes. Please have in mind that this a best effort approach. Based on the data or your boundaries a forecast is not available.
The CarbonAwareDataProviderOnlineForecastFile has a cache of all forecasts. To improve performance use it as a singleton, to avoid multiple downloads. For a list of locations see below.
Hangfire Extension
Hangfire is one of the most used tools for background processing in .NET. Use the Hangfire.CarbonAwareExecution Extension to enqueue and schedule your jobs.
Installation
Hangfire.Community.CarbonAwareExecution is available as a NuGet package. You can install it using the NuGet-Package Console window:
Install-Package Hangfire.Community.CarbonAwareExecution
After installation add the extension to the Hangfire configuration.
builder.Services.AddHangfireCarbonAwareExecution(configuration => configuration.
UseCarbonAwareDataProvider(new CarbonAwareDataProviderOpenData(), ComputingLocations.Germany));
Usage
There are extension to Enqueue and Schedule with WithCarbonAwarenessAsync. For more details check the GitHub Repository.
Web API
We provide a live and ready to use subset of the Carbon Aware SDK. The API is available from this location: https://forecast.carbon-aware-computing.com/. Use the Swagger UI https://forecast.carbon-aware-computing.com/swagger/UI to play around with the API.
Registration
To use the API, you must register to the service submitting a valid eMail-Address. Please check the register endpoint in the Swagger UI. The API-Key is send to this email. We will use this address only to inform you about important changes to the service.
curl -X POST "https://forecast.carbon-aware-computing.com/register" -H "accept: */*" -H "Content-Type: application/json" -d "{\"mailAddress\":\"someone@example.com\"}"
Subset of endpoints & data
We want to support the time-shifting functionality of the SDK and provide only the forecast endpoint for given locations. There are no historically data and the forecast data has only the optimalDataPoints collection set. The emissionsDataPoints with all forecast data is not set due to data efficiency. If you need the forecast data download it directly.
Carbon Aware SDK as NuGet-Package
We have fork the Carbon Aware SDK https://github.com/bluehands/carbon-aware-sdk and provide the SDK as a NuGet-Package. The fork has also some modifications for cached data provider. You may use this package for your extensions.
Installation
The unofficial Carbon Aware SDK is available form nuget.org. Install it using the Package Manager Console window:
Install-Package GSF.CarbonAware.Unofficial
PowerShell Cmdlets
There is a PowerShell Cmdlets to forecast the best execution time. You may use this Cmdlets in automation scripts to execute tasks with carbon awareness. See the GitHub Repository for more details.
Installation
Install-Module -Name CarbonAwareComputing
Usage
$now=get-date
Get-CarbonAwareExecutionTime -Location at -EarliestExecutionTime $now -LatestExecutionTime ($now).AddHours(10) -EstimatedExecutionDuration "00:10:00"
Set the FallbackExecutionTime Parameter to set the execution time when no forecast is available. This command is designed to be used in scripts, therefor no errors are thrown.
Data
The forecast data is gathered from Energy Charts provided by Frauenhofer ISE. It is licensed as CC 0 https://creativecommons.org/publicdomain/zero/1.0/. You may use it for any purpose without any credits.
Download
The forecast data is available as json formatted files for every location. The files are directly consumable by the Carbon Aware SDK. Download is publicly available from a Azure Blob Storage.
curl -X GET "https://carbonawarecomputing.blob.core.windows.net/forecasts/{LOCATION}.json" -H "accept: application/json"
Replace the {LOCATION} with one of the supported locations two letter country code (e.g. "de").
Available and supported locations
We support the most countries in Europe, but not all are active. For computing efficiency we start with a Germany, France, Austria and Switzerland. If you have a need for some other countries please contact us. We will activate that country. To get a list of all locations see the locations endpoint of the API. Every location has a IsActive-Flag.
curl -X GET "https://forecast.carbon-aware-computing.com/locations" -H "accept: application/json"
Methodology
The forecast data is based on reported energy production (current) and forecast production for Wind (on-shore & off-shore) and Solar. This information's are send to the ENTSO-E Transparency Platform by the power grid Transmission System Operators (TSO). For the additional renewable energy sources like running water, bio mass the forecast is calculated as an interpolation of the last hours. After that the share of renewable energy is calculated as the quotient of generated renewable energy to all generated energy. This forecast is very accurate because it is used by the TSO to manage the power grid. The data is recalculated every hour by Energy Charts. The forecast for next day is available at 19:00+02.
In future Energy Charts will provide mid term forecast based on weather forecast and own calculations as well.
Fallback
For regions we not support (e.g. US, Asia), a WattTime-DataProvider is implemented. For that you must provide your WattTime Credentials.
Contribution
Every contribution is warmly welcome. You may contribute to forecast data for other regions than Europe or help to integrate time-shifting in popular processing systems and libraries. Migration to other programming languages and runtime systems is very efficacious as well.
Contact
Please drop a message to
Aydin Mir Mohammadi
am@bluehands.de
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.Caching.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Caching.Memory (>= 6.0.0)
- Microsoft.Extensions.Http (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CarbonAwareComputing.ExecutionForecast:
Package | Downloads |
---|---|
CarbonAwareComputing.Hangfire
A Hangfire Extension to schedule tasks on a point in time with minimal grid carbon intensity. The extension uses the Green Software Foundation Carbon Aware SDK to calculate best execution time. For the emission forecast open data is used. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.1.5 | 171 | 3/24/2024 | |
1.1.4 | 117 | 3/24/2024 | |
1.1.3 | 299 | 12/3/2023 | |
1.1.1 | 349 | 4/29/2023 | |
1.1.0 | 170 | 4/17/2023 | |
1.0.5 | 175 | 4/12/2023 | |
1.0.4 | 177 | 4/12/2023 | |
1.0.3 | 197 | 4/9/2023 | |
1.0.1-beta | 145 | 4/4/2023 | |
1.0.0-beta | 146 | 4/4/2023 |