Skip to main content

Parallel task graph framework.

Project description

TaskGraph:

About TaskGraph

TaskGraph is great.

TaskGraph Dependencies

Task Graph is written in pure Python, but if the psutils package is installed the distributed multiprocessing processeses will be niced.

Example Use

Install taskgraph with

pip install taskgraph

Then

def _create_list_on_disk(value, length, target_path):
    """Create a numpy array on disk filled with value of `size`."""
    target_list = [value] * length
    pickle.dump(target_list, open(target_path, 'wb'))


def _sum_lists_from_disk(list_a_path, list_b_path, target_path):
    """Read two lists, add them and save result."""
    list_a = pickle.load(open(list_a_path, 'rb'))
    list_b = pickle.load(open(list_b_path, 'rb'))
    target_list = []
    for a, b in zip(list_a, list_b):
        target_list.append(a+b)
    pickle.dump(target_list, open(target_path, 'wb'))

# create a taskgraph that uses 4 multiprocessing subprocesses when possible
task_graph = taskgraph.TaskGraph(self.workspace_dir, 4)
target_a_path = os.path.join(self.workspace_dir, 'a.dat')
target_b_path = os.path.join(self.workspace_dir, 'b.dat')
result_path = os.path.join(self.workspace_dir, 'result.dat')
result_2_path = os.path.join(self.workspace_dir, 'result2.dat')
value_a = 5
value_b = 10
list_len = 10
task_a = task_graph.add_task(
    target=_create_list_on_disk,
    args=(value_a, list_len, target_a_path),
    target_path_list=[target_a_path])
task_b = task_graph.add_task(
    target=_create_list_on_disk,
    args=(value_b, list_len, target_b_path),
    target_path_list=[target_b_path])
sum_task = task_graph.add_task(
    target=_sum_lists_from_disk,
    args=(target_a_path, target_b_path, result_path),
    target_path_list=[result_path],
    dependent_task_list=[task_a, task_b])
sum_task.join()

# expect that result is a list `list_len` long with `value_a+value_b` in it
result = pickle.load(open(result_path, 'rb'))

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

taskgraph-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskgraph-0.1.1-py2-none-any.whl (7.9 kB view details)

Uploaded Python 2

File details

Details for the file taskgraph-0.1.1.tar.gz.

File metadata

  • Download URL: taskgraph-0.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for taskgraph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a5e20eb1f26713f8c5662c52186dfc0feada77d653ef444a9609c5f6450808ce
MD5 7a781941aaa8519ce334da430afac5c5
BLAKE2b-256 44a2abe7c939351a9d877e283de6ac85e4dc8954a42e1724ab63dbc467fba0b2

See more details on using hashes here.

File details

Details for the file taskgraph-0.1.1-py2-none-any.whl.

File metadata

File hashes

Hashes for taskgraph-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 458194b6bd87d4dcf208d7ec30dca9ebe51268141b306b04634ddecfd1361564
MD5 fdeb59f4cbf66b7eccf30a1ef912a304
BLAKE2b-256 99ac196ce8ed3c57c7d288bd47261531bea9f87f76fb986af4c4c1ff0faff719

See more details on using hashes here.

Supported by

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