- scheduler - The core scheduling
library, a.k.a.
schedlib
. - scheduler-server - This package. The Flask API for fetching schedules.
- scheduler-web - The web front end for the scheduler.
First clone this repository, and then install it with
pip install -r requirements.txt
pip install -e .
Launching it requires gunicorn
to be available. If we are inside this directory, run
gunicorn --bind localhost:8010 scheduler_server.app:app
Alternatively, you can launch the server in a docker container:
docker run --rm -p 8010:8010 scheduler-server
The API is temporarily hosted here: https://scheduler-uobd.onrender.com
POST /api/v1/schedule/
The Schedule API is used to generate a schedule of commands.
The API expects a JSON object in the request body with the following properties:
t0
: a string representing the start time in the format "YYYY-MM-DD HH:MM"t1
: a string representing the end time in the format "YYYY-MM-DD HH:MM"policy
: a json string representing the scheduling policy. It should contain a"policy"
key which specify the name of the policy and a"config"
key which contains a dictionary of configurations for this given policy. The provided configuration will overwrite the default configuration used. Current supported policy names:"dummy"
and"basic"
.
The API returns a JSON object with the following properties:
status
: a string indicating the status of the request, either 'ok' or 'error'commands
: a string representing the generated schedule of commandsmessage
: a string representing the message of the request
The API will return a HTTP status code of 200 OK on success and 400 Bad Request on error.
Request:
POST /api/v1/schedule/
{
"t0": "2022-01-01 12:00",
"t1": "2022-01-01 14:00",
"policy": {"policy": "dummy", "config": {}}
}
Successful Response:
{
"status": "ok",
"commands": "import time\ntime.sleep(1)\ntime.sleep(1)\ntime.sleep(1)\n",
"message": "Success"
}
Unsuccessful Response:
{
"status": "error",
"message": "Invalid input"
}
Test with Curl
curl -L -X POST -H "Content-Type: application/json" -d '{"t0": "2022-01-01 12:00", "t1": "2022-01-01 14:00", "policy": "{\"policy\": \"dummy\", \"config\": {}}"}' http://127.0.0.1:8010/api/v1/schedule