A scheduler for task and ruleset based parallel computation. Useful for highly parallel applications.
Project description
task-ruleset
A scheduler for task and ruleset based parallel computation. Useful for highly parallel applications.
Any algorithm can be devided into a set of steps, called Tasks. Some Tasks may need to be run in a particular order, and some may be run in any order.
We define Tasks of several types, and a Rule for acting on each type of Task. These Rules may perform some computation and end their Task, and then may create one or more new Tasks of same or different types, or may not create any new Tasks and end the chain. All Tasks which exist at a given point in time must not depend on each other and will run in parallel.
Paralellism is achieved by creating a fixed number of sub-processes and scheduling the Tasks on those sub-processes.
Usage Example
A simple example of how this package can be used is shown below:
import task_ruleset as Lib
import os, sys, time
def rule_init(TaskKey, TaskData):
return [Lib.Task("get", "get_" + str(i), [i]) for i in range(16)]
def rule_get(TaskKey, TaskData):
time.sleep(1)
print(TaskKey, TaskData)
Lib.NGuests = 8
Lib.Rules["init"] = (0, rule_init)
Lib.Rules["get"] = (1, rule_get)
Lib.InitTask = Lib.Task("init", "init", [])
def main():
print("Starting Execution")
Lib.main()
print(Lib.TasksAssignedToProcess)
if __name__ == '__main__':
main()
Here we first set the number of sub-processes being used to 8.
We define Tasks of 2 types:
"init"
: acted on byrule_init
, requires0
parameters
Creates 16 new tasks, all of type"get"
, with keys as"get_0"
,"get_1"
..."get_15"
, and parameters as0
,1
...15
."get"
: acted on byrule_get
, requires1
parameters
Waits for 1 second, then prints key of the Task and its parameters, then ends.
When run, this program creates 8 sub-processes and runs 1 Task of type "init"
on one sub-process. This creates 16 new tasks which needs to be schedules on 8 sub-processes. Each sub-process gets 2 Tasks. None of these Tasks create new Tasks, so the program ends.
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
Built Distribution
File details
Details for the file task-ruleset-0.0.3.tar.gz
.
File metadata
- Download URL: task-ruleset-0.0.3.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a944c64367e0c8d20848b4b8e06efa47183787c863c5166cc1f0df7e616ec20c |
|
MD5 | b600be27c21bc3f54b9d3c30346f1a58 |
|
BLAKE2b-256 | 668172d31c10e9f1f511c39ff43f964847b31428ca359b55c3e57437ccaf218f |
File details
Details for the file task_ruleset-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: task_ruleset-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d517b83dc7148efe62ace7c6d33a33b4a47bdedadf6887395363a78b291f2d8 |
|
MD5 | 6681652209e922885920030dcea35244 |
|
BLAKE2b-256 | fb25aa722541d76d15718c8a3c9354090c4eb6a7e3887ae0ffba26296f4f7b26 |