Mpijobs
A Python3 library for running many jobs on multiple processes, using MPI.
Example
The following example runs 3 jobs. For each of them, a message is printed on the screen.
from mpi4py import MPI
from time import sleep
import mpijobs
class MyJob(mpijobs.Job):
def __init__(self,
params):
super().__init__()
self.params = params
self.result_str = None
def run(self, rank):
print("Hi, I am {0} (process {1})".format(self.params, rank))
# Pretend you're doing something useful
sleep(1.0)
# Perform a simple computation and save the result
self.result_str = self.params.upper()
JOB_LIST = [MyJob(name) for name in ('Bob', 'Alice', 'Stephen')]
RESULTS = mpijobs.run_event_loop(MPI.COMM_WORLD, JOB_LIST)
if MPI.COMM_WORLD.rank == 0: # Only one process should print the results
print("strings computed by the processes = [{0}]"
.format(', '.join([x.result_str for x in RESULTS])))
print("elapsed_time = [{0}]"
.format(', '.join([str(x.running_time) for x in RESULTS])))
The program must be run using mpirun (or an equivalent program, depending on your MPI library):
mpirun -n 3 python3 example.py
The output is the following (actual ranks and times might vary):
Hi, I am Stephen (process 2) Hi, I am Alice (process 1) Hi, I am Bob (process 1) strings computed by the processes = [ALICE, STEPHEN, BOB] elapsed_time = [0:00:01.001056, 0:00:01.001088, 0:00:01.001041]
Copyright
See the COPYRIGHT.md file.
Metadata
Release files for mpijobs 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mpijobs-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for mpijobs-0.2.2-py3-none-any.whl |
Release files / mpijobs-0.2.2-py3-none-any.whl
| Download URL | mpijobs-0.2.2-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e33d5f56c51297d185eb07bfaad473e44278a4bc4fc9d0fdf4240a5b69c59ada
|
|
BLAKE2b-256 checksum How to use checksums |
eca9f3dd8a990063a6ed70329688f4af78017c66cb6d3dc72e960ba8052e2e90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for mpijobs 0.2.2
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.