Ampeg
Ampeg is a simple and lightweight package for parallel computation. It provides
simple functions for scheduling and execution of a set of dependent or
independent computational tasks over multiple processes using the
multiprocessing package.
Requirements
Python 2.7 or later
Python 3.4 or later
Installation
pip install ampeg
Usage
Ampeg exposes a scheduling function earliest_finish_time, an execution
function execute_task_lists and a Dependency class. The former takes a
directed acyclic graph (DAG) and a number of processes and produces a set of
task lists for each process and a corresponding set of task IDs for translating
the execution result. These two form the input to execute_task_lists, which
returns a dict with the result of each task in the original graph.
The DAG is represented by a python dict of vertices where each key is the ID of
a task and each value is a triple of (function, args or kwargs, computation
cost). Edges are implicitly defined by instances of the Dependency class in
the args or kwargs.
A simple usage example computing (3^2 + 4^2) - (3^2 * 10/2):
>>> import ampeg as ag
>>> n_processes = 3
>>> my_graph = {0: (lambda x: x**2, 3, 10.8),
1: (lambda x: x**2, 4, 10.8),
2: (lambda x: x/2, 10, 11),
3: (lambda x, y: x + y, (ag.Dependency(0, None, 1),
ag.Dependency(1, None, 1), 10.7),
4: (lambda x, y: x*y, (ag.Dependency(0, None, 1),
ag.Dependency(2, None, 1)), 10.8),
5: (lambda x, y: x - y, (ag.Dependency(3, None, 1),
ag.Dependency(4, None, 1)), 10.9)}
>>> task_lists, task_ids = ag.earliest_finish_time(my_graph, n_processes)
>>> ag.execute_task_lists(task_lists, task_ids)
{0: 9, 1: 16, 2: 5, 3: 25, 4: 45, 5: -20}
The Dependency class
A dependency is a triple of (task ID or index, key (if any) and communication
cost). The key may be a single key, index or slice, or it may be an iterable of
such values to be applied in sequence. For example, the key ('values', 2)
extracts the value 5 from the dict {'values': [1, 3, 5]}. Dependency
instances are created by ampeg.Dependency(task, key, cost) where cost is
optional and defaults to 0.
Exceptions
Ampeg catches exceptions raised by individual tasks, returning them as results
encapsulated in the Err class. When an Err instance is found among the
dependencies for a task, the result for this task will be an Err instance
encapsulating a DependencyError.
Windows
Note that under Windows, the functions and their arguments must all be picklable.
Metadata
Release files for ampeg 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ampeg-0.2.0.tar.gz | 16.0 kB | Without provenance | Details for ampeg-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ampeg-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ampeg-0.2.0-py3-none-any.whl |
Total release size: 45.7 kB
Release files / ampeg-0.2.0.tar.gz
| Download URL | ampeg-0.2.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d565f66e48a35379366d57844c38f2a53646ed03ca978cf5ca5399a85b99df19
|
|
BLAKE2b-256 checksum How to use checksums |
54b9a5a642a6baa76620f6bc447894ea438a2ff6851bede7169880c65184b7fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.0
|
Release files / ampeg-0.2.0-py3-none-any.whl
| Download URL | ampeg-0.2.0-py3-none-any.whl |
|---|---|
| Size | 29.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b905b236f13b0e3fbe6bffca27c14f1cb318b3726fcd1caace3a9f138bce5d6b
|
|
BLAKE2b-256 checksum How to use checksums |
da8a50686905d8766793528f8ab392a7e3985c2b2aae96ca19269ae4d1020f95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.0
|
Security for ampeg 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.