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.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

task_ruleset-0.0.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: task-ruleset-0.0.2.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

Hashes for task-ruleset-0.0.2.tar.gz
Algorithm Hash digest
SHA256 bfa32a3478657fc6180e5b66c501375166fc72ba9a42cead7f376c562a3320f1
MD5 db07e45492edecbdc94cdcc77518f406
BLAKE2b-256 924c9c144b765c6fc4ab9aaad3ec9802b60ef055c04172fc7d52b069910b000f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for task_ruleset-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b5879a6b2daae50fd1b836c8fc1aa65b40b06ef88c3d6998c4cc7eb887f2503
MD5 9eb13dcfbcaa207dd8a1082768bc53eb
BLAKE2b-256 60dcbc1c8d42d4dbc22a82ea320d6eb6cb635e7748a2a75b16eb4ea05d86849f

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