Scheduler shifts given scripts to time when most renewables available
Project description
renops-scheduler (MIGRATED TO https://github.com/TANGO-EU-PROJECT/renops-scheduler)
renops-scheduler is a Python package that allows you to schedule and execute scripts at the time the most renewable energy is available.
This reduces the carbon footprint and stabilises the grid of our operations. In cases where the electricity price is variable, the scheduler also reduces utility costs. While its main focus are energy-intensive processing tasks such as big data analytics or AI model training, it may be used to shift any energy-intensive load such as HVAC.
Requirements
Before you begin, ensure you have met the following requirements:
- Python: Version 3.8 or higher.
To check your Python version, run:
$ python3 --version
Installation
To install renops-scheduler, run the following command:
$ pip install renops-scheduler
Usage
Once you have installed renops-scheduler, you can use it to schedule and execute Python scripts in command line interface (CLI).
To use the program, follow these steps:
-
Open a terminal or command prompt.
-
Create a new file named
test.pycontaining:$ echo 'print("hello world!")' > test.py
-
Export
RENOPSAPI_KEYenv:$ export RENOPSAPI_KEY="TANGO_DEMO_KEY"
NOTE: This is demo key with limited number of request. Contanct us to obtain personal access token.
-
Run the following command to execute the script with a deadline of 24 hours:
$ renops-scheduler test.py -la -r 6 -d 24 -v --optimise renewable
This will execute the
test.pyin an optimal window within the given deadline.-lasets automatic location detection (uses machines public IP!),-r 6sets runtime (estimated by user),-d 24sets the deadline to 24 hours.
-
Scheduler can also find interval with minimal energy price:
$ renops-scheduler test.py -la -r 6 -d 24 -v --optimise price
This is achieved by adding
--optimise priceflag. -
Running scheduler without automatic location detection:
$ renops-scheduler test.py -l "Berlin,Germany" -r 6 -d 24 -v
In cases where a user does not want to expose its IP, due to privacy concerns, we can manually specify a rough location in a text description.
-
Scheduler can be used to find inteval with minimal carbon emissions:
$ renops-scheduler test.py -la -r 6 -d 24 -v --optimise emissions
This is achieved by adding
--optimise emissionsflag.
Import Example
from renops.scheduler import Scheduler
# Define a function with an argument that scheduler will execute
def test_run(a, text: str):
print("Hello World!")
print("Passed keyword argument:", text)
print("Passed argument:", a)
# Intialise the scheduler
s = Scheduler(runtime=1,
deadline=1,
location="Kranj",
verbose=True,
optimise_type="price",
action=test_run,
argument=([42]),
kwargs={"text": "Scheduler Test!"})
Geographical Shifting
Scheduler allows you to define a set of available endpoints with their associated commands for energy-intensive tasks. The tool intelligently analyzes these locations and selects the optimal one based on your specified metrics (such as renewable energy potential, price, etc.).
CLI
Populate locations.json with following content:
{
"hpc1": {
"location": "Berlin, Germany",
"cmd": "ssh user@hpc1 python3 test.py"
},
"hpc2": {
"location": "Madrid, Spain",
"cmd": "ssh user@hpc2 python3 test.py"
},
"hpc3": {
"location": "Copenhagen, Denmark",
"cmd": "ssh user@hpc3 python3 test.py"
}
}
Run scheduler by passing path to geo-shift.json together with --geo-shift flag
$ renops-scheduler locations.json --geo-shift --optimise-price --verbose
Scheduler will find optimal location to execute the script based on given metric.
Python Script
from renops.geoshifter import GeoShift
# Define locations and commands for each endpoint
locations = {
"hpc1": {
"location": "Berlin, Germany",
"cmd": "ssh user@hpc1 python3 test.py"
},
"hpc2": {
"location": "Madrid, Spain",
"cmd": "ssh user@hpc2 python3 test.py"
},
"hpc3": {
"location": "Copenhagen, Denmark",
"cmd": "ssh user@hpc3 python3 test.py"
}
}
# Intialise the shifter
gs = GeoShift(
locations=locations,
optimise_type="price",
verbose=True
)
# Run geoshifter
gs.shift()
Arguments
The program accepts several command-line arguments to customize the execution. Here's an overview of the available options:
usage: renops-scheduler [-h] -l LOCATION [-gs] [-o {renewable,price,emissions}] [-v] [-r RUNTIME] [-d DEADLINE] script_path
positional arguments:
script_path Path to the script to be executed or JSON file in case of geo shifting.
options:
-h, --help show this help message and exit
-l LOCATION, --location LOCATION
Location can be specified in two ways:
1. Pass a specific location as a string, e.g., "Berlin, Germany".
2. Use automatic location detection based on IP address.
By using this tag, you agree that your IP can be used to detect your location.
You can use any of the following values for this purpose:
-l a (-la)
-l auto
-l automatic
-o {renewable,price,emissions}, --optimise {renewable,price,emissions}
Choose an optimisation type:
- 'renewable' (renewable potential - renewable energy availability on a scale from 0 to 1)
- 'price' (day-ahead energy price)
- 'emissions' (Carbon emissions in gCO2eq/kWh)
-gs, --geo-shift JSON on given path should be formated as:
{
"hpc1": {
"location": "Berlin, Germany",
"cmd": "ssh user@hpc1 python3 train.py"
},
"hpc2": {
"location": "Madrid, Spain",
"cmd": "ssh user@hpc2 python3 train.py"
},
"hpc3": {
"location": "Copenhagen, Denmark",
"cmd": "ssh user@hpc3 python3 train.py"
}
}
-v, --verbose Verbose mode.
-r RUNTIME, --runtime RUNTIME
Runtime in hours. (Not for geo shift mode)
-d DEADLINE, --deadline DEADLINE
Deadline in hours, by when should script finish running (Not for geo shift mode)
Privacy
The script does not pose security or privacy concerns, as it runs locally. The communication between our forecasting API is encrypted and includes an approximate location of the requested forecast. Automatic localization through IP is mandatory and must be manually set.
Licences
This project is licensed under the Apache License - see the LICENSE file for details.
Attributions
- Open meteo (https://open-meteo.com/en/license)
- NASA POWER API (https://power.larc.nasa.gov/docs/services/api/)
- ENTSO-e (https://transparency.entsoe.eu/content/static_content/download?path=/Static%20content/terms%20and%20conditions/231018_List_of_Data_available_for_reuse.pdf)
- OpenStreetMap (https://osmfoundation.org/wiki/Licence)
Notes
- renops-scheduler is currently in beta version and may contain bugs or limitations.
- Send possible suggestions, bugs and improvements to jakob.jenko@xlab.si
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 renops_scheduler-1.1.1.tar.gz.
File metadata
- Download URL: renops_scheduler-1.1.1.tar.gz
- Upload date:
- Size: 2.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5f009fc1a6f4e3e20180d5488cb2557874529aacb80cbace1fae86cee0f4cd2
|
|
| MD5 |
998e6c5e69451283c5f5c1702167266a
|
|
| BLAKE2b-256 |
b8e033efd81d2ed32386d51db51dc757de180a865e2c2003ef2110bd8cd61e36
|
File details
Details for the file renops_scheduler-1.1.1-py3-none-any.whl.
File metadata
- Download URL: renops_scheduler-1.1.1-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa29a67a33c20219803d5aefc312b86d9d39557858b8b14dfde2c61389d975f9
|
|
| MD5 |
72c828ebcc589bcbf0fda58c048cfc4b
|
|
| BLAKE2b-256 |
833caf416098db097983154e58b63772ae714f30f74dbafc46fff5acf04ee651
|