Skip to main content

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 by rule_init, requires 0 parameters
    Creates 16 new tasks, all of type "get", with keys as "get_0", "get_1" ... "get_15", and parameters as 0, 1 ... 15.
  • "get": acted on by rule_get, requires 1 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

task-ruleset-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

task_ruleset-0.0.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file task-ruleset-0.0.1.tar.gz.

File metadata

  • Download URL: task-ruleset-0.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.6

File hashes

Hashes for task-ruleset-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1467268c8f6e240216ce12a6ea19d2cb7b72017032290d1ee1f6d38a7af5201b
MD5 4efdb514c454c90f98f3d37fc19b6c48
BLAKE2b-256 bd4557d05e6f9a259af89a78761601ae48105d5015fdb61d724c1c2c58eab990

See more details on using hashes here.

File details

Details for the file task_ruleset-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for task_ruleset-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e06430d611c0ff615dc3d8b1918d4670f61ff4daaa322520bdc5ffba2bda422
MD5 cd12a4e39b8af5acb6c08149ca5f8605
BLAKE2b-256 27454edba34d4275c8d8c8436eeef626bbfa5609e65cd5ecc5238b8ac0ed57cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page