Skip to main content

NumPipe

NumPipe is a Python software package that makes long-running tasks easier and faster by executing code in embarrassingly parallel and caching the output to HDF5 files.

Features

  • Combine computation and visualization code into single scripts. Only re-run computations on request
  • Use the yield statement to return data over time that will be periodically cached to file
  • Specify dependencies between cached functions
  • Progress bars similar to tqdm that work in parallel to show the progress of running tasks
  • An optional Telegram Messenger bot that can notify the user of completion and send Matplotlib figures and animations
  • Command line arguments to re-run tasks and automatically save Matplotlib figures and animations
  • Option to use the Slurm Workload Manager to automatically create and submit an sbatch file (used on many compute clusters)

Installation

NumPipe can be installed with pip

pip install numpipe

Examples

single task

from numpipe import scheduler, pbar
from time import sleep
import matplotlib.pyplot as plt

job = scheduler()

@job.cache
def sim():
    for i in pbar(range(100)):
        sleep(.1)   # long running task...
        yield dict(i=i, x=i**2)

@job.plots
def vis():
    var = job.load(sim)
    plt.plot(var.i, var.x)

if __name__ == '__main__':
    job.run()

parallel tasks

from numpipe import scheduler, pbar
from time import sleep
import matplotlib.pyplot as plt

job = scheduler()

@job.cache
def sim(power):
    for i in pbar(range(100)):
        sleep(.1)   # long running task...
        yield dict(i=i, x=i**power)

@job.plots
def vis():
    for name, var in job.load(sim):
        plt.plot(var.i, var.x)

for i in range(3):
    job.add(sim, power=i)

if __name__ == '__main__':
    job.run()

more examples

See the examples folder for more usage examples

Command line arguments

positional arguments:
  {display,clean,slurm}
    display             display available functions and descriptions
    clean               remove all h5files that are no longer cache functions
    slurm               run on a system with the Slurm Workload Manager

optional arguments:
  -h, --help            show this help message and exit
  -r [RERUN [RERUN ...]], --rerun [RERUN [RERUN ...]]
                        re-run specific cached functions by name
  -f, --force           force over-write any existing cached data
  -d [DELETE [DELETE ...]], --delete [DELETE [DELETE ...]]
                        delete specified cached data
  -e EXCLUDE [EXCLUDE ...], --exclude EXCLUDE [EXCLUDE ...]
                        exclude cached function from being re-run
  --at-end              only run at_end functions
  --no-at-end           don't run at_end functions
  -p [PROCESSES], --processes [PROCESSES]
                        number of processes to use in parallel execution (default: cpu_count)
  -ct CACHE_TIME, --cache_time CACHE_TIME
                        time (in seconds) until data cached data is flushed to file
  --no-deps             do not rerun functions that depend on other reran functions
  --mininterval MININTERVAL
                        time (in seconds) for progress bar mininterval argument
  --notify              send notifications without delay
  --notify-message NOTIFY_MESSAGE
                        send a custom message with other notifications
  --notify-delay NOTIFY_DELAY
                        time (in seconds) before notifications will be sent
  --theme THEME         matplotlib plot theme
  --figures FIGURES [FIGURES ...]
                        which figure numbers to display
  --save [SAVE]         save figures and animations
  --save-format SAVE_FORMAT [SAVE_FORMAT ...]
                        file format for figures
  --save-figs [SAVE_FIGS]
                        save figures
  --save-anims [SAVE_ANIMS]
                        save animations
  --debug               run in debug mode (single process)

License

NumPipe is licensed under the terms of the MIT license.

Metadata

Release files for numpipe 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for numpipe 0.3.3
File Size Uploaded
numpipe-0.3.3.tar.gz 23.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for numpipe 0.3.3
File Interpreter ABI Platform
numpipe-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 50.4 kB

Release files / numpipe-0.3.3.tar.gz

Download URL numpipe-0.3.3.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2344cdead4a1e0a81b93310c4e75b027ded1d65d2baa86d340fc1d25a1ab3921
BLAKE2b-256 checksum
How to use checksums
2ba1cd64c479f058fa11195db93d7257811f9ee30e482f759f69ef35ac9a4a81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1.post20200604 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release files / numpipe-0.3.3-py3-none-any.whl

Download URL numpipe-0.3.3-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07f39484a540d48d1f25a19b663c7e551fd104fccaf8d221984d1c73e6d588cc
BLAKE2b-256 checksum
How to use checksums
efe52f49e17515f791e76b176628ca93b9b7d8d2e62cbca58136c5d7a080313a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1.post20200604 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

1 release file

0.3.1

1 release file

0.3.0

2 release files

0.2.1

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page